Generates a LiveKit JWT token for a participant to join a specific room.
When authentication is enabled (auth.id is present), this handler:
room.metadata.auth_id to the authenticated tenant’s IDstate - Shared application state containing LiveKit configurationrequest - Token request with room name and participant detailsResponse - JSON response with token or error statusauth_idauth.id is present (authenticated mode):
metadata.auth_id is set to your tenant ID.| Scenario | Behavior |
|---|---|
| Room doesn’t exist | Room is created with metadata.auth_id set to your tenant ID. |
| Room exists, you own it | Token is issued normally. |
| Room exists, different owner | 403 Forbidden is returned. |
| Unauthenticated mode | Token is issued without ownership checks. |
| Status | Condition |
|---|---|
400 Bad Request | Missing or empty required fields. |
403 Forbidden | Room exists with a different tenant’s auth_id. |
500 Internal Server Error | LiveKit not configured or token generation failed. |
JWT token obtained from the authentication service. Required when AUTH_REQUIRED is enabled.
Request body for generating a LiveKit token
{
"room_name": "conversation-room-123",
"participant_name": "Alice Smith",
"participant_identity": "user-alice-456"
}Unique identifier for the participant (e.g., "user-123")
"user-alice-456"
Display name for the participant (e.g., "John Doe")
"Alice Smith"
The LiveKit room name to generate a token for
"conversation-room-123"
Token generated successfully. Room is created if it doesn't exist and metadata.auth_id is set.
Response containing the generated LiveKit token
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"room_name": "conversation-room-123",
"participant_identity": "user-alice-456",
"livekit_url": "ws://localhost:7880"
}The LiveKit server URL to connect to
"ws://localhost:7880"
Echo back the participant identity for client confirmation
"user-alice-456"
Echo back the room name for client confirmation
"conversation-room-123"
The generated JWT token for LiveKit
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."