# Leaderboards

**Purpose:** this page explains how players are ranked each week and how your game or your server submits scores. Leaderboards are enabled per game in the developer console. Players are ranked inside a weekly season, and the best of each season earns trophies on their profile.

## Concepts

Configure these in the console, on your game's **Leaderboard** tab.

| Setting | Meaning |
| --- | --- |
| Score label | How scores are described to players: `XP`, `KDA`, `POINTS` (shown as Points) or `MINUTES` (shown as Minutes). |
| Sorting | `DESC` (bigger is better) or `ASC` (smaller is better, for times). |
| Min and max value | Scores outside the range are rejected. Default 0 to 999,999,999; the console accepts any value from -1,000,000,000,000 to 1,000,000,000,000, and the minimum may not exceed the maximum. On an incremental board the range applies to each submitted amount, not to the running total. |
| Cooldown | Minimum seconds between submissions from the same player (counted from their last update), from `0` (none) to `86400`. Enforced atomically, so parallel submissions cannot slip past it. A score sent inside the cooldown is dropped, not queued: your game sends it again after the cooldown if it still wants it. |
| Incremental | When on, each submitted score is **added** to the player's season total, and must be greater than zero. When off, the player keeps their better score for the season; a worse score is accepted but changes nothing. |
| Player guide | Free text (up to 600 characters) shown with the board that explains how to score. |
| Encryption key | A 32-byte key (base64) used to encrypt client submissions. Shown once when you generate or rotate it. |
| API key | For server submissions, starts with `zlb_`. Shown once; we store only a hash. |

A **season** is one ISO week (for example `2026-W47`). Seasons roll over on Monday at 09:00 UTC. When a season closes, ranks 1, 2 and 3 receive gold, silver and bronze trophies, and further top-1 %, top-5 % and top-10 % trophies are awarded once at least 10 players took part. Players with the same score share a rank.

Only signed-in players appear on a leaderboard. Guests cannot submit. Players choose who sees them on leaderboards in their account settings: everyone (`public`, the default), accepted friends only (`friends`), or nobody (`hidden`). A player who is not shown to a viewer is left out of that viewer's board, and the ranks of everyone else are counted without them, so there are no gaps. Scores are still recorded for a hidden player, and they always see their own row. The leaderboard responses the player-facing panel uses (`/api/sdk/leaderboard/<gameId>` and `/api/leaderboard/<gameId>`) carry `privacyDisabled: true` for a signed-in player who chose `hidden` (otherwise `false`), so your game can explain why they are not listed to others. The field is additive; ignore it if you do not need it.

**Changing the rules later.** Saving applies the new rules to the next submission only; scores already on the board are not rewritten. Flipping **Sorting** re-ranks the existing scores by the new rule, flipping **Incremental** changes how the next submissions combine with what is already stored, and a narrower min and max does not remove old scores. After changing sorting or incremental on a board that has scores, use **Reset scores** on the Leaderboard tab to start the week clean. **Reset this week** deletes the running week's scores, **Reset all weeks** deletes every week's; either way players lose those scores from the board and from their own best scores, trophies already awarded stay, and the studio's webhook `leaderboard.reset` fires. Turning **Leaderboard enabled** off hides the board and refuses new scores (`no_leaderboard`) but deletes nothing. **Rotating the encryption key** makes every shipped build that still has the old key drop its scores silently, for all players, until a build with the new key is live; a build update is reviewed before players get it, so rotate only when that build is ready.

A game made for children has no leaderboard: `submitScore` still resolves and records nothing (a `delayed` copy is not kept either), and the server API answers `403` with `kids-game`.

## Lifecycle

```text
run ends in the game
  -> user = await SDK.user.getUser()           null for a guest: skip the submission
  -> encryptedScore = encrypt(score, key, userId, gameId)
  -> await SDK.user.submitScore({ encryptedScore, score })
  -> portal checks the board rules -> accepted -> rank toast for the player
```

## Client submission

```ts
SDK.user.submitScore(options: { encryptedScore: string; score: number; delayed?: { encryptedScore: string; earnedAt: number } }): Promise<void>
```

`encryptedScore` proves the number came from your game: it is the score encrypted with your board's encryption key. When the board has a key, **only the encrypted value counts**; the plain `score` is ignored. Keys are opt-in: a new board has no key until you press **Generate** next to **Encryption key** on the game's **Leaderboard** tab. A board with no key accepts the plain `score` (and `encryptedScore` may be an empty string); that path is limited to 10 submissions a minute per player and can be forged by anyone with the browser's developer tools, so only the range, cooldown and rate limits protect it. Generate the key before you ship if the scores matter: on a game that is already live, the first key makes the board ignore the plain scores of the build players have now, for every player, until a build that encrypts with it is live (a build update is reviewed before players get it), so the console asks you to confirm before it makes one.

The scheme is AES-256-GCM, and the payload is bound to the player, the game and the moment it was made:

1. Build the plaintext `"<score>|<unix milliseconds now>"`, for example `"4210|1767225600000"`. The score may be negative or have up to 6 decimals, with at most 15 integer digits.
2. Generate a random 12-byte IV. It doubles as a one-time nonce, so use a fresh one for every submission.
3. Encrypt the UTF-8 bytes with the game's 32-byte key and the additional authenticated data `zoko-score-v1|<userId>|<gameId>`. The tag (16 bytes) is appended to the ciphertext.
   - `<userId>` is `getUser().__dangerousUserId`. It is the same value as the `userId` claim (and `sub`) of the player's [token](https://docs.zokogames.com/sdk/user#tokens): one UUID per account, identical in every game. It is not the opaque `userId` that the rankings endpoint returns.
   - `<gameId>` is your game's id: the UUID in your console address (`/developer/games/<id>`). It is set when the draft is created and stays the same after launch, and it is the `aud` and `gameId` claim of the tokens. From SDK 1.6.2 the game can read it as `SDK.game.gameId`; on earlier versions put it in your build as a constant (`GAME_ID` in the sample).
4. Send `base64(iv || ciphertext || tag)`.

In the sample below, `GAME_KEY` is the key the console showed once when you generated it (the console and the step-by-step guide call it `KEY`).

The portal rejects a payload made for another player or game, one older than 2 minutes (or from the future), and one it has already seen. Encrypt at the moment of submission; do not store or retry old payloads.

<!-- docs-sample: uses GAME_KEY, GAME_ID -->
```js
async function encryptScore(score, keyBase64, userId, gameId) {
  const raw = Uint8Array.from(atob(keyBase64), (c) => c.charCodeAt(0));
  const key = await crypto.subtle.importKey("raw", raw, "AES-GCM", false, ["encrypt"]);
  const iv = crypto.getRandomValues(new Uint8Array(12));
  const data = new TextEncoder().encode(`${score}|${Date.now()}`);
  const additionalData = new TextEncoder().encode(`zoko-score-v1|${userId}|${gameId}`);
  const sealed = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-GCM", iv, additionalData }, key, data));
  const out = new Uint8Array(iv.length + sealed.length);
  out.set(iv, 0);
  out.set(sealed, iv.length);
  return btoa(String.fromCharCode(...out));
}

async function finishRun(score) {
  const user = await SDK.user.getUser();
  if (!user) return;
  const encryptedScore = await encryptScore(score, GAME_KEY, user.__dangerousUserId, GAME_ID);
  await SDK.user.submitScore({ encryptedScore, score });
}
```

> [!WARNING]
> Anti-cheat, honestly: every score a browser sends can be forged. Anything shipped in the browser can be read by a determined player, including the key, and a board without a key accepts the plain number outright. The encryption, the min and max range, the cooldown and the rate limits stop casual tampering, not a motivated cheater. If your game has real competitive stakes, calculate the score on your own server and submit it with the API key through the [server API](#server-api) below; that is the only path the portal can treat as trustworthy. Scores are accepted only for games that are live; a game in review or preview records nothing.

`submitScore` rejects with `invalidArgument` when `options` is not an object, `encryptedScore` is not a string, or `score` is not a finite number. Otherwise it resolves with nothing; `rateLimited` is the only portal error. It also throws `sdkNotInitialized` or `sdkDisabled` as described in [errors](https://docs.zokogames.com/sdk/introduction#errors). `delayed` is optional and never makes the call reject: a malformed one is dropped by the portal and the normal score still goes through, and neither the SDK nor local mode checks `earnedAt` or the token. See [Offline scores](#offline-scores).

To test the encryption without a live player, use local mode (it validates the call and records nothing) and decrypt your own payload in a unit test with the same key, IV and additional data; for a real accepted score, play a build in basic launch signed in with an account of your studio and look under **Entries this week** on the Leaderboard tab.

A submission that cannot be read (wrong key, malformed payload) or that breaks a board rule (range, cooldown) is dropped by the portal without telling the game why, so a cheater learns nothing; the call itself still resolves. A player who is not signed in does not get an error either: the call resolves without recording anything, and when the score would reach the top 10 of the current week's board the portal invites the player to sign in, at most once per game per page view; a run that does not place does not use up that invitation. Submissions are limited to 30 per minute per player and game; beyond that the call rejects with `rateLimited`. When a score is accepted the portal shows the player's rank.

**When `submitScore` rejects with `rateLimited`.** This is the one refusal the game is told about. The portal refused the call before it read the score, so nothing was recorded and the payload was not used up. The run is still yours to send. The retry rule:

1. **Keep the run, not the payload.** A payload older than 2 minutes is refused, so encrypt the kept score again for every attempt, with a fresh IV and the current time.
2. **Wait about a minute before the first retry.** The limit counts the last 60 seconds (10 without an encryption key). Then back off, for example 60, 120 and 240 seconds, and give up after about 5 attempts or when the player leaves. Never retry in a loop.
3. **Send one score for the backlog, not every run that piled up.** On a highest-first board keep the best run, on a lowest-first (`ASC`) board the lowest, on an incremental board add the amounts into one submission (it must stay within the max).
4. **A weekly score is not back-dated.** A retry that goes through after Monday 09:00 UTC counts for the new week, not for the week the run was played in.
5. **Retry only `rateLimited`.** Every other outcome resolves normally and the game is not told whether it counted. A score dropped by the cooldown can be sent again after the cooldown; one outside the min and max is never accepted, so do not resend it.

On the server API the same refusal is HTTP `429` `rate-limited` with a `Retry-After` header: wait that many seconds and resend the same body, since nothing in it was recorded.

### Offline scores {#offline-scores}

A run that ends while the player is offline cannot reach the board. Pass `delayed` next to the normal score to keep it:

```text
delayed?: { encryptedScore: string; earnedAt: number }
```

Offline, the score is not lost if you also pass `delayed`: a copy sealed at the end of the run with `earnedAt = Date.now()`, additional data `zoko-score-v3|<userId>|<gameId>|<earnedAt>` and plaintext `<score>|<earnedAt>`. The portal keeps it on the device for a signed-in player (keyed boards only, never in kids mode) and sends it when they are back online, within 72 hours. It counts for the all-time board only, not the weekly board. Without `delayed`, or on a portal older than SDK 1.6.4, an offline score is not queued.

- `earnedAt` is the moment the run ended, in Unix milliseconds (13 digits). Use the same number in the additional data, in the plaintext and in the field.
- `encryptedScore` inside `delayed` is the sealed copy as text, at most 256 characters. Seal it like the normal payload (AES-256-GCM, a fresh 12-byte IV, `base64(iv || ciphertext || tag)`); only the additional data and the plaintext differ.
- Nothing changes for the normal `encryptedScore`: send it as before. `delayed` is an extra field, and there is no new call.
- A malformed `delayed` is dropped by the portal, and the normal score still goes through. Neither the SDK nor local mode validates `earnedAt` or the token, so a wrong value is silent.
- Nothing is kept for a guest, on a board without an encryption key or in kids mode. A portal older than SDK 1.6.4 ignores `delayed`.

<!-- docs-sample: uses GAME_KEY, GAME_ID, encryptScore -->
```js
async function encryptDelayedScore(score, keyBase64, userId, gameId, earnedAt) {
  const raw = Uint8Array.from(atob(keyBase64), (c) => c.charCodeAt(0));
  const key = await crypto.subtle.importKey("raw", raw, "AES-GCM", false, ["encrypt"]);
  const iv = crypto.getRandomValues(new Uint8Array(12));
  const data = new TextEncoder().encode(`${score}|${earnedAt}`);
  const additionalData = new TextEncoder().encode(`zoko-score-v3|${userId}|${gameId}|${earnedAt}`);
  const sealed = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-GCM", iv, additionalData }, key, data));
  const out = new Uint8Array(iv.length + sealed.length);
  out.set(iv, 0);
  out.set(sealed, iv.length);
  return btoa(String.fromCharCode(...out));
}

async function finishRun(score) {
  const user = await SDK.user.getUser();
  if (!user) return;
  const earnedAt = Date.now();
  const encryptedScore = await encryptScore(score, GAME_KEY, user.__dangerousUserId, GAME_ID);
  const delayed = {
    encryptedScore: await encryptDelayedScore(score, GAME_KEY, user.__dangerousUserId, GAME_ID, earnedAt),
    earnedAt,
  };
  await SDK.user.submitScore({ encryptedScore, score, delayed });
}
```

### In local mode, as a guest, offline or ad-free

| Situation | What `submitScore` does |
| --- | --- |
| Local mode | Validates its arguments, then resolves without recording anything and without a rank toast. Since SDK 1.6.3 every call also writes one console line (`Local mode: score <n> not sent (nothing is stored; real leaderboards run in the portal)`), so you can see the call happened. Offline (`?offline=true`), with a signed-in player and `delayed`, it shows "Score saved offline" (SDK 1.6.4). Test the encryption in your own code and the ranking in the [Preview tool](https://www.zokogames.com/preview). |
| Basic launch | Scores are recorded: a basic-launch game is live. Only a game that is not live yet (draft, in review, preview) records nothing. |
| Guest | Resolves without recording, and the score is not kept. When it would place in the top 10 of the current week's board, the portal invites the player to sign in, at most once per game per page view. Submit the score again after sign-in if it should count. |
| Offline | Resolves without recording. Offline, the score is not lost if you also pass `delayed`: a copy sealed at the end of the run with `earnedAt = Date.now()`, additional data `zoko-score-v3|<userId>|<gameId>|<earnedAt>` and plaintext `<score>|<earnedAt>`. The portal keeps it on the device for a signed-in player (keyed boards only, never in kids mode) and sends it when they are back online, within 72 hours. It counts for the all-time board only, not the weekly board. Without `delayed`, or on a portal older than SDK 1.6.4, an offline score is not queued. On a game with a leaderboard (never in kids mode), the offline notice over the game tells the player: **Scores are not saved while you're offline.** See [Offline scores](#offline-scores). |
| Ad blocker or ad-free member | No effect. |

**Common mistakes.** The ones QA and support see most often:

| Mistake | Result | Fix |
| --- | --- | --- |
| The score is encrypted at level load and sent later, or an old payload is retried | The portal drops it silently: it only accepts a payload under 2 minutes old that it has not seen | Encrypt at the moment of submission with a fresh IV. |
| `userId` in the encryption's additional data is not the player's id from `getUser()`, or `gameId` is wrong | The payload is dropped without an error | Use `zoko-score-v1\|<userId>\|<gameId>` with the values from `getUser().__dangerousUserId` and your game id. |
| The board has a key but `encryptedScore` is empty | The plain score is ignored and nothing is recorded | Always send the encrypted value for a board with a key. |
| A score is submitted after every action | `rateLimited` (30 a minute, 10 without a key) | Submit once per run. If it already happened, keep the best run and re-send it after about a minute, encrypted again (see the retry rule under Client submission). |
| The result of `submitScore` is read as "accepted" | It resolves even when the score was dropped, ignored or the player is a guest | Do not show "new high score" from the promise. Read the rankings endpoint to show the rank. |
| Guests are expected to appear on the board | Nothing is recorded; the portal may invite them to sign in | Ask the player to sign in, then submit again. |
| Scores that matter are only checked in the browser | Anyone can forge them | Calculate on your server and use the server API. |
| The ranking `userId` is used as an account id | It does not match any token | Use it as a list key only, and `isYou` to find the player's row. |
| Test scores are left on the live board | Fake rows in the ranking | Use **Reset scores** before launch. |
| `delayed` is sealed with the normal payload's data, or its `earnedAt` differs between the field, the additional data and the plaintext, or it is in seconds | The portal drops the copy without an error; the normal score still goes through, and the offline score is lost | Seal it with `zoko-score-v3\|<userId>\|<gameId>\|<earnedAt>` and the plaintext `<score>\|<earnedAt>`, with one `earnedAt` in milliseconds. |

## Server API

For authoritative scores. Authenticate with your API key and send up to 100 scores per request (a request body over 100 KB is refused). `userId` is the `userId` claim from a [verified token](https://docs.zokogames.com/sdk/user#tokens). Each key may make 1,000 requests per minute. A missing or unknown key spends a separate budget of 30 a minute per address and then answers `429`; a valid key from that address is still served. A very high total request rate from one address (far above the per-key limit) also answers `429` with `Retry-After`.

```http
POST https://www.zokogames.com/api/v1/leaderboard/scores
X-API-Key: <your game's api key>
Content-Type: application/json

{ "scores": [ { "userId": "0b9c2e1a-8f2c-4d7e-9a11-2f6f3c1d4b55", "score": 4210 }, { "userId": "5e1d77a0-1a77-4c0b-8b3e-9d2c6a7f1e08", "score": 3987 } ] }
```

Send the request from your server. Examples:

:::tabs
== Node.js
<!-- docs-sample: uses process, batch -->
```js
const res = await fetch("https://www.zokogames.com/api/v1/leaderboard/scores", {
  method: "POST",
  headers: { "x-api-key": process.env.ZOKO_LEADERBOARD_KEY, "content-type": "application/json" },
  body: JSON.stringify({ scores: batch }),
});
const { ok, results } = await res.json();
```
== Python
```python
import os, requests

res = requests.post(
    "https://www.zokogames.com/api/v1/leaderboard/scores",
    headers={"X-API-Key": os.environ["ZOKO_LEADERBOARD_KEY"]},
    json={"scores": [{"userId": user_id, "score": 4210}]},
    timeout=10,
)
data = res.json()
```
== Go
```go
body, _ := json.Marshal(map[string]any{
	"scores": []map[string]any{{"userId": userID, "score": 4210}},
})
req, _ := http.NewRequest("POST", "https://www.zokogames.com/api/v1/leaderboard/scores", bytes.NewReader(body))
req.Header.Set("X-API-Key", os.Getenv("ZOKO_LEADERBOARD_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
```
== C#
```csharp
using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Post, "https://www.zokogames.com/api/v1/leaderboard/scores");
req.Headers.Add("X-API-Key", Environment.GetEnvironmentVariable("ZOKO_LEADERBOARD_KEY"));
req.Content = JsonContent.Create(new { scores = new[] { new { userId, score = 4210 } } });
var resp = await http.SendAsync(req);
var json = await resp.Content.ReadAsStringAsync();
```
== curl
```bash
curl -X POST https://www.zokogames.com/api/v1/leaderboard/scores \
  -H "X-API-Key: $ZOKO_LEADERBOARD_KEY" -H "Content-Type: application/json" \
  -d '{"scores":[{"userId":"0b9c2e1a-8f2c-4d7e-9a11-2f6f3c1d4b55","score":4210}]}'
```
:::

Keep the API key on your server only. The same min, max, sorting, cooldown and incremental rules apply as for the client path. Each score is checked on its own, so one bad entry does not stop the others. The response has one result per submitted score, in order:

Unlike the client path, the server API does not check the game's status: while the board is enabled and the key is valid, scores are recorded even for a game that is still a draft or in review. Use **Reset scores** on the game's **Leaderboard** tab to clear test scores before launch.

```json
{
  "ok": true,
  "results": [
    { "index": 0, "userId": "0b9c2e1a-8f2c-4d7e-9a11-2f6f3c1d4b55", "ok": true, "score": 4210, "rank": 12 },
    { "index": 1, "userId": "5e1d77a0-1a77-4c0b-8b3e-9d2c6a7f1e08", "ok": false, "error": "validation" }
  ]
}
```

Per-score `error` values:

| Error | Meaning |
| --- | --- |
| `no-active-season` | The leaderboard is disabled for this game. |
| `user-not-found` | The `userId` is unknown or the player is banned. |
| `banned` | An administrator has barred this player from leaderboards. |
| `validation` | The entry is malformed, outside the min and max range, or inside the cooldown. |
| `internal-server-error` | Retry later. |

The whole request fails instead (with no per-score results and `{ "ok": false, "error": ... }`) in these cases:

| HTTP status | `error` |
| --- | --- |
| 400 | `invalid-body` (not `{ scores: [...] }`), `empty` |
| 401 | `invalid-api-key` (missing, unknown or revoked) |
| 403 | `kids-game` (the game is made for children and has no leaderboard), `developer-suspended` (the studio is suspended; its server keys are refused like its API tokens) |
| 405 | `method-not-allowed` (any method other than `POST` or `OPTIONS`; the `Allow` header lists them) |
| 404 | `leaderboard-not-found` |
| 413 | `too-many-items` (more than 100), `payload-too-large` |
| 429 | `rate-limited` (a `retry-after` header says when to retry). Requests with a missing or unknown key get the same answer once their address has sent 30 of them in the last minute; a valid key from that address is not affected. |

Each score item is `{ "userId": string, "score": number }`.

### Errors of the server API

Every failure body is `{ "ok": false, "error": "<code>", "message": "<what happened>", "hint": "<how to fix it>" }`. Branch on `error` and the HTTP status; `message` and `hint` are for humans and their wording may change. The same `message` and `hint` fields are on every failed per-score result. The codes are the two tables above; causes and fixes:

| `error` | Status | Cause | Fix |
| --- | --- | --- | --- |
| `invalid-api-key` | 401 | The `X-API-Key` header is missing, has a typo, or the key was rotated or revoked. | Copy the current server API key (starts with `zlb_`) from the game's Leaderboard tab; after a rotation the old one stops working at once. |
| `invalid-body` | 400 | The body is not JSON, or has no `scores` array. | Send `Content-Type: application/json` and `{ "scores": [ ... ] }`. |
| `empty` | 400 | `scores` has no items. | Do not send empty batches. |
| `too-many-items` | 413 | More than 100 scores. | Send batches of at most 100. |
| `payload-too-large` | 413 | Body over 100 KB. | Send smaller batches. |
| `leaderboard-not-found` | 404 | The key's game has no leaderboard row. | Enable the leaderboard and save the rules on the Leaderboard tab, then generate a new key. |
| `kids-game` | 403 | The game is made for children. | Do not submit; a kids game has no board. |
| `developer-suspended` | 403 | The studio is suspended. | Contact support through the console. |
| `rate-limited` | 429 | Over the per-key or per-address limit. | Wait for the `Retry-After` seconds, then retry; batch instead of sending one score per request. |
| `method-not-allowed` | 405 | Not a `POST`. | Use `POST`. |

Per-score errors: `no-active-season` (turn on **Leaderboard enabled** and save the rules), `user-not-found` (use the `userId` claim of a verified token, not a ranking `userId` or a name), `banned` (nothing to fix; do not retry), `validation` (send `{ userId, score }`, keep the score in the min and max range, wait out the cooldown, and on an incremental board send an amount above zero) and `internal-server-error` (retry that entry later).

> [!NOTE]
> Generate and rotate the encryption key and the server API key on the game's **Leaderboard** tab (or the **Leaderboard keys** page in the console's left menu). A new key is shown once, with a button that copies it as code; leaving the page before you press **I have saved it** loses it, and rotating is the way to get a new one. Generating, rotating or revoking a key asks for a second step: a passkey or an authenticator app on your player account. Without one the console changes nothing and says so, and you add one in your account's security settings first. Rotating the encryption key breaks any shipped build that still uses the old one, and revoking the server API key makes your server's requests fail with `401` at once.

## Reading rankings

Public rankings for a game are available without a key:

```http
GET https://www.zokogames.com/api/leaderboard/<gameId>?scope=global&limit=10&season=2026-W47
```

`scope` is `global`, `country` or `friends` (friends needs a signed-in session and answers 401 otherwise). `limit` is 1 to 100 (default 10) and `season` (format `YYYY-Www`) defaults to the current one. The answer includes the season, when it ends, the sorting, the entries (`rank`, `userId`, `username`, `avatarUrl`, `countryCode`, `score`, `isYou`), the total, and the signed-in viewer's own row (`me`) and nearest neighbours. The game must be live and have the leaderboard enabled. Errors use the body `{ "error": "<code>" }`: `404` `game_not_found` (no live game with that id), `404` `no_leaderboard` (the leaderboard is off), `400` `invalid_request` (a malformed game id, `scope`, `limit` or `season`) and `401` `unauthenticated` (`scope=friends` without a session). A game made for children answers `200` with no entries and an `unavailable` field.

### Errors of the rankings read

The status codes are as above; the body is `{ "error": "<code>", "message": "<what happened>", "hint": "<how to fix it>" }` (the `401` also carries the usual season fields).

| Status | `error` | Cause | Fix |
| --- | --- | --- | --- |
| 400 | `invalid_request` | The game id is not a valid id, or `scope`, `limit` or `season` is malformed. | Use the game's UUID, `scope` of `global`, `country` or `friends`, `limit` 1 to 100 and a season like `2026-W47`. |
| 404 | `game_not_found` | No live game has this id. A draft, a game in review or a mistyped id looks the same. | Use the id from `/developer/games/<id>` and read the board once the game is live. |
| 404 | `no_leaderboard` | The game is live but **Leaderboard enabled** is off. | Turn it on and save the rules on the Leaderboard tab. |
| 401 | `unauthenticated` | `scope=friends` without a signed-in session. | Use `global` or `country` from a server, or call from the player's browser with credentials. |

**Player ids in rankings.** In every ranking row (`entries`, `me` and `neighbours`), `userId` is an opaque id for that player in this game only: the same player always gets the same id in the same game, and a different id in every other game. It is not the player's account id (the `userId` in the [player token](https://docs.zokogames.com/sdk/user#tokens)), it cannot be turned back into one, and no other API accepts it, so use it only as a list key. To highlight the player's own row, use `isYou`: it is `true` on the signed-in caller's row and `false` on every other row, and always `false` for guests. Show `username` as the player's name. Never store the ranking `userId` as an account identifier or link accounts with it; use the `userId` from a verified token for that. `isYou` is part of the JSON response. The SDK has no leaderboard read call, so fetch the endpoint yourself; since SDK 1.5.0 its type declarations include `LeaderboardEntry`, a type only, which describes one row (`isYou` and this `userId` included).

## Design tips

- Submit once per run, at the end, not every frame.
- For time-based games use `ASC` with `MINUTES`.
- Show the player's own rank, not just the top ten.
- Do not make the leaderboard the only reason to play; the weekly reset is a feature for new players too.

## Next steps

- [Leaderboards step by step](https://docs.zokogames.com/guides/leaderboard-setup)
- [Achievements](https://docs.zokogames.com/sdk/achievements)
