v1
latestOpenAPI 3.1.0Apache-2.02026-07-17144068.3 KBlivekit
Handler for POST /livekit/token endpoint
Generates a LiveKit JWT token for a participant to join a specific room.
When authentication is enabled (auth.id is present), this handler:
- Creates the room if it doesn't exist
- Sets room.metadata.auth_id to the authenticated tenant's ID
- Issues the token only after metadata is verified/set
Arguments
- state - Shared application state containing LiveKit configuration
- request - Token request with room name and participant details
Returns
- Response - JSON response with token or error status
Errors
- 400 Bad Request - Invalid request data (empty fields)
- 403 Forbidden - Room exists with a different tenant's auth_id
- 500 Internal Server Error - LiveKit service not configured, room creation failed, or token generation failed
post/livekit/token
Request body
Example request
{
"participant_identity": "user-alice-456",
"participant_name": "Alice Smith",
"room_name": "conversation-room-123"
}Response
Token generated successfully. Room is created if it doesn't exist and metadata.auth_id is set.
Example response
{
"livekit_url": "ws://localhost:7880",
"participant_identity": "user-alice-456",
"room_name": "conversation-room-123",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}