Install the LiveKit Server SDK for your language (e.g., livekit-server-sdk for Node.js) and store your API key and API secret from the LiveKit Cloud dashboard or your self-hosted config as environment variables.
Generate an access token by constructing an AccessToken with your API key and secret, call addGrant() with VideoGrant fields such as roomJoin: true, room: 'your-room-name', canPublish: true, canSubscribe: true, then call toJwt() to produce the signed JWT.
Optionally pre-create the room server-side via RoomServiceClient.createRoom(), passing name, emptyTimeout (seconds before an empty room is deleted), and maxParticipants to enforce limits.
Pass the JWT to your frontend client; the client connects by calling room.connect(livekitUrl, token) where livekitUrl is your WebSocket endpoint (e.g., wss://your-project.livekit.cloud).
Use RoomServiceClient methods such as listParticipants(), removeParticipant(), and mutePublishedTrack() for server-side room management without requiring a client connection.
Tokens expire after the duration set at creation (default 6 hours); refresh tokens before expiry or implement a token refresh webhook to avoid session drops.
Known gotchas
Tokens are signed with the API secret and must be generated server-side; never expose the API secret in client-side code.
The room name in the token grant must exactly match the room the client attempts to join; a mismatch returns a permission-denied error.
emptyTimeout defaults to a short period on self-hosted deployments; set it explicitly if you need the room to persist before the first participant joins.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp