# Developer API reference

The developer API lets your own server read your studio's data without opening the console. It is **read-only**, scoped to one studio, and authenticated with a **studio API token**. The one write is uploading a build from CI with the optional `builds:write` scope (see [Upload a build from CI](#upload-a-build-from-ci)); nothing else changes a game through it, and a build uploaded that way is never made live by the API. A pipeline that must react to a new build can subscribe to the `build.published` and `build.activated` webhooks. It is separate from the leaderboard server API key, which only submits scores for one game (see [leaderboards](https://docs.zokogames.com/sdk/leaderboards)).

Base URL: `https://www.zokogames.com/api/v1`

The machine-readable description is an OpenAPI 3.1 file at `https://www.zokogames.com/api/v1/openapi.json`. It is generated from the same schemas the API uses, so it always matches. Load it into your API client or code generator. It also describes `POST /leaderboard/scores`, the one write, which takes a game's leaderboard server key instead of a studio token (see [leaderboards](https://docs.zokogames.com/sdk/leaderboards#server-api)).

## Tokens

Owners and admins create tokens on the **Studio API tokens** page of the developer console (left menu) (or with `POST /api/developer/orgs/{studioId}/tokens` while signed in to the console). Creating or revoking a token asks you to confirm it is you with a passkey or an authenticator app. If you have neither yet, set one up first in your player account on zokogames.com (console account menu, **Settings**, then **Account**).

- A token looks like `zst_` followed by 43 characters (256 bits of randomness). It is **shown once**, when you create it. We store only a one-way hash, so we cannot show it again: if you lose it, revoke it and create a new one.
- Each token has a **name** (up to 60 characters), one or more **scopes**, a **rate limit** (10 to 1,200 requests per minute, default 300) and an optional expiry (1 to 730 days; the console offers 30, 90 or 365 days, or never). The console has no rate-limit field, so a token created there gets 300 a minute; `GET /api/v1` shows a token's limit as `rate_limit_per_min`. Spread a large pull over time, or split it across tokens, rather than spending one token's minute at once.
- A studio can have up to **10** active tokens. Revoking a token stops it working at once.
- **Rotating a token.** There is no rotate button, and a token's name, scopes and limit cannot be edited. Create the new token, switch your server to it, wait until the old token's **Last used** time stops moving, then revoke the old one. Both work side by side until then, so nothing fails during the switch.
- The console shows when each token was **last used** (recorded at most once a minute) and the first characters of the token so you can tell them apart. Creating and revoking a token is written to the studio's audit trail, and the studio's team gets an email when a token is created or revoked (the email names the token and its first characters, never the token). Owners and admins also get a notice in the console, and an email, 7 days before a token expires, once per token, so a token with an expiry does not stop a pipeline without warning: create its replacement then.
- Treat a token like a password. Keep it on your server, never in a game build or a web page, and never in a URL: a request with `token`, `access_token`, `api_key` or similar in the query string is refused with `400 invalid_query` before the token is even looked at (the response names the parameter, never its value, and `details` says `token_in_url`).

**Scopes**

| Scope | Allows |
| --- | --- |
| `games:read` | `GET /api/v1/games`, `GET /api/v1/games/{id}`, `GET /api/v1/games/{id}/builds`, `GET /api/v1/games/{id}/feedback`, `GET /api/v1/leaderboards` |
| `stats:read` | `GET /api/v1/games/{id}/stats`, `GET /api/v1/games/{id}/stats/daily` |
| `statements:read` | `GET /api/v1/statements`, `GET /api/v1/statements/{id}/lines` |
| `builds:write` | `POST /api/v1/games/{id}/builds/uploads`, `POST /api/v1/games/{id}/builds/uploads/{uploadId}/parts`, `POST /api/v1/games/{id}/builds/uploads/{uploadId}/confirm`, `GET /api/v1/games/{id}/builds/uploads/{uploadId}` |

`GET /api/v1` itself needs only a valid token. Give a token the fewest scopes it needs: for example, a dashboard that shows plays does not need `statements:read`. `builds:write` is off by default in the console's create form: tick it only for a token that is used by CI. A request without the needed scope gets `403 insufficient_scope`. The scopes of an existing token cannot be changed: create a new token with the scopes you need, then revoke the old one.

**Authentication.** Send the token as a bearer token:

```bash
curl -H "Authorization: Bearer zst_your_token" https://www.zokogames.com/api/v1
```

`X-API-Key: <token>` is accepted as well. Session cookies are **never** accepted on `/api/v1`: a request with only a cookie gets `401`.

**Browsers and CORS.** The API is for servers. No `/api/v1` response carries CORS headers, so a web page on any origin cannot read it, and an `OPTIONS` request answers `204` with `Allow: GET, HEAD, OPTIONS` and allows nothing cross-origin. The only exception is `openapi.json`, which is public, holds no studio data and may be loaded from any origin.

## Requests and responses

- Apart from the four build-upload calls (scope `builds:write`), only `GET` (and `HEAD`) exist. A request body over 1 KB (600 KB on the build-upload calls), or any chunked body, is refused with `413 payload_too_large`; URLs are limited to 2,048 characters (longer: `414 uri_too_long`). Any other method answers `405 method_not_allowed` with an `Allow` header, and an unknown path under `/api/v1` answers `404 not_found`; both use the JSON error envelope. `HEAD` returns the headers of the `GET` and no body.
- Use the paths exactly as listed, **without a trailing slash**. `/api/v1/` is answered by the web framework with a `308` redirect to `/api/v1` before the API sees the request, so it carries no API headers; many HTTP clients drop the `Authorization` header when they follow a redirect. Call `/api/v1` directly.
- Always call the `www.zokogames.com` host. `zokogames.com` answers with a `308` redirect to `www`, and HTTP clients drop the `Authorization` header when they follow a redirect to another host, so the request arrives without your token.
- Query parameters are strict: an unknown or repeated parameter is `400 invalid_query`.
- **Ids.** `{id}` in a path is always the UUID in the `id` field of the list that holds it: a game's `id` from `GET /api/v1/games` (also the `game_id` of leaderboards, feedback and stats), a statement's `id` from `GET /api/v1/statements`. A game's `slug` (its address name) and its name are **not** accepted as `{id}`; they answer `400 invalid_params`. The game id never changes, also after launch. The console shows it too, on a game's Leaderboard page as **Your game id**.
- Every response except `openapi.json` has an `x-request-id` header, including those of `POST /leaderboard/scores`. Quote it when you contact support. The same value is in `error.requestId` for errors.
- Dates and times are ISO 8601 in UTC with a trailing `Z`, such as `2026-11-18T09:30:00.000Z`. Calendar days are `YYYY-MM-DD` (UTC) and months `YYYY-MM`.
- Field names are `snake_case` and stable: new fields may be added, existing ones are not renamed or removed within `v1`. Ignore fields you do not know.
- Money is an **integer number of minor units** (cents for USD) next to its ISO 4217 `currency` and `currency_exponent`. Amounts are truncated toward zero to whole minor units, the way payouts are. Never use floating point for these.
- Successful `GET` responses carry an `ETag` and `Cache-Control: private, no-cache`. Send it back as `If-None-Match` to get a `304` with no body when nothing changed. A `304` still counts against your rate limit. It may arrive without `RateLimit-*` headers (the hosting edge can drop them), so read your remaining quota from the last `200` response (or any non-`304` response). The public `/api/v1/openapi.json` is the exception: it needs no token, is cached by the CDN for an hour, is not metered and never carries `RateLimit-*` headers, so a `304` from it has none either.

### Rate limits

Each token has its own fixed one-minute window (see **Tokens** for the limit). Every authenticated response, errors included, reports it, except that a `304` may arrive without these headers:

| Header | Meaning |
| --- | --- |
| `RateLimit-Limit` | Requests allowed per window. |
| `RateLimit-Remaining` | Requests left in this window. |
| `RateLimit-Reset` | Seconds until the window resets. |
| `RateLimit-Policy` | For example `300;w=60`: 300 requests per 60 seconds. |

Every request that carries a valid token spends one unit of its minute, including `HEAD`, `304` and `4xx` answers (a request refused for a bad token, a suspended studio or an oversized body spends none). When the budget is spent you get `429 rate_limited` with `Retry-After` (whole seconds; for a token's own limit the same number as `RateLimit-Reset`, at most 60). Back off and retry after that time. With curl, `--retry 3` does this for you: it waits for `Retry-After` on a `429`.

An example of the answer when a token's minute is spent:

```http
HTTP/2 429
retry-after: 23
ratelimit-limit: 300
ratelimit-remaining: 0
ratelimit-reset: 23
ratelimit-policy: 300;w=60
```

Every `/api/v1` endpoint except the build-upload calls is a read-only `GET`, so repeating a request is idempotent and always safe to retry. The upload calls have their own retry rules (see below). Repeated bad or missing tokens from one address are throttled too (30 a minute), and also answer `429`; a valid token from that address is still served. A very high total request rate from one address (far above what any token is allowed) also answers `429` with `Retry-After`, whatever the token.

### Errors

Every error of the studio-token endpoints is JSON with the same envelope and an HTTP status, and is never cached. The one exception is `POST /api/v1/leaderboard/scores`, which takes a game's server key instead of a studio token: it answers `{ "ok": false, "error": "invalid-api-key", "message": "…", "hint": "…" }` with its own dash-style codes, listed with their fixes under [errors of the server API](https://docs.zokogames.com/sdk/leaderboards#errors-of-the-server-api). It has no `error.requestId`; its `x-request-id` header is the id to quote.

```json
{
  "error": {
    "code": "insufficient_scope",
    "message": "This token needs the \"games:read\" scope. A token's scopes cannot be changed: create a token with that scope on the API tokens page of the developer console, then revoke this one if nothing else uses it.",
    "requestId": "6f0c9a3e-3b1d-4a53-9c1e-2d1f6a7b8c90"
  }
}
```

Branch on `code`, which is stable; `message` is for people, says what to do next, and may change. Errors about the request itself (`invalid_query`, `invalid_params`, `invalid_cursor`) also carry `details`, an array with one `{ "field", "problem" }` entry per problem, for example:

```json
{
  "error": {
    "code": "invalid_query",
    "message": "limit must be an integer between 1 and 100. Unknown query parameter: foo.",
    "requestId": "6f0c9a3e-3b1d-4a53-9c1e-2d1f6a7b8c90",
    "details": [
      { "field": "limit", "problem": "out_of_range" },
      { "field": "foo", "problem": "unknown_parameter" }
    ]
  }
}
```

`problem` is one of `unknown_parameter`, `duplicate_parameter`, `invalid_value`, `out_of_range` or `token_in_url`.

A `401 invalid_token` also carries one `details` entry, with `field` `authorization`, that says why the token was not accepted:

| `problem` | Meaning | What to do |
| --- | --- | --- |
| `missing` | No `Authorization` or `X-API-Key` header was sent. | Send `Authorization: Bearer <token>`. |
| `malformed` | A header was sent, but it does not hold `zst_` and 43 characters. | Copy the whole token, without quotes or spaces. |
| `unknown` | The token is well formed but is not one of ours. | Check the copy; if the token is lost, create a new one. |
| `revoked` | The token was revoked in the console. | Create a new token. |
| `expired` | The token's expiry date has passed. | Create a new token. |

The `code` is `invalid_token` in every case, so branch on `details[0].problem` when you need the reason. For example, a revoked token answers `"details": [{ "field": "authorization", "problem": "revoked" }]`. `details` is absent on other errors.

Checks run in a fixed order, so you can tell which problem you hit first: body and URL size (`413`, `414`), a token in the URL (`400 invalid_query`), the token (`401`), a suspended studio (`403 developer_suspended`), the token's rate limit (`429`), the scope (`403 insufficient_scope`), the query string (`400 invalid_query`), the `{id}` in the path (`400 invalid_params`), then the data itself (`400 invalid_cursor`, `404 not_found`, `409 amount_unsafe`). A request with the wrong scope and a bad query therefore answers `403`, and every request that got past the token, whatever it answers, spent one unit of the token's minute.

Every `200` and every error response carries `x-request-id` and `Vary: Authorization, X-API-Key`; a `304` may arrive without them. Authenticated responses (200, and errors after the token was accepted and its budget spent, 429 included; not `developer_suspended`, which is answered first) also carry the `RateLimit-*` headers, and a 429 has `Retry-After`.

| Status | `code` | Meaning |
| --- | --- | --- |
| 400 | `invalid_query` | A query parameter is unknown, repeated, malformed or out of range (including a bad stats date range). `message` says which and `details` names each field. |
| 400 | `invalid_params` | The `{id}` in the path is not a UUID, for example a game's slug or name. Use the `id` from the list endpoint. |
| 400 | `invalid_cursor` | The `cursor` is not one we issued. Start again without it. |
| 401 | `invalid_token` | No token, or one that is malformed, unknown, revoked or expired; `details[0].problem` says which (see above). It carries `WWW-Authenticate: Bearer realm="zokogames"`, with `error="invalid_token"` added when a credential header was sent. |
| 403 | `insufficient_scope` | The token lacks the scope this endpoint needs; `message` names it. Create a token with that scope. |
| 403 | `developer_suspended` | The token's studio is suspended, so all its tokens are refused until it is reinstated. Contact developer support. |
| 404 | `not_found` | The game is not one of your studio's (a game of another studio looks the same as one that does not exist), or the path is not an endpoint. |
| 405 | `method_not_allowed` | The method is not `GET`, `HEAD` or `OPTIONS`. `Allow` lists the supported ones. |
| 409 | `amount_unsafe` | Statements endpoints only. An amount of a statement on the page you asked for is outside the range the API can state exactly (beyond 9,007,199,254,740,991 micros), so the whole response is refused rather than rounded. Retrying gives the same answer. Contact developer support: the portal team settles that statement by hand. The `statement.updated` webhook carries `payableMicros: null` for the same statement. |
| 413 | `payload_too_large` | The request body is over 1 KB (600 KB on the build-upload calls), or it was sent chunked. The read endpoints take no body at all. |
| 414 | `uri_too_long` | The URL is longer than 2,048 characters. |
| 429 | `rate_limited` | Too many requests. Wait `Retry-After` seconds. |
| 400 | `invalid_body` | Build upload only. The JSON body is not valid JSON or a field is wrong; `details` names each field. |
| 409 | `too_many_inactive_builds` | Build upload only. The game already holds 10 builds uploaded with API tokens that are not active. Delete old inactive builds on the game's **Builds and updates** page in the console, then start again. |
| 409 | `locked_in_review` | Build upload only. The game is in review, so builds cannot change. Upload again once it is decided. |
| 404 | `upload_not_found` | Build upload only. No such upload for this game and this token's creator. |
| 409 | `upload_closed` | Build upload only. The upload was refused, expired or cleaned up. Start a new one. |
| 409 | `already_processed` | Build upload only. The upload was already confirmed. |
| 409 | `upload_in_progress` | Build upload only. Another confirm is still processing this upload; poll its status. |
| 409 | `not_uploaded` | Build upload only. The file has not arrived in storage yet: finish the `PUT`, then confirm again. |
| 422 | `upload_invalid` | Build upload only. The stored file is not what you declared (a size mismatch answers `409` with the same code). |
| 400 | `parts_required` | Build upload only. A multipart confirm needs the list of parts. |
| 400 | `not_multipart` | Build upload only. A part was requested for an upload that is not multipart. |
| 400 | `invalid_part_number` | Build upload only. The part number is outside the upload's part count. |
| 400 | `invalid_part_size` | Build upload only. A part must be exactly the size the start call announced. |
| 429 | `too_many_open_uploads` | Build upload only. Too many uploads are still waiting to finish (the console's cap, per token creator). |
| 429 | `daily_upload_limit` | Build upload only. Too many uploads were started in 24 hours without being finished. |
| 503 | `storage_unavailable` | Build upload only. Storage did not answer; retry in a minute. |
| 500 | `internal_error` | Our side. Retry after a short wait; if it keeps happening, send us the `requestId`. |

### Pagination

List endpoints take `limit` (1 to 100, default 25) and `cursor`, and answer:

```json
{ "data": [ ... ], "next_cursor": "eyJ0Ijoi...", "meta": { "limit": 25, "count": 25, "has_more": true } }
```

`meta` is on every list: `limit` is the page size applied, `count` the items in `data`, and `has_more` is true exactly when `next_cursor` is set. Some lists add fields to `meta` that describe the whole answer (for example `game_id` or the resolved `range`). Pass `next_cursor` as `cursor` to get the next page; it is `null` on the last page. A cursor is opaque: do not build or change one. Pages are stable while you walk them: a game created meanwhile does not shift the rows you have not seen yet.

### Walk every page

The loop below follows `next_cursor` until it is `null` and prints every game id. It needs `curl` and `jq`.

```bash
cursor=""
while :; do
  page=$(curl -fsS --retry 3 -H "Authorization: Bearer $ZOKO_TOKEN" \
    "https://www.zokogames.com/api/v1/games?limit=100${cursor:+&cursor=$cursor}")
  jq -r '.data[].id' <<<"$page"
  cursor=$(jq -r '.next_cursor // empty' <<<"$page")
  [ -n "$cursor" ] || break
done
```

A cursor only uses the characters `A-Z a-z 0-9 - _`, so it can go into the URL as it is.

## API index

`GET /api/v1`. Any valid token. Lists every endpoint, which of them this token may call, and the token's own details.

```json
{
  "version": "1",
  "studio_id": "…",
  "token": { "id": "…", "name": "reporting", "prefix": "zst_AbCdEfGh", "scopes": ["games:read"],
             "rate_limit_per_min": 300, "expires_at": null },
  "endpoints": [ { "method": "GET", "path": "/api/v1/games", "summary": "List the studio's games",
                   "scope": "games:read", "allowed": true } ],
  "docs_url": "https://www.zokogames.com/docs/guides/developer-api",
  "openapi_url": "https://www.zokogames.com/api/v1/openapi.json"
}
```

It is the quickest way to test a new token: a `200` proves the token works, and `allowed` shows what it can reach.

## Games list

`GET /api/v1/games?limit=&cursor=`. Your studio's games, newest first (scope `games:read`).

```bash
curl -H "Authorization: Bearer zst_your_token" "https://www.zokogames.com/api/v1/games?limit=10"
```

Each item:

```json
{
  "id": "5b0c…", "slug": "sky-runner", "name": "Sky Runner", "status": "full_launch",
  "category": "arcade", "technology": "html5", "orientation": "landscape",
  "plays": 18230, "upvotes": 412, "downvotes": 9, "is_kids": false, "has_iap": false,
  "devices": { "desktop": true, "phone": true, "tablet": true, "chromebook": true, "android": true, "ios": true },
  "allow_embed": false, "allowed_origins": [],
  "published_at": "2026-09-01T10:00:00.000Z",
  "created_at": "2026-08-20T08:15:00.000Z", "updated_at": "2026-11-02T16:40:00.000Z"
}
```

`published_at` is `null` until the game goes live. `status` is one of `draft`, `submitted`, `in_qa`, `changes_requested`, `rejected`, `basic_launch`, `full_qa`, `full_launch` or `unpublished`; players can open the game in `basic_launch`, `full_qa` and `full_launch`, and a state you do not know should be treated as not live. `plays`, `upvotes` and `downvotes` are running totals, not per day.

`has_iap` is `true` when the game offers in-game purchases; a made-for-children game cannot turn it on.

## Game detail

`GET /api/v1/games/{id}` (scope `games:read`).

```bash
curl -H "Authorization: Bearer zst_your_token" "https://www.zokogames.com/api/v1/games/5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d"
```

The fields above plus `short_description`, `description`, `hosting`, `age_rating` (or `null`), `locales` (ISO 639-1 codes), `is_multiplayer`, `has_leaderboard`, `ads_enabled`, `offline_play` and `guide_url` (or `null`). A game of another studio answers `404 not_found`.

### Text format of description and release notes

`description` in the game detail and `release_notes` in the builds list come back exactly as stored. A value saved now is **Markdown** with the fixed set of formatting described in [text formatting](https://docs.zokogames.com/requirements/text-formatting).

A value last saved before 21 November 2026 can still be HTML from the old editor (`description`) or plain text (`release_notes`) until someone saves that field again. There is no format flag: a value that begins with an HTML tag such as `<p>` is most likely old HTML.

Treat every value as untrusted text. Render it through your own sanitiser and never insert it into a page as unsanitised HTML. The controls, FAQ and studio description are not part of the API.

The token API is read-only and cannot write these fields. When a signed-in studio member saves them in the console, the server sanitises them as Markdown.

## Game stats

`GET /api/v1/games/{id}/stats?from=YYYY-MM-DD&to=YYYY-MM-DD`. Daily stats of one of your games (scope `stats:read`).

```bash
curl -H "Authorization: Bearer zst_your_token" \
  "https://www.zokogames.com/api/v1/games/5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d/stats?from=2026-11-01&to=2026-11-18"
```

Days are UTC and both ends are inclusive. `to` defaults to today and `from` to 29 days before `to`. The longest range is **92 days**, `from` must not be after `to`, and `to` cannot be in the future; otherwise `400 invalid_query`. The numbers come from the same report as a game's **Performance** section in the console, so the same days give the same figures; today is still being counted (hourly) and the console leaves it out. Fields use the CSV column names: `gameplays` is the console's **Plays**, `views` its **Views**; the analytics and metrics reference maps every one. Revenue is not part of this endpoint; money is in statements.

```json
{
  "game_id": "5b0c…",
  "range": { "from": "2026-10-20", "to": "2026-11-18" },
  "totals": { "impressions": 1200, "views": 480, "players": 130, "gameplays": 310,
              "playtime_sec": 52000, "avg_playtime_sec": 168, "ctr": 0.4, "conversion": 0.12, "d1_retention": 0.21,
              "orders": 7 },
  "by_day": [ { "day": "2026-10-20", "impressions": 40, "views": 16, "players": 5, "gameplays": 11,
                "playtime_sec": 1800, "avg_playtime_sec": 164, "ctr": 0.4, "conversion": 0.1, "d1_retention": 0.2,
                "orders": 0 } ]
}
```

`by_day` has one entry for every day in the range, with zeros for quiet days. `ctr`, `conversion` and `d1_retention` are fractions from 0 to 1. `players` is the sum of daily unique players, so across several days it can count one person more than once. `orders` is the number of in-game orders your game reported through [`SDK.analytics.trackOrder`](https://docs.zokogames.com/sdk/analytics): self-reported by the game, capped per game and day, and never ZokoGames revenue or part of a payout.

## Statements list

`GET /api/v1/statements?limit=&cursor=`. Your studio's cut statements, newest period first (scope `statements:read`). Open months are not listed until the month is closed.

```bash
curl -H "Authorization: Bearer zst_your_token" "https://www.zokogames.com/api/v1/statements"
```

Sample response (`StatementList`, generated from the test fixture):

```json
{
  "data": [
    {
      "id": "9a1f4c2e-6b3d-4e8a-b5c7-0d2e1f3a4b6c",
      "period": "2026-10",
      "state": "invoiced",
      "currency": "USD",
      "currency_exponent": 2,
      "invoice_number": "INV-2026-10-0007",
      "gross_minor": 1334,
      "share_minor": 675,
      "adjustments_minor": 25,
      "carried_in_minor": 123,
      "payable_minor": 798,
      "paid_at": null,
      "paid_reference": null,
      "paid_minor": null,
      "held_back_minor": null
    },
    {
      "id": "3c7e9b1a-2d4f-4a6c-8e0b-5f1a2c3d4e6f",
      "period": "2026-09",
      "state": "paid",
      "currency": "USD",
      "currency_exponent": 2,
      "invoice_number": "INV-2026-09-0007",
      "gross_minor": 40000,
      "share_minor": 20000,
      "adjustments_minor": 0,
      "carried_in_minor": 0,
      "payable_minor": 20000,
      "paid_at": "2026-11-16T10:00:00.000Z",
      "paid_reference": "TR-1042",
      "paid_minor": 16000,
      "held_back_minor": 4000
    }
  ],
  "next_cursor": null,
  "meta": {
    "limit": 25,
    "count": 2,
    "has_more": false
  }
}
```

Amounts are in minor units (the [webhooks](https://docs.zokogames.com/guides/webhooks) use micros, millionths of the currency: to compare a `statement.updated` `payableMicros` with `payable_minor`, divide by `10^(6 - currency_exponent)`, which is 10,000 for USD, and truncate toward zero): `gross_minor: 1334` with `currency: "USD"` is 13.34 USD. `currency_exponent` is the number of decimal digits of the minor unit (2 for USD, 0 for JPY). `payable_minor` is the share plus the amount carried in, truncated to whole minor units; it can differ by one minor unit from adding the rounded parts. `state` is `invoiced`, `held`, `paid` or `rolled_over`. For a printable or downloadable invoice, use **Download PDF** on the statement page in the console: it is the same document, generated for you, with a watermark when the statement comes from the sandbox payout provider. `paid_minor` and `held_back_minor` are set once `state` is `paid`: the amount actually sent to you and the part the new-studio holdback kept back (`0` when none applied), from the payment record; both are `null` before payment and when the amount cannot be read exactly. `payable_minor` keeps its meaning. After a Stripe transfer is reversed in full both become `null`; after a partial reversal `paid_minor` stays the amount sent. An accepted Circle payment that arrived over or under is stated as it arrived, so `paid_minor + held_back_minor` can differ from `payable_minor`.

## Daily stats, paginated

`GET /api/v1/games/{id}/stats/daily?from=YYYY-MM-DD&to=YYYY-MM-DD&limit=&cursor=` (scope `stats:read`). The same daily numbers as `by_day` above, one row per UTC day, **oldest first**, read page by page. Use it when you pull long histories: the range may be up to **366 days** (the report above is limited to 92). `from` and `to` follow the same rules (`to` defaults to today, `from` to 29 days before `to`, no future days). `meta.range` echoes the range that was applied. A game of another studio answers `404 not_found`.

```bash
curl -H "Authorization: Bearer zst_your_token" \
  "https://www.zokogames.com/api/v1/games/5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d/stats/daily?from=2026-11-17&to=2026-11-18&limit=25"
```

Sample response (`DailyStatsList`, generated from the test fixture):

```json
{
  "data": [
    {
      "day": "2026-11-17",
      "impressions": 40,
      "views": 16,
      "players": 5,
      "gameplays": 11,
      "playtime_sec": 1800,
      "avg_playtime_sec": 164,
      "ctr": 0.4,
      "conversion": 0.1,
      "d1_retention": 0.2,
      "orders": 2
    },
    {
      "day": "2026-11-18",
      "impressions": 80,
      "views": 32,
      "players": 10,
      "gameplays": 22,
      "playtime_sec": 3600,
      "avg_playtime_sec": 164,
      "ctr": 0.4,
      "conversion": 0.1,
      "d1_retention": 0.2,
      "orders": 4
    }
  ],
  "next_cursor": null,
  "meta": {
    "limit": 25,
    "count": 2,
    "has_more": false,
    "game_id": "5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d",
    "range": {
      "from": "2026-11-17",
      "to": "2026-11-18"
    }
  }
}
```

## Builds

`GET /api/v1/games/{id}/builds?limit=&cursor=` (scope `games:read`). Every build uploaded for one of your games, newest version first, the same list as the console's Builds tab. `active` is true for the live build, `pending_review` when an update submission for it is waiting for review. `validation` is the result of the upload checks (`ok` and a list of `issues`), or `null`. The machine-readable error codes (`issueDetails`) are returned only by the upload check itself; see [what the build check returns](https://docs.zokogames.com/requirements/build-validation#what-the-build-check-returns).

A build in this list has no address. To open one, use the console preview: for a build players are not being served (a draft, an update waiting for review, an older build) it adds a short-lived preview link (`zk_preview_token`, valid for 15 minutes), for signed-in members of your studio only. The console's own build list (`GET /api/developer/games/{id}/builds`, signed-in session, not an API token) keeps the same `url` field as before; for such a build that `url` now carries the preview link, and the answer is sent with `Cache-Control: private, no-store`. Do not store or share it: open it within 15 minutes.

```bash
curl -H "Authorization: Bearer zst_your_token" \
  "https://www.zokogames.com/api/v1/games/5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d/builds"
```

Sample response (`BuildList`, generated from the test fixture):

```json
{
  "data": [
    {
      "id": "e7f8a9b0-c1d2-4e3f-a4b5-c6d7e8f9a0b1",
      "version": 3,
      "active": true,
      "pending_review": false,
      "entry_file": "index.html",
      "file_count": 42,
      "total_bytes": 8388608,
      "release_notes": "New desert level.",
      "validation": {
        "ok": true,
        "issues": []
      },
      "created_at": "2026-11-02T16:40:00.000Z"
    }
  ],
  "next_cursor": null,
  "meta": {
    "limit": 25,
    "count": 1,
    "has_more": false,
    "game_id": "5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d"
  }
}
```

### Check a build from your pipeline

To upload from CI, see [Upload a build from CI](#upload-a-build-from-ci). After an upload, a pipeline can wait for what happens next with this script, which reads the newest build of a game and waits until it is live. It needs `curl` and `jq`, and a token with the `games:read` scope kept as a secret in your CI system.

```bash
#!/usr/bin/env bash
# usage: ZOKO_TOKEN=zst_... ./check-build.sh <game id> <expected build number>
set -euo pipefail
game="$1"; want="$2"
url="https://www.zokogames.com/api/v1/games/$game/builds?limit=1"
for i in $(seq 1 30); do
  body=$(curl -fsS -H "Authorization: Bearer $ZOKO_TOKEN" "$url")
  build=$(jq -c '.data[0] // empty' <<<"$body")
  if [ -n "$build" ] && [ "$(jq .version <<<"$build")" -ge "$want" ]; then
    if [ "$(jq .validation.ok <<<"$build")" = "false" ]; then
      echo "Build $want failed its checks:"; jq -r '.validation.issues[]' <<<"$build"; exit 1
    fi
    if [ "$(jq .active <<<"$build")" = "true" ]; then echo "Build $want is live."; exit 0; fi
    if [ "$(jq .pending_review <<<"$build")" = "true" ]; then echo "Build $want is waiting for review."; exit 3; fi
  fi
  sleep 10
done
if [ "$(jq .validation.ok <<<"${build:-null}")" = "true" ]; then
  echo "Build $want passed its checks but is not live: press Activate or Send for review in the console."
else
  echo "Build $want is not live yet."
fi
exit 2
```

`curl -f` makes a `4xx` or `5xx` fail the step but hides the error body (with its `code` and `requestId`); drop `-f` and print the body while you are setting this up. Exit codes: `0` live, `1` failed the upload checks, `2` not live within five minutes (the message says when the build passed its checks and is only waiting for someone to press **Activate** or **Send for review**, which a build of a live game always needs), `3` uploaded but waiting for review. A `429` means the token's minute is spent; this script makes at most 30 requests in five minutes, far below the default 300 a minute. To react to a build without polling, subscribe to the `build.activated` [webhook](https://docs.zokogames.com/guides/webhooks) instead.

## Upload a build from CI

A token with the `builds:write` scope can upload a build the way the console does, without a browser. The API only **creates and checks** the build: the same upload checks, the same size and file-count limits ([limits](https://docs.zokogames.com/requirements/build-validation#limits)) and the same zip checks as the console. It cannot activate a build, send a game for review, publish, roll back or delete anything. **A build uploaded with a token always lands inactive**, even for a game that is not live yet (the console makes a new valid build active automatically before launch; the API does not). Open the game's **Builds and updates** page, look at the build, and press **Activate** (or **Send for review** for a live game) yourself.

Set it up once:

1. Create a token on the **API tokens** page with **only** the `builds:write` scope (least privilege: a CI token should not read stats or statements). Creating it asks you to confirm with a passkey or authenticator app, like any token. Only an owner or admin can create it, and the token stops working if that person leaves the studio or is no longer an owner or admin.
2. Store the token as a **secret** of your CI system (for example `ZOKO_TOKEN`), never in the repository or in a build log. Treat it like a password and **rotate** it: create a new token, update the secret, then revoke the old one. Give it an expiry (the console offers 30, 90 or 365 days).
3. Find your game's id (the last part of its address in the console, or `GET /api/v1/games`).

The upload has three steps, for a zip of any size. A game of another studio answers `404 not_found`, the same as a game that does not exist.

**1. Start.** Send the zip's size in bytes. The answer is where to send the file.

```bash
curl -X POST "https://www.zokogames.com/api/v1/games/5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d/builds/uploads" \
  -H "Authorization: Bearer $ZOKO_TOKEN" -H "Content-Type: application/json" \
  -d "{\"size\": $(wc -c < game.zip | tr -d ' ')}"
```

```json
{
  "uploadId": "8d2f1c64-9b7e-4a30-8f55-3c1e6a0b9d72",
  "multipart": false,
  "put": {
    "url": "https://storage.example/upload?signature=...",
    "headers": { "Content-Type": "application/zip" },
    "expiresAt": 1790000000000
  }
}
```

**2. Send the file** straight to storage with the headers the answer gives (it does not pass through this API, and it needs no token):

```bash
curl -X PUT -H "Content-Type: application/zip" --data-binary @game.zip "<put.url>"
```

A zip over 50 MB answers `"multipart": true` with `multipartId`, `partSize` and `partCount`. Cut the file into `partSize` pieces (the last one is smaller). For each part, `POST /api/v1/games/{id}/builds/uploads/{uploadId}/parts` with `{ "multipartId", "partNumber", "contentLength" }` returns a fresh `PUT` URL (call it again to retry a part), and the storage answer to each `PUT` carries an `ETag` header to keep.

**3. Confirm and read the report.** `POST /api/v1/games/{id}/builds/uploads/{uploadId}/confirm` finishes a multipart upload (send `{ "multipartId", "parts": [{ "partNumber", "etag" }] }`; a single upload needs no such fields), runs the build check and stores the build. Optional `releaseNotes` (basic Markdown, sanitised like the console's) appear in the build history. It answers `200` **whether the build passes or not**: read `ok`.

```bash
curl -X POST "https://www.zokogames.com/api/v1/games/5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d/builds/uploads/8d2f1c64-9b7e-4a30-8f55-3c1e6a0b9d72/confirm" \
  -H "Authorization: Bearer $ZOKO_TOKEN" -H "Content-Type: application/json" \
  -d '{"releaseNotes": "Build from CI."}'
```

The answer is the console's confirm answer (see [what the build check returns](https://docs.zokogames.com/requirements/build-validation#what-the-build-check-returns)) plus `findings`, one entry per finding with the stable `code`, `severity` (`error`, `warn`, `info`), a `message`, a `hint` that says how to fix it, the `path` and `line` when known, and a `docs` link: the same codes and fix hints as the console's report. `activated` is always `false` and `next` is `activate`.

```json
{
  "ok": false,
  "buildId": null,
  "version": null,
  "activated": false,
  "validation": { "ok": false, "issues": ["index.html must be at the root of the zip"] },
  "findings": [
    {
      "code": "no_index",
      "severity": "error",
      "message": "index.html must be at the root of the zip.",
      "hint": "Zip the contents of your export folder, not the folder itself.",
      "path": null,
      "line": null,
      "count": null,
      "paths": null,
      "docs": "https://www.zokogames.com/docs/requirements/build-validation#code-no-index"
    }
  ]
}
```

**If the confirm answer is lost** (a timeout in CI), do not start again: `GET /api/v1/games/{id}/builds/uploads/{uploadId}` answers `state` (`presigned`, `uploaded`, `processing`, `processed` or `failed`), and for a refused build the stored `validation` and `findings`. When it says `processed`, the build exists: read it with `GET /api/v1/games/{id}/builds` (scope `games:read`) or on the **Builds and updates** page. Only uploads made by the token's creator for that game are visible.

A plain shell script for any CI job. Keep `ZOKO_TOKEN` in the CI system's secret store and pass it to the job as an environment variable, with `ZOKO_GAME_ID` next to it. Never add `set -x` or `curl -v`: they print request headers, and with them your token, into the job log. Needs `curl` and `jq`:

```bash
#!/usr/bin/env bash
# usage: ZOKO_TOKEN=zst_... ZOKO_GAME_ID=... ./zoko-upload.sh game.zip   (single upload, zips up to 50 MB)
# Never add `set -x` or `curl -v`: the token would be printed to the job log.
set -euo pipefail
API="https://www.zokogames.com/api/v1/games/$ZOKO_GAME_ID/builds/uploads"
AUTH="Authorization: Bearer $ZOKO_TOKEN"
size=$(wc -c < "$1" | tr -d ' ')
start=$(curl -sS -X POST "$API" -H "$AUTH" -H "Content-Type: application/json" -d "{\"size\": $size}")
id=$(jq -er .uploadId <<<"$start") || { echo "$start"; exit 1; }
[ "$(jq .multipart <<<"$start")" = "false" ] || { echo "Over 50 MB: use the multipart steps"; exit 1; }
curl -fsS -X PUT -H "Content-Type: application/zip" --data-binary @"$1" "$(jq -r .put.url <<<"$start")"
done=$(curl -sS -X POST "$API/$id/confirm" -H "$AUTH" -H "Content-Type: application/json" -d '{}')
if [ "$(jq .ok <<<"$done")" != "true" ]; then
  echo "Build rejected:"; jq -r '.findings[]? | "[\(.severity)] \(.code): \(.message) \(.hint // "")"' <<<"$done"
  jq -r '.error.message? // empty' <<<"$done"; exit 1
fi
echo "Build $(jq .version <<<"$done") uploaded. It is inactive: activate it in the console."
```

Limits, on top of the token's per-minute limit: each token may make 10 start calls, 300 part calls, 10 confirm calls and 240 status calls an hour, and the whole studio 20, 600, 20 and 480. Beyond that you get `429 rate_limited` with a `Retry-After` of the real wait. Uploads started with a token also have their own daily bucket, apart from the console's: at most 10 unfinished uploads per token and 20 per studio in 24 hours (`429 daily_upload_limit`), which never use up, and are never limited by, any person's console uploads. A game keeps at most 10 builds made by tokens that are not active; past that, starting another is refused with `409 too_many_inactive_builds` until you delete old inactive builds on the game's **Builds and updates** page.

Every build stored this way is written to the studio's audit trail with the token's id and name (not a person), and so is a rejected one. Each uploaded build also sends the studio's owners and admins a notice in the console that names the token, linking to the game's **Builds and updates** page: if nobody on your team did the upload, revoke the token at once. The `build.published` [webhook](https://docs.zokogames.com/guides/webhooks) carries `uploadedBy` with the token's id and name, and the build is not live.

The upload calls never answer from a cache, and the `PUT` URLs they return are valid for a short time only (about 15 minutes): start the upload right before sending the file.

## Feedback

`GET /api/v1/games/{id}/feedback?resolved=all&limit=&cursor=` (scope `games:read`). Player feedback for one of your games, newest first. `resolved` is `false` (open items, like the console inbox), `true` or `all` (default). `reply_count` is how many replies the studio has sent. Player email addresses, account ids and the technical context are never part of this endpoint; answer players from the console.

```bash
curl -H "Authorization: Bearer zst_your_token" \
  "https://www.zokogames.com/api/v1/games/5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d/feedback?resolved=false"
```

Sample response (`FeedbackList`, generated from the test fixture):

```json
{
  "data": [
    {
      "id": "b4c5d6e7-f8a9-4b0c-91d2-e3f4a5b6c7d8",
      "game_id": "5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d",
      "subject": "Bug report",
      "message": "The jump button stops responding after level 3.",
      "resolved": false,
      "reply_count": 1,
      "created_at": "2026-11-02T16:40:00.000Z"
    }
  ],
  "next_cursor": null,
  "meta": {
    "limit": 25,
    "count": 1,
    "has_more": false,
    "game_id": "5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d"
  }
}
```

## Leaderboards

`GET /api/v1/leaderboards?limit=&cursor=` (scope `games:read`). The settings of every leaderboard in your studio, ordered by game id, with the number of scores in the running season (`season`, `season_entries`) and across all seasons (`all_entries`). `has_api_key` says whether a server API key exists; the key and the encryption key are never returned. Scores of individual players are not part of the API.

```bash
curl -H "Authorization: Bearer zst_your_token" "https://www.zokogames.com/api/v1/leaderboards"
```

Sample response (`LeaderboardList`, generated from the test fixture):

```json
{
  "data": [
    {
      "game_id": "5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d",
      "game_slug": "sky-runner",
      "enabled": true,
      "score_label": "POINTS",
      "sorting": "DESC",
      "min_value": 0,
      "max_value": 999999999,
      "cooldown_seconds": 0,
      "is_incremental": false,
      "has_api_key": true,
      "season": "2026-W47",
      "season_entries": 214,
      "all_entries": 1893
    }
  ],
  "next_cursor": null,
  "meta": {
    "limit": 25,
    "count": 1,
    "has_more": false
  }
}
```

## Statement lines

`GET /api/v1/statements/{id}/lines?limit=&cursor=` (scope `statements:read`). The line items of one cut statement, as snapshotted when the month closed, in statement order. `{id}` is the `id` from the statements list; a statement of another studio, or one still open, answers `404 not_found`. Each line is one game and one `source` (`ads`, or `store` for real-money in-game store revenue, which has its own share rate). Amounts are minor units in `meta.currency`, with `meta.currency_exponent`; `share_percent` is the studio's rate on the line. `game_id` is `null` on the single summary line of statements cut before per-game lines existed.

```bash
curl -H "Authorization: Bearer zst_your_token" \
  "https://www.zokogames.com/api/v1/statements/9a1f4c2e-6b3d-4e8a-b5c7-0d2e1f3a4b6c/lines"
```

Sample response (`StatementLineList`, generated from the test fixture):

```json
{
  "data": [
    {
      "game_id": "5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d",
      "game_name": "Sky Runner",
      "source": "ads",
      "gross_minor": 1200,
      "ivt_minor": 20,
      "net_gross_minor": 1180,
      "share_percent": 50,
      "share_minor": 590
    },
    {
      "game_id": "5b0c7d3e-8a41-4f6b-9c2d-1e7f0a3b4c5d",
      "game_name": "Sky Runner",
      "source": "store",
      "gross_minor": 134,
      "ivt_minor": 0,
      "net_gross_minor": 134,
      "share_percent": 70,
      "share_minor": 93
    }
  ],
  "next_cursor": null,
  "meta": {
    "limit": 25,
    "count": 2,
    "has_more": false,
    "statement_id": "9a1f4c2e-6b3d-4e8a-b5c7-0d2e1f3a4b6c",
    "period": "2026-10",
    "currency": "USD",
    "currency_exponent": 2
  }
}
```

## Game settings

Game settings are changed from the console, which uses `PATCH /api/developer/games/{id}` with a session (not a token). The body is strict: unknown fields are rejected. These fields matter here:

- **`allowedOrigins`**: a list of up to 10 sites that may embed the game, validated and normalised as described in [Restrict which sites may embed](https://docs.zokogames.com/requirements/embedding#restrict-which-sites-may-embed-allowed-sites). Invalid input is a `400` that names the entry. `[]` removes the restriction.
- **`desktopEnabled`, `phoneEnabled`, `tabletEnabled`** (booleans, all `true` by default): turn a device class off to tell players on it that the game is not available there. At least one must stay on.
- **`chromebookEnabled`, `androidEnabled`, `iosEnabled`** (booleans, all `true` by default): the per-platform switches (Chromebook, Android, iPhone and iPad). A player on a switched-off platform sees the same "not available on this device" message on the game page and in embeds. They are returned by the read API as `devices.chromebook`, `devices.android` and `devices.ios`, next to `devices.desktop`, `devices.phone` and `devices.tablet`.
- **`hosting`** (`"hosted"` or `"external"`) and **`externalUrl`**: a game hosted on your own server is framed from `externalUrl`. The address must be `https`, at most 500 characters, a public host name, and carry no username or password. Addresses on the portal itself are refused (the site, the docs, blog and other section hosts, the SDK and image hosts; only a hosted-build address `g-<slug>.zokogames.com` is allowed), and so are `localhost`, IP numbers and internal names. Your server must allow being embedded in a frame from zokogames.com.

Staff can set the same fields from the admin editor.

## Next steps

- [Webhooks](https://docs.zokogames.com/guides/webhooks)
- [Analytics and metrics reference](https://docs.zokogames.com/guides/analytics-metrics)
