Documentation Index
Fetch the complete documentation index at: https://teambattles.gg/docs/llms.txt
Use this file to discover all available pages before exploring further.
Interactive Endpoints
Try out the API directly from the docs:User Matches
Retrieve matches where you’re on the roster
Team Matches
Retrieve matches for a specific team
Organization Matches
Retrieve matches for all teams in an organization
Twitch Global Badges
Access global Twitch badge data
Twitch Channel Badges
Access channel-specific Twitch badge data
The OpenAPI specification at
/api-reference/openapi.json covers 13 paths: three match listing endpoints (user / team / org), two Twitch badge endpoints, and eight league endpoints. Game-developer score and lifecycle endpoints, overlay endpoints, and OAuth-proxy routes are intentionally excluded from the public spec.API Key Permissions
API keys carry a 5-category permission object. Every category appears in the create/edit dialog at/settings/developer. The leagues category is v.optional() in src/convex/schema/validators.ts:735 - older keys may lack it on disk, and the dialog auto-fills it from defaultLeagues (src/routes/(app)/settings/developer/(components)/api-key-edit-dialog.svelte:134-137) so all five categories remain editable.
| Category | Scopes | Values |
|---|---|---|
| Matches | user_matches, team_matches, org_matches | none / read / read-write |
| Connections | discord, twitch, github, battlenet | none / enabled |
| Game | scores, lifecycle | none / write (scores), none / read / read-write (lifecycle) |
| Webhooks | manage | none / enabled |
| Leagues | league_public, league_admin | none / read |
Presets
The create-key dialog ships with two one-click permission presets (src/routes/(app)/settings/developer/(components)/api-key-edit-dialog.svelte:98-130). A preset is only selectable when every connection in its requiredConnections list is linked on the user’s account.
| Preset | Scopes set | Required connections |
|---|---|---|
battles-replay | matches.user_matches: read, connections.twitch: enabled | Twitch |
league-manager | matches.team_matches: read, leagues.league_public: read, leagues.league_admin: read | none |
Captain Score Endpoints
These endpoints allow team captains to submit and manage scores.| Method | Endpoint | Description | Permission |
|---|---|---|---|
POST | /matches/{matchId}/scores | Submit a map score | matches.team_matches: read-write |
PATCH | /matches/{matchId}/scores | Confirm opponent’s score | matches.team_matches: read-write |
GET | /matches/{matchId}/scores | Get all map scores | matches.team_matches: read |
Game Developer Endpoints
These endpoints are for approved game developers.Score Submission
| Method | Endpoint | Description | Permission |
|---|---|---|---|
POST | /game/matches/{matchId}/scores | Submit verified score | game.scores: write |
Match Lifecycle
| Method | Endpoint | Description | Permission |
|---|---|---|---|
POST | /game/matches | List matches (JSON body with gameId) | game.lifecycle: read |
GET | /game/matches/{matchId} | Get match details | game.lifecycle: read |
GET | /game/matches/{matchId}/rosters | Get match rosters | game.lifecycle: read |
GET | /game/matches/{matchId}/status | Get match status | game.lifecycle: read |
PATCH | /game/matches/{matchId}/status | Update match status | game.lifecycle: read-write |
Player Stats
| Method | Endpoint | Description | Permission |
|---|---|---|---|
POST | /game/matches/{matchId}/player-stats | Submit player stats for a map | game.scores: write |
Common Response Codes
| Status | Description |
|---|---|
200 | Success |
201 | Created |
400 | Bad request - invalid parameters |
401 | Unauthorized - missing or invalid API key |
403 | Forbidden - insufficient permissions |
404 | Resource not found |
409 | Conflict - duplicate or invalid state |
429 | Rate limited |
500 | Internal server error |
Error Format
All errors follow a consistent format:Common Error Codes
Theerror field uses a stable machine-readable identifier. The most common pagination-related codes are:
| Error code | HTTP | When it occurs |
|---|---|---|
INVALID_NUM_ITEMS | 400 | Returned by the match listing endpoints when numItems is outside 1-100. See src/routes/api/v1/user/matches/+server.ts. |
INVALID_LIMIT | 400 | Returned by the league listing endpoints and /game/matches when limit is outside the supported range (1-50 for /leagues, 1-100 elsewhere). |
error_invalid_num_items and error_invalid_limit (src/convex/_helpers/errors.ts:21-22). Clients should treat the error field, not the message, as the stable contract.
Pagination
The v1 API is mid-migration and currently exposes two pagination envelope shapes. Check each endpoint’s reference page for its exact response shape.Native envelope (match listing endpoints)
The three match listing endpoints use Convex’s native pagination envelope:POST /api/v1/user/matches- see User MatchesPOST /api/v1/teams/{teamId}/matches- see Team MatchesPOST /api/v1/orgs/{orgId}/matches- see Organization Matches
numItems (page size, default 25) and cursor (opaque string from the previous response, or omit/null for the first page).
Response shape: { page, isDone, continueCursor }. Iterate page for results, check isDone to know when you’ve reached the end, and pass continueCursor as cursor in the next request.
Legacy envelope (all other v1 endpoints)
Most remaining v1 paginated endpoints still wrap results in a legacy envelope:{ matches, pagination: { cursor, hasMore }, timestamp }. Pass cursor (and typically limit) in the request body to get the next page. This shape will be migrated to the native envelope in a follow-up release.