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..."
}

Changes

Changed in 3 of the 13 revisions of this API.6

    • the endpoint scheme security auth was added to the API

      api-security-added

    • the endpoint scheme security bearer_auth was removed from the API

      api-security-removed

    This revision also has 2 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog

    • added the non-success response with the status

      response-non-success-status-added

    • the endpoint scheme security bearer_auth was added to the API

      api-security-added

    • the endpoint scheme security auth was removed from the API

      api-security-removed

    • removed the non-success response with the status

      response-non-success-status-removed

    This revision also has 29 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog