Leaderboards
Leaderboard definitions (metric, period, max entries) + admin-side ranked entries.
Leaderboards are named rankings of users by a metric (xp, streak, custom, high_score). A high_score board ranks scores your server submits through POST …/scores; see Score leaderboards. Entries are written automatically by the engagement pipeline; ranking and tiebreaker logic is shared with the segment-rule and gamification engines.
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /admin/projects/:projectId/leaderboards | Create a leaderboard. |
| GET | /admin/projects/:projectId/leaderboards | List leaderboards. |
| GET | /admin/projects/:projectId/leaderboards/:leaderboardId | Fetch. |
| PATCH | /admin/projects/:projectId/leaderboards/:leaderboardId | Partial update. |
| DELETE | /admin/projects/:projectId/leaderboards/:leaderboardId | Delete. |
| GET | /admin/projects/:projectId/leaderboards/:leaderboardId/entries | Paginated ranked entries with user display info. |
| POST | /admin/projects/:projectId/leaderboards/:leaderboardId/scores | Submit a score to a high_score board. |
POST /admin/projects/:projectId/leaderboards
Request
| Field | Type | Required | Default |
|---|---|---|---|
name | string | yes | — |
metric | string | yes | — |
period | string | no | "all_time" |
max_entries | number | no | 100 |
custom_event | string | no | null |
sort | string | no | "desc" |
keyed | bool | no | false |
metric is one of xp, streak, custom, high_score. period is one of all_time, daily, weekly, monthly (UTC windows; weeks open on Sunday). sort (desc ranks the highest score first, asc the lowest) and keyed (rank per key) apply to high_score boards only.
Errors
400 VALIDATION_ERROR: a missingnameormetric, or an unknown value.409 LEADERBOARD_EXISTS: the name is taken.
Response 201
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/leaderboardscurl -X POST 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/leaderboards' \
-H 'Content-Type: application/json' \
-d '{
"name": "Weekly XP",
"metric": "xp"
}'Curl:
GET /admin/projects/:projectId/leaderboards
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/leaderboardscurl -X GET 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/leaderboards'Curl:
GET /admin/projects/:projectId/leaderboards/:leaderboardId
Errors
404 NOT_FOUND.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7Dcurl -X GET 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7D'Curl:
PATCH /admin/projects/:projectId/leaderboards/:leaderboardId
Allowed fields: name, metric, period, max_entries, custom_event, is_active, sort, keyed.
Once a high_score board holds scores, its metric, period, sort and keyed are fixed, because stored bests were recorded under them. Changing one answers 409 SCORE_SETTINGS_LOCKED; create a new leaderboard instead.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7Dcurl -X PATCH 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7D'Curl:
DELETE /admin/projects/:projectId/leaderboards/:leaderboardId
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7Dcurl -X DELETE 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7D'Curl:
GET /admin/projects/:projectId/leaderboards/:leaderboardId/entries
Paginated entries ordered by rank ascending (entries without a rank sort last). Each row carries the user's display_name and avatar_url.
Query
| Param | Default |
|---|---|
limit | 50 |
offset | 0 |
key | — |
period_start | current window |
:leaderboardId accepts the id or the name. key and period_start apply to high_score boards: key picks the board on a keyed definition, and period_start (YYYY-MM-DD, any UTC date inside the window) picks a past window. A score board returns { rank, app_user_id, display_name, avatar_url, score, achieved_at } rows plus key, period and period_start (null on all-time boards).
Response 200
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7D/entriescurl -X GET 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/leaderboards/%7B%7BleaderboardId%7D%7D/entries'Curl:
POST /admin/projects/:projectId/leaderboards/:leaderboardId/scores
Submit a player's score to a high_score board. Call it from trusted server code with a server key or developer token. The board keeps the player's best score for the current UTC window (per key on a keyed board). The write is atomic: when two submits for the same player race, the better score wins. :leaderboardId accepts the id or the name.
Request
| Field | Type | Required |
|---|---|---|
app_user_id | string | yes |
score | number | yes |
key | string | on keyed boards only |
idempotency_key | string | no |
Response 200
rank counts from 1. A tie goes to whoever reached the score first. A repeat with the same idempotency_key returns the first submit's new_personal_best with replayed: true.
Errors
400 VALIDATION_ERROR: badapp_user_idorscore, a missingkeyon a keyed board, or akeyon an unkeyed board.400 NOT_A_SCORE_LEADERBOARD: the board ranks another metric.404 NOT_FOUND/404 USER_NOT_FOUND.409 IDEMPOTENCY_KEY_REUSED: the key was used for a different user, board key or score.409 LEADERBOARD_INACTIVE.
Curl: