Info
- Live sessions that players find in a list or by join code. Paths below are under
/api/v2
- A host registers a session, keeps it alive with heartbeats or updates and ends it when it stops. Hosts are game servers or players hosting from their device
- Every call needs a player's or server's token, except the host's own calls with
X-Session-Secret. Without one 401 unauthorized
- Needs the Lobby service on for the app, otherwise
403 service_disabled
- Base URL, app key, tokens, errors, lists,
Idempotency-Key and rate limits: API
- Unity side: Lobby in Unity Core
Host side
POST /lobby/sessions - name, version, optional public_address, public_port, max_players (32 when left out), data (any string, e.g. JSON, up to 262,144 characters, else 413 too_large), visibility, friends, groups, group_ids, debug. Name, version and address are cut at 256 characters. Takes Idempotency-Key
- Answers
201 with Location: join_code (5 letters or digits), secret (shl_…), expires_at and restored
- Who registers: a player's token (the player is recorded as the host) or a server token (the session belongs to the server, see Hosted servers)
visibility - public (the default, everyone finds it in the list) or private (found by its join code, and in the list by those it's shared with)
- Share a private session with
friends: true (the host's friends), groups: true (everyone in the host's groups that have roles in the app and Share sessions on) or group_ids (picked groups from GET /lobby/groups, up to 20). Friends and groups need a player host. A dedicated server or linked machine may pick any of the app's groups. Otherwise 400 invalid_request
- When a heartbeat or update answers
404, e.g. after a hub restart, register again with the old secret in X-Session-Secret. The session comes back with the same join code, stream room and guest passes, and restored: true. Send the players again with an update. If the code was taken meanwhile, it gets a new code and secret
POST /lobby/sessions/{code}/heartbeat - send it before expires_at (30 s after the last heartbeat or update by default), or the session ends. Returns the next expires_at, while someone takes its server over also ending_at and taken_over_by (see Hosted servers)
PATCH /lobby/sessions/{code} - any of name, data, current_players, players, visibility, friends, groups, group_ids. Leave a field out to keep it, send group_ids: [] for no picked groups. Counts as a heartbeat and answers like one, with the session
players - everyone connected: user_id (or guest_id from a guest pass), name (cut at 64), device (headset, desktop or mobile). Up to 512, each person once. Leave it out to keep the last list, send [] for nobody. Without current_players the count is the list's length
- A
user_id must be the host's own or one whose ticket the host redeemed in this session (Player tickets). Otherwise the whole update is refused with 403 player_not_verified and the user_ids to leave out. Players without an account are listed by the guest_id of their guest pass
- Once a session sends
players, only the players listed get into its presence and stream room, a join code alone isn't enough. Hosts that never send it keep join-code access
DELETE /lobby/sessions/{code} - when the host stops. Answers 204
- Host calls send the session's secret in
X-Session-Secret. Without it 400 invalid_request, with a wrong secret or a code that doesn't match it 404 session_not_found
POST /lobby/sessions/{code}/guest-passes - optional name. Answers 201 with a pass and guest_id for a player without an account. The host hands the pass over the game connection, the guest sends it as Bearer token with X-App-Key for presence, the events connection and stream tokens. It works only for this session and ends with it. List the guest in players by its guest_id
GET /lobby/groups - the groups a private session can be shared with: those that have roles in the app and Share sessions on (Groups › General). For a player host its own, for a dedicated server or linked machine all of the app's. limit 50 (up to 200) from offset. Each group has id, name and color (hex like #86EFAC)
Player tickets
- A ticket proves to the host who a player is, so the players a session reports are the real accounts
- The player:
POST /lobby/tickets with an optional join_code. Answers 201 with ticket (sht_…) and expires_at (2 minutes)
- With
join_code the ticket works only in that session, and only when the player may join it (else 404 session_not_found, counted as a wrong code). Without one it works in any session of the app the player may join, e.g. after joining by address
- Needs a player's token, a guest account's too. Server tokens and guest passes answer
403 player_token_required
- The player hands the ticket to the host over the game connection
- The host:
POST /lobby/sessions/{code}/players with ticket and X-Session-Secret. Answers user_id and name, the name others see
400 ticket_invalid - unknown or expired, the player asks for a new one
409 ticket_used - another session redeemed it
403 ticket_mismatch - made for another session or app
403 forbidden - the player may not join this session's server