damp-midnight-34907
12/02/2025, 7:41 AMtall-airline-16756
12/02/2025, 7:42 AMtall-airline-16756
12/02/2025, 7:42 AMcreateRoom: false only prevents calling the explicit CreateRoom() API; it does not stop a room from being auto-created when a participant with a valid join token connects. In other words, if a token grants roomJoin (and a room name), joining will create the room even when createRoom is false.
What you can do instead:
• Pre-create rooms server-side with a privileged account (one that has RoomCreate) and only issue join tokens after the room exists.
• Or enforce backend checks before issuing tokens: only return a token for a room if the requesting user is allowed to create/join that room (use ACLs, naming rules, or a whitelist).
• If you need explicit control over creation, remove roomJoin tokens for untrusted users for non-existent rooms and require an admin workflow to create rooms.
Do you want sample server-side code to: 1) pre-create rooms and issue tokens, or 2) validate token requests against an ACL before returning a join token?
Sources: CreateRoom() is Taking Too Long | server-sdk-js | livekit/livekit_composite | DeepWiki | Authentication | LiveKit docs | Managing rooms | LiveKit docsdamp-midnight-34907
12/02/2025, 9:08 AMtall-airline-16756
12/02/2025, 9:08 AMcreateRoom grant only controls who may call the explicit CreateRoom API (server-side). A client holding a token with createRoom cannot invoke CreateRoom from the browser/mobile SDK; room creation via join still auto-creates rooms when roomJoin is granted.
What you can do instead:
• Call CreateRoom from your server (REST or server SDK) using a token/service key that has RoomCreate. The server will succeed if the token has the createRoom privilege and return an error if it does not.
• Or implement a server endpoint that checks the caller’s privileges and calls CreateRoom for them when allowed; clients call that endpoint rather than trying to create rooms directly.
If you want, I can:
• Share a short server-side code sample (REST or Node/Go) showing CreateRoom and the expected error when createRoom is missing, or
• Suggest a pattern for issuing tokens so only allowed users can join non-existent rooms. Which would you prefer?damp-midnight-34907
12/02/2025, 9:10 AMtall-airline-16756
12/02/2025, 9:11 AMRoomCreate) calls LiveKit's CreateRoom API. The backend enforces who may create rooms.
Why:
• User tokens are issued to clients and may be leaked or manipulated. Letting clients call CreateRoom directly with those tokens exposes privilege control.
• The createRoom grant controls the CreateRoom API call, but that call should be made from a trusted server-side environment.
Recommended flow:
1. Client requests room creation from your backend (e.g., POST /create-room with room name and user identity).
2. Backend verifies the user’s privileges (ACL, role, membership, etc.).
3. If allowed, backend calls LiveKit CreateRoom REST API or server SDK using a service token/key that has RoomCreate.
4. Backend returns success (or the join token) to the client. If not allowed, backend returns an authorization error.
Error handling:
• If the backend calls CreateRoom with a token that lacks createRoom, the CreateRoom call will fail with an authorization error — surface that error to logs and return a 403-like response to the client.
• If you instead issue a join token for a non-existent room, a client with roomJoin will auto-create it when joining; avoid issuing join tokens for rooms that shouldn't be created.
Would you like a brief sample of:
• Node/Express backend code calling LiveKit CreateRoom, or
• A sample endpoint that both creates the room and returns a join token?damp-midnight-34907
12/02/2025, 9:12 AMtall-airline-16756
12/02/2025, 9:13 AMcreateRoom privilege) calls LiveKit's REST CreateRoom endpoint, handles success/failure, and returns a result to the client. The client calls this backend endpoint instead of calling LiveKit directly.
Prerequisites:
• Service token or API key with RoomCreate permission available only on your backend.
• Install dependencies: npm install express node-fetch (or use your preferred HTTP client).
Example: Node/Express backend (minimal)
// server.js
const express = require('express');
const fetch = require('node-fetch');
const app = express();
app.use(express.json());
const LIVEKIT_BASE = 'https://your-livekit-host.example'; // your LiveKit server URL
const CREATE_ROOM_PATH = '/v1/rooms';
const SERVICE_TOKEN = process.env.LIVEKIT_SERVICE_TOKEN; // token with createRoom
// Simple auth check (replace with your real ACL/role checks)
function userCanCreateRoom(user) {
// implement your logic: roles, membership, subscription, etc.
return user && user.role === 'admin';
}
app.post('/create-room', async (req, res) => {
const { roomName, user } = req.body; // user info should come from session/auth
if (!userCanCreateRoom(user)) {
return res.status(403).json({ error: 'not_authorized' });
}
if (!roomName) {
return res.status(400).json({ error: 'roomName required' });
}
try {
const resp = await fetch(`${LIVEKIT_BASE}${CREATE_ROOM_PATH}`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${SERVICE_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: roomName }),
});
if (!resp.ok) {
const text = await resp.text();
return res.status(resp.status).json({ error: 'livekit_create_failed', details: text });
}
const body = await resp.json();
// Optionally create and return a join token here, or return room info
return res.status(200).json({ success: true, room: body });
} catch (err) {
return res.status(500).json({ error: 'server_error', details: err.message });
}
});
app.listen(3000, () => console.log('listening on 3000'));
Notes and best practices
• Keep the service token private on the backend (do not expose it to clients).
• Enforce strong ACLs in userCanCreateRoom so only authorized users can request creation.
• Optionally: after creating the room, generate a join token for the requesting user and return it so the client can connect immediately.
• If you call CreateRoom with a token that lacks createRoom, the LiveKit API returns an authorization error—log these and return a 403 to the client.
• Avoid issuing roomJoin tokens for non-existent rooms to untrusted clients; that would let them auto-create rooms by joining.
Would you like a short example showing how to also generate and return a join token after room creation?damp-midnight-34907
12/02/2025, 9:31 AMtall-airline-16756
12/02/2025, 9:32 AM/twirp/livekit.RoomService/CreateRoom)
• The backend/server SDK call to LiveKit's RoomService (e.g., using RoomServiceClient.createRoom)
• A client call to the WebSocket connect URL (e.g., room.connect(wss://...))
Also send:
• The exact URL/path your backend is calling (hide secrets/tokens)
• A curl or code snippet of the failing request (headers + body)
• Whether you're using LiveKit Cloud (project.livekit.cloud) or a self-hosted domain
With that I’ll tell you the likely cause and the minimal change to fix it.
Sources: Managing rooms | LiveKit docs | CreateRoom() is Taking Too Long | Authentication | LiveKit docsdamp-midnight-34907
12/02/2025, 9:41 AMtall-airline-16756
12/02/2025, 9:41 AMroomCreate).
Example curl (replace host and token):
curl -X POST https://your-livekit-host/twirp/livekit.RoomService/CreateRoom \
-H "Authorization: Bearer $SERVICE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"test-room"}'
If that still returns 404, tell me:
• Are you using LiveKit Cloud or a self-hosted instance?
• The exact host + port you're calling (no secrets). Example you tried: http://livekit-server:7880 or https://my-host.
• The server logs around the request (if available).
I’ll use that to point out the exact config or URL fix.damp-midnight-34907
12/02/2025, 9:45 AMtall-airline-16756
12/02/2025, 9:45 AMdamp-midnight-34907
12/02/2025, 9:50 AMtall-airline-16756
12/02/2025, 9:50 AMdamp-midnight-34907
12/02/2025, 9:55 AMtall-airline-16756
12/02/2025, 9:55 AM