Info
- REST API used by the Unity SDK, dedicated game servers and build tools:
https://polis.lics.cz/api/v2
- The full, always current reference with request and response schemas is Scalar: https://polis.lics.cz/scalar/v2. These pages explain how the parts fit together
- Unity side: Service Hub SDK in Unity Core
Calling the API
- JSON in and out, field names in
snake_case. Yes/no fields have no is_ prefix (guest, active). Leave out or send null for a field you don't use
- Every call names its app
X-App-Key - the app's key from App Settings, not a secret. After the key changes, the old one keeps working
- or a token of the app in
Authorization: Bearer <token>
- A token the hub turns down answers
401 with what to do (see Errors), also when X-App-Key comes along. Only the /auth calls, which take their credential in the body, and calls with a lobby guest pass go on with the key
- A token of another app than
X-App-Key names answers 403 app_mismatch
- Who calls
- Players:
Authorization: Bearer <access_token> from the Auth API
- Servers: a server token from server or machine sign-in (Auth API), or from hosting a server as a player (Servers API)
- Guests without an account: their lobby guest pass as the Bearer token with
X-App-Key, on the events connection, presence and stream calls (Presence & Streams API)
- Lobby hosts: the session's secret (
shl_…) in X-Session-Secret (Lobby API). The lobby's other calls need a player's or server's token
- Scripts: a personal API token (
shp_…), with the app's key in the path (Data API)
- Builds also send on every call, each up to 64 characters
X-App-Version - the app version
X-App-Build - the build
X-App-Platform - the platform, read in lowercase
X-App-Channel - the release channel the build is on, e.g. beta
X-App-Device - the device model, e.g. Quest 3
X-App-Os - the operating system with its version, e.g. Horizon OS 74
- Release resolve, remote config, crash report config and analytics sessions take these values from the headers; the same fields in the query or body override them. Remote config overrides can depend on them, see Remote Config API
X-Instance-Id on the events connection, presence and stream calls tells one person's running apps apart, e.g. a random ID the install keeps. A player's defaults to their sign-in. The events connection also takes X-App-Device-Type: headset, desktop or mobile, shown to staff with who's online
Accept-Language picks the language of legal texts, is recorded with legal and study answers, and remote config overrides can depend on it. The first language counts: cs from cs-CZ,cs;q=0.9,en;q=0.8
- Answers are compressed with brotli or gzip when the request asks for it (
Accept-Encoding)
Answers
- A success returns the data itself, without a wrapper.
201 for something new, e.g. an account, a lobby session, a server, a content upload or a friend request, with its URL in Location where it has one. 204 when there is nothing to answer
- Times are UTC in ISO 8601 with
Z, to the microsecond, in fields ending in _at. Sign-in answers also give expires_in in seconds, as in OAuth
- IDs are public ones: user IDs,
server_id, join codes and GUIDs. Internal database numbers never show
- Credentials start with a prefix that tells what they are, so secret scanners can spot them:
shr_ refresh token, shm_ machine token, shs_ server secret, shg_ guest key, shl_ lobby session secret, shp_ API token, shu_ upload key, sht_ lobby ticket
Errors
- Errors are problem details (RFC 9457),
Content-Type: application/problem+json
type, title, status, detail - detail, when there is more to say, tells what went wrong or what to do
code - a readable code in snake_case, e.g. server_already_hosted. Check code, not the texts. Each code has one fixed title; Scalar lists every code
errors - for bad input, each field at fault with what's wrong
- Some problems add fields of their own, e.g.
server_already_hosted names the host
- The HTTP status follows the code, the same in every area
400 bad input: invalid_request, with the fields at fault in errors. Refused sign-ins also answer 400, with OAuth codes, see Auth API
401 no valid credential, with WWW-Authenticate: Bearer error="invalid_token" and a code that says what to do: token_expired (refresh and retry), session_ended (sign in again), server_token_revoked (sign the server in again with its secret or machine token), unauthorized (sign in). app_not_found without X-App-Key or a token of the app
403 not allowed: forbidden, or player_token_required / server_token_required when the call needs the other kind of token, app_mismatch for a token of another app than X-App-Key names. Some calls give a reason of their own, e.g. service_disabled, guests_off
404 not found or gone, also live things that ended: lobby sessions, presences, hostings, uploads
409 conflict, e.g. account_already_linked, server_already_hosted
410 item_deleted - a save data item that was deleted and can still be restored
412 precondition_failed - the If-Match or If-None-Match sent no longer holds
413 too_large, also for a body over the call's limit
429 too_many_requests with Retry-After in seconds
500 internal_error - something broke on the hub
503 can't be done now: storage_unavailable (the file share is down), import_unavailable, streaming_unavailable