v1

latestOpenAPI 3.1.0Apache-2.02026-07-17144068.3 KB
livekit

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:

  1. Creates the room if it doesn't exist
  2. Sets room.metadata.auth_id to the authenticated tenant's ID
  3. 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

participant_identitystring required

Unique identifier for the participant (e.g., "user-123")

participant_namestring required

Display name for the participant (e.g., "John Doe")

room_namestring required

The LiveKit room name to generate a token for

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.

livekit_urlstring required

The LiveKit server URL to connect to

participant_identitystring required

Echo back the participant identity for client confirmation

room_namestring required

Echo back the room name for client confirmation

tokenstring required

The generated JWT token for LiveKit

Example response

{
  "livekit_url": "ws://localhost:7880",
  "participant_identity": "user-alice-456",
  "room_name": "conversation-room-123",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}