Skip to content
Server

Token API

Mint a room token and user token with POST /api/v1/token.

Mints a token to join a room, and creates the room if it doesn't exist. The kits call this for you, so you only need this page if you mint from your backend or use the media client.

POST https://stream.zavryn.online/api/v1/token

Authenticate

Send X-App-Id, plus one of these:

  • X-App-Key: from an app. See Credentials and auth.
  • X-App-Secret: from your backend. The Server Secret must never ship in an app.

Request

FieldRequiredDescription
identityYesA unique user id, up to 200 characters
room_nameYesThe room. Letters, numbers and _ - : ., up to 200 characters.
typeYesaudio_room or live_stream. It must be enabled on the project.
nameNoThe user's display name
roleNohost, admin, guest, audience or visitor. The default is audience.
metadataNoCustom data attached to the participant, up to 10 KB
display_nameNoThe room's display name, used when it's created
room_owner_idNoThe owner's identity. This user always joins as host.
seat_countNoSeats to create with the room, from 1 to 100. Default 9. Ignored for live_stream.
seat_modeNofree or request. Default free. Ignored for live_stream.
host_seatNoA seat reserved for identity when the room is created. Ignored for live_stream.
mode_idNoYour own identifier for the room's mode
device_idNoA device id, used so a user has one active session

In a live_stream room, only the verified owner becomes host. Everyone else becomes audience, whatever role they send. See Stage and roles.

Response

{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "url": "wss://...",
  "room_name": "my-room",
  "user_token": "eyJzdWIiOi...",
  "ws_url": "wss://stream.zavryn.online/ws"
}
FieldDescription
tokenConnects to the room's media
urlThe media server to connect to. Always use this value, and don't save it.
user_tokenThe bearer for in-room requests, bound to this identity
ws_urlThe signaling endpoint
room_messagingOnly when your project uses room messaging: url and batch_ms

A token is valid for one hour to join. Once connected, a user can stay with no time limit.

Errors

StatusMessage
422identity and room_name are required
422type must be one of: audio_call, video_call, live_stream, audio_room
422identity must be a string of max 200 characters
422room_name must be alphanumeric (with _ - : .) and max 200 characters
422role must be one of: host, admin, guest, audience, visitor
403Type '<type>' is not enabled for this project
403User is banned
403Project is suspended
429Maximum concurrent rooms reached
500Failed to generate token