Creating Leaderboards
This guide teaches you how to provision, update, and retire leaderboards via the Admin Gateway.
It assumes you already understand the configuration model from Leaderboards Overview.
1. Authentication Recap
Admin endpoints require API Key authentication (HMAC is supported for tenant-scoped operations but API keys are recommended). Include either of the following headers:
X-API-Key: <ADMIN_API_KEY>or
Authorization: Bearer <ADMIN_API_KEY>For tenant-aware routes (/tenants/{tenant_id}/...), the API key must have access to that tenant. Phoenix returns 403 if the scopes or tenant permissions are insufficient.
2. List Existing Leaderboards
Endpoint
GET /leaderboardsResponse
{
"total": 2,
"leaderboards": [
{
"leaderboard_id": "xp-weekly-global",
"tenant_id": "tenant-prod-001",
"name": "Global Weekly XP",
"description": "Weekly XP race across all regions",
"status": "active",
"version": 3,
"config": { "...": "..." },
"created_at": "2025-08-01T12:00:00Z",
"updated_at": "2025-11-18T09:15:42Z"
}
]
}Use /tenants/{tenant_id}/leaderboards to filter by tenant when using API keys scoped to a specific partner.
3. Create a Leaderboard
Endpoint
POST /tenants/{tenant_id}/leaderboardsRequest Body
{
"leaderboard_id": "xp-weekly-global",
"tenant_id": "tenant-prod-001",
"name": "Global Weekly XP",
"description": "Weekly XP race across all regions",
"config": {
"scope": {
"filters": {
"actor.metadata.region": { "in": ["na", "eu"] }
}
},
"timeframe": {
"type": "weekly",
"timezone": "UTC",
"reset_day": "monday",
"reset_time": "00:00"
},
"scoring": {
"rules": [
{
"event_type": "match.completed",
"points_expression": "attrs.score",
"conditions": {
"attrs.victory": { "eq": true }
}
}
],
"aggregation": "sum"
},
"ranking": {
"method": "score_desc",
"size": 1000,
"min_score": 0
}
}
}Validation highlights
leaderboard_idmust be alphanumeric with hyphens/underscores.tenant_idin the body must match the URL path.- Config is validated server-side using the same rules documented in
leaderboard-overview.md. Errors return400with descriptive messages (e.g., “reset_day is required when type is 'weekly'”).
cURL example
curl -X POST \
"$ADMIN_BASE_URL/tenants/$TENANT_ID/leaderboards" \
-H "Content-Type: application/json" \
-H "X-API-Key: $ADMIN_API_KEY" \
-d @leaderboard.jsonIf successful, Phoenix returns the persisted record plus timestamps/version.
4. Retrieve a Single Leaderboard
GET /tenants/{tenant_id}/leaderboards/{leaderboard_id}This returns the full record (same shape as creation response). Use it to confirm deployed configs or to seed your admin UI.
5. Update Metadata or Status
PATCH /tenants/{tenant_id}/leaderboards/{leaderboard_id}
Content-Type: application/jsonBody supports:
{
"name": "Updated Display Name",
"description": "New marketing copy",
"status": "inactive"
}statusacceptsactive,inactive, orarchived.- Phoenix automatically increments the
versionandupdated_atfields. - Config changes (scope/timeframe/scoring/ranking) require a new leaderboard today; we recommend cloning the existing config, editing, and recreating if you need structural changes. (Config mutability is on the roadmap; contact support for guidance.)
6. Delete a Leaderboard
DELETE /tenants/{tenant_id}/leaderboards/{leaderboard_id}Deletes the configuration and returns the removed record. Existing historical data remains accessible via Query Gateway snapshots.
Use deletion sparingly; inactive/archived statuses are usually sufficient to hide leaderboards from players while preserving admin history.
7. Error Reference
| Status | Code | When it occurs |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid JSON, mismatched tenant IDs, config validation failures. |
| 401 | UNAUTHORIZED | Missing or malformed API key headers. |
| 403 | FORBIDDEN | API key lacks leaderboards:write scope or cannot access the specified tenant. |
| 404 | NOT_FOUND | Requested leaderboard or tenant does not exist. |
| 409 | CONFLICT | Duplicate leaderboard_id for the same tenant. |
| 500 | INTERNAL_ERROR | Unexpected server issue; retry or contact Phoenix support if it persists. |
Responses follow the standard error envelope:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "leaderboard_id can only contain alphanumeric characters, hyphens, and underscores",
"status": 400
}
}8. Tips Before Going Live
- Keep
leaderboard_idslugs stable; they are referenced by ingestion and query clients. - Store configs in source control so you can track changes outside Phoenix.
- Exercise new configs in a staging tenant (short timeframes) before promoting to production.
- Coordinate status changes (
active↔inactive) with your live ops calendar so players know what to expect.
Next up: Real-time Updates, which covers WebSocket subscriptions, pagination, and filter strategies for displaying live leaderboards to players.
Leaderboard Overview
This guide explains how Phoenix leaderboards are modeled so you can design meaningful competitions before touching the Admin API. It focuses on the configuration shape you submit when creating or updating a leaderboard.
Real-time Updates
Phoenix offers a managed WebSocket channel for live leaderboard streams. Use it when you need immediate score changes in your game client, spectator dashboard, or broadcast overlays.