Sending logs
How your game server sends Game Log records: the one endpoint, realtime batches, full-log files and the errors. Sign every request as described in Authentication. Samples to download: send.js, upload-full-log.js and sign.js (needed by the other two; keep the three files in one folder).
Realtime batch vs full-log file
You can send the same log type in two ways. Both use the same URL; the Content-Type header decides which one Alogame applies.
| Realtime batch | Full-log file | |
|---|---|---|
| What it is | A few records, sent as they happen | All records of a log type for a period, in one gzip file |
| When to use | register, login, logout, recharge, ccu: within 15 minutes of the event. money_flow, item_flow, user_snapshot, mission, ad_revenue: at least once a day | Once a day after the day ends, for each of the 8 required log types; and whenever you need to correct data |
| Request | POST the URL below with Content-Type: application/json | POST the same URL with Content-Type: application/x-ndjson and Content-Encoding: gzip |
| Body | A JSON array of 1–1000 records | gzip of NDJSON: one record per line |
| Response | 200 { accepted, duplicate, flagged, rejected } straight away | 202 { batch_id, status: "received" }; Alogame processes the file afterwards |
| Record that already exists | The stored record is kept (counted as duplicate) | The record in the file overwrites the stored one: the file wins over realtime. One exception: a record whose key is stored under another day is kept |
| Size limit | Body up to 5 MB | File up to 512 MB |
| When it shows up in KPI | As soon as Alogame has stored the records | After Alogame has processed the file; a day is closed at 06:00 GMT+7 of the next day and shows as final at the next refresh, about 08:00 |
Send both: realtime is fast, the file makes it correct. To correct data, send a file.
Which one, when:
- During the day: send
register,login,logout,rechargeandccuas realtime batches, within 15 minutes of the event. The200response tells you at once which records were rejected. - Other types: send
money_flow,item_flow,user_snapshot,missionandad_revenueas batches at least once a day. - After the day ends: send one file per required log type, between 00:00 and 06:00 GMT+7 of the next day. This is the complete copy; it also covers records that were lost or sent twice.
- To correct data: send a file again. Its values replace the stored ones, except for the cross-day case below.
Endpoint
| Method | Path | Use |
|---|---|---|
POST | {BASE_URL}/ | Realtime batch or full-log file, chosen by Content-Type |
{game_id}is your game id and{log_type}is one ofregister,login,logout,recharge,ccu,money_flow,item_flow,user_snapshot,mission,ad_revenue. An unknown{log_type}returns404 UNKNOWN_LOG_TYPE.client_id(optional, 1–64 characters, defaultdefault): usedefaultunless Alogame told you that your game runs several client builds with separate schemas.schema_version(required, integer ≥ 1): the version of the column list your records follow. Version 1 is the column list in Log types.- Both parameters go in the query string, for batches and for files, never in the body. The query is part of the signature.
Body of a request
The body carries only records. Each record is a JSON array of values in column order, not an object. A batch is an array of records:
[
["acc-1001", "role-1", "Hero", "VN", "2026-11-02 10:15:00", "google", "s1", "10.0.0.1", "Android", "14", "dev-1", "Pixel 8"],
["acc-1002", "role-2", "Mage", "VN", "2026-11-02 10:15:03", "apple", "s1", "10.0.0.2", "iOS", "17", "dev-2", "iPhone 15"]
]
This is a login batch. The values of the first record, in the column order of login:
| # | Column | Value above |
|---|---|---|
| 1 | account_id | acc-1001 |
| 2 | role_id | role-1 |
| 3 | role_name | Hero |
| 4 | country_code | VN |
| 5 | login_time | 2026-11-02 10:15:00 |
| 6 | login_channel | google |
| 7 | server_id | s1 |
| 8 | client_ip | 10.0.0.1 |
| 9 | os_platform | Android |
| 10 | os_version | 14 |
| 11 | device_id | dev-1 |
| 12 | device_name | Pixel 8 |
A file holds the same records, one per line, with no surrounding brackets and no commas between lines:
["acc-1001","role-1","Hero","VN","2026-11-02 10:15:00","google","s1","10.0.0.1","Android","14","dev-1","Pixel 8"]
["acc-1002","role-2","Mage","VN","2026-11-02 10:15:03","apple","s1","10.0.0.2","iOS","17","dev-2","iPhone 15"]
Sending a batch
// send.js (excerpt)
const body = JSON.stringify(records); // [[...], [...]]
const ts = Math.floor(Date.now() / 1000);
const url = `/ingest/v1/games/${GAME_ID}/logs/${logType}?client_id=default&schema_version=1`;
const res = await fetch(`${BASE_URL}${url}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Key-Id': KEY_ID, 'X-Timestamp': String(ts), 'X-Signature': sign(SECRET, ts, 'POST', url, body),
},
body,
});
const result = await res.json(); // { accepted, duplicate, flagged, rejected: [{ index, reason_code }] }
Download the scripts, then run the whole sample against your sandbox: GAME_LOG_BASE_URL=… GAME_LOG_GAME_ID=… GAME_LOG_KEY_ID=… GAME_LOG_SECRET=… node send.js. It sends one login and one recharge batch and prints each result.
Resending is safe. Records are de-duplicated on their duplicate key (Log types). A record that is already stored is kept and comes back as duplicate. Resend a whole batch after a timeout or a 5xx. Retry with exponential backoff; do not retry 4xx other than 429.
Per-record problems are not HTTP errors: they come back in rejected of the 200 response (Log reference).
Errors of a batch
| Status | code | Meaning | Action |
|---|---|---|---|
| 400 | INVALID_BODY | The body is not a JSON array of 1–1000 records, or client_id / schema_version in the query is missing or malformed | Fix the request |
| 401 | INVALID_SIGNATURE | Unknown key, revoked key, or the signature does not match the method, path, query or body | Check key, secret, and that you sign the exact path, query and bytes you send |
| 401 | STALE_TIMESTAMP | X-Timestamp is more than 300 s from Alogame's clock | Sync your clock. Send X-Timestamp in seconds since 1970; a value in milliseconds is also rejected as stale |
| 403 | KEY_GAME_MISMATCH | The key belongs to another game than {game_id} | Use the right key |
| 403 | REALTIME_DISABLED | Realtime is switched off for your game | Send files instead; contact Alogame to switch realtime on |
| 404 | UNKNOWN_GAME / UNKNOWN_LOG_TYPE | {game_id} is not registered, or Game Log is switched off for this game / unknown {log_type} | Check the URL; if it is correct, ask the Alo team whether Game Log is enabled for your game |
| 413 | PAYLOAD_TOO_LARGE | Body over 5 MB | Split the batch |
| 429 | RATE_LIMITED | More than 600 requests per rolling 60 seconds for this key (Alogame can set another limit for your game) | Send fewer, larger batches. Requests that were rejected also count against the limit, so after a 429 wait most of a minute before retrying |
Error bodies are { "code": "…", "message": "…" }. Requests rejected with 401 are never stored.
Sending a file
For each of the eight required log types, send the full log of day D after D ends (from 00:00 GMT+7 of D+1) and before 06:00 GMT+7 of D+1. If no file of a required log type arrives in that window, Alogame raises an alert. Alogame does not check that a file is complete: the two sides trust each other, so send everything you have for the day.
- Build the file. Write one record (a JSON array) per line, same columns and order as realtime, then gzip the whole file. Save it as
.ndjson.gz. - Hash the compressed file. Compute the SHA-256 of the compressed bytes (not of the NDJSON) as lower-case hex.
- Sign. The fifth value of the signature string is that same hash.
- POST to the endpoint with
Content-Type: application/x-ndjson,Content-Encoding: gzip,Content-Length, andX-Content-Sha256set to the hash. Alogame checks the signature before it accepts the body, so compute the hash first, then upload. - Read the response.
202 { batch_id, status: "received" }means Alogame has the file and will process it afterwards. Keep thebatch_id. A202does not say the file is valid. Records that fail validation are stored in the rejects table with the same reason codes as realtime, and never stop the rest of the file; they do not appear in the response. - Know what can still fail later. Some problems are found only while the file is processed, after you have your
202: a line longer than 1 MiB (a record is one JSON array, so a file that is not NDJSON usually breaks this), a body that is not gzip, or a truncated gzip. The batch is then marked failed and Alogame's data team is alerted; records read before the failure stay applied. There is nothing to poll: ask the Alo team for the status of yourbatch_id. Check the file before you send it, for example withgzip -t login.ndjson.gz, and send it again after a fix (resending is safe).
// upload-full-log.js (excerpt)
const body = fs.readFileSync(file); // already gzipped NDJSON
const sha = crypto.createHash('sha256').update(body).digest('hex'); // hash of the compressed bytes
const url = `/ingest/v1/games/${GAME_ID}/logs/${logType}?client_id=default&schema_version=1`;
const res = await fetch(`${BASE_URL}${url}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-ndjson', 'Content-Encoding': 'gzip', 'X-Content-Sha256': sha,
'X-Key-Id': KEY_ID, 'X-Timestamp': String(ts), 'X-Signature': sign(SECRET, ts, 'POST', url, body),
},
body,
});
Run it with node upload-full-log.js login ./login.ndjson.gz (same environment variables as send.js).
- Duplicates: a record that already exists is overwritten by the file's values, so late, lost or duplicated realtime records do not affect the final KPIs.
- Cross-day exception: for
register,recharge,money_flowanditem_flow, the duplicate key does not contain a date. If a record in your file has a key that is already stored under a different day, the stored record is kept and the file's record is counted as a duplicate. So a correction that moves such a record across midnight (for example arecharge_timeorcreate_timecorrected from 23:58 to 00:02) cannot be fixed by sending a file. Contact the Alo team to have it corrected. - Any days in one file: each record is stored under the day of its own timestamp, so one file may contain records of any days.
- Big days: if a day is too big for one file (over 512 MB), send it as several independent files. Each file must be complete in itself, which is a gzip of whole lines.
- Concurrent uploads: Alogame limits how many file uploads of your game run at the same time (4 by default; Alogame can change it for your game). This is a maximum: you do not have to send 4 at a time. Over the limit you get
429 TOO_MANY_UPLOADSbefore the body is read: wait and retry. A limit of0switches file uploads off (403 FULL_LOG_UPLOAD_DISABLED). - Content-Length: always send it. A file over 512 MB is refused with
413before it is read; a request withoutContent-Length(chunked upload) gets411. - Final day: a day is closed at 06:00 GMT+7 of the next day, whichever files arrived, and shows as
finalat the next scheduled refresh, about 08:00 GMT+7. A later file still updates the days it contains. - Correcting data: to correct data, send a file; its values replace the stored ones, except for the cross-day exception.
Errors of a file
| Status | code | Meaning | Action |
|---|---|---|---|
| 400 | INVALID_BODY | client_id or schema_version in the query is missing or malformed | Fix the query |
| 401 | INVALID_SIGNATURE | X-Content-Sha256 is missing, is not a SHA-256 in hex, or differs from the hash of the body; or the signature is wrong | Hash the compressed bytes, sign with that hash, and send the file again; nothing was stored |
| 401 | STALE_TIMESTAMP | X-Timestamp is more than 300 s from Alogame's clock | Sync your clock |
| 403 | KEY_GAME_MISMATCH | The key belongs to another game than {game_id} | Use the right key |
| 403 | FULL_LOG_UPLOAD_DISABLED | File uploads are switched off for your game | Contact Alogame |
| 404 | UNKNOWN_GAME / UNKNOWN_LOG_TYPE | As for batches | Check the URL |
| 411 | LENGTH_REQUIRED | No valid Content-Length header | Send Content-Length; do not upload chunked |
| 413 | PAYLOAD_TOO_LARGE | File over 512 MB | Split it into several files |
| 422 | UNKNOWN_SCHEMA_VERSION / LOG_TYPE_NOT_DECLARED | Alogame has no locked schema for this client_id + schema_version + log_type. Checked before any byte is accepted; nothing is stored | Ask the Alo team to declare the schema, then upload again |
| 429 | TOO_MANY_UPLOADS | Too many file uploads of your game are running | Wait and retry |
| 429 | RATE_LIMITED | Too many requests for this key | Back off |
| 503 | STORAGE_UNAVAILABLE | Alogame could not store the file | Retry later |
| 503 | QUEUE_UNAVAILABLE | Alogame stored the file but could not queue its processing | Send the file again; resending is safe, the same records overwrite themselves |
Implementation checklist
- Every timestamp is GMT+7
yyyy-MM-dd HH:mm:ss. - Records are arrays in column order and carry exactly the declared number of columns.
-
client_idandschema_versionare in the query, not in the body; the query is signed. - Realtime types reach Alogame within 15 minutes; the other types are sent at least once a day.
- The full log of day D, for each of the 8 required log types, is sent between 00:00 and 06:00 GMT+7 of D+1, with the SHA-256 of the compressed bytes in
X-Content-Sha256. -
rechargeis sent only for completed payments, with the SDKtransaction_id. -
ccuis sent every 5 minutes, one record per server per platform, sameevent_timefor all servers. -
user_snapshotis taken at 23:59:59 GMT+7 for every active character and currency. - No secret is committed to source control or written to logs.
Alogame then verifies your data over three consecutive days using the acceptance checklist.