Token API
The Token API generates LiveKit JWT tokens for video consultation rooms.
GET /token
Generates a LiveKit access token with a room grant for the specified room and participant.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
room |
string | Yes | The name of the LiveKit room to join. |
participant |
string | Yes | The display name of the participant. |
Example Request
GET /token?room=consultation-123&participant=Jane%20Doe
Response (200)
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"url": "wss://3.93.221.174",
"room": "consultation-123",
"participant": "Jane Doe"
}
| Field | Type | Description |
|---|---|---|
token |
string | A signed JWT token with a room grant for the specified room. Short-lived (typically 6 hours). |
url |
string | The LiveKit server WebSocket URL to connect to. |
room |
string | Echoes back the requested room name. |
participant |
string | Echoes back the participant name. |
Token Claims
The generated JWT includes the following LiveKit grants:
roomJoin:true-- allows joining the roomroom: the requested room name -- scopes the token to that specific roomcanPublish:true-- allows publishing audio/video trackscanSubscribe:true-- allows subscribing to other participants' tracks
Frontend Usage
The frontend uses this token to connect to LiveKit:
import { LiveKitRoom } from '@livekit/components-react';
const response = await fetch(
`${process.env.NEXT_PUBLIC_TOKEN_ENDPOINT}?room=${roomName}&participant=${name}`
);
const { token, url } = await response.json();
// Then in the component:
<LiveKitRoom serverUrl={url} token={token} connect={true} />
Errors
| Status | Cause |
|---|---|
400 |
Missing room or participant query parameter |
500 |
Failed to read LiveKit credentials from SSM or token signing error |