Video Chat API Reference
Cloud Functions for video conferencing with Daily.co integration.
Overview
The Video Chat feature uses Firebase Cloud Functions to interact with the Daily.co API. All functions are callable and require authentication.
Functions
createDailyRoom
Creates a new Daily.co room for video conferencing.
Signature:
interface CreateRoomRequest {
projectId: string;
}
interface CreateRoomResponse {
roomName: string;
roomUrl: string;
}Behavior:
- Creates room with name pattern:
onbook-{projectId}-{timestamp} - Sets 2-hour expiry (
expproperty) - Enables transcription by default
- Returns full room URL for client-side joining
Permissions: Requires stage-manager, production-manager, or owner role.
Example:
import { httpsCallable } from 'firebase/functions';
import { functions } from '@/lib/firebase-config';
const createRoom = httpsCallable(functions, 'createDailyRoom');
const { data } = await createRoom({ projectId: 'abc123' });
// data.roomUrl = "https://onbook.daily.co/onbook-abc123-1706567890"getDailyToken
Generates a participant authentication token for joining a room.
Signature:
interface GetTokenRequest {
roomName: string;
userName: string;
isOwner?: boolean;
}
interface GetTokenResponse {
token: string;
}Behavior:
- Generates meeting token with user's display name
isOwner: truegrants room control privileges (kick, mute others)- Token expires with the room (2 hours max)
Permissions: Any authenticated project member.
Token Types:
| Role | isOwner | Capabilities |
|---|---|---|
| Stage Manager | true | Full room control |
| Production Manager | true | Full room control |
| Owner | true | Full room control |
| All Others | false | Join and participate only |
Example:
const getToken = httpsCallable(functions, 'getDailyToken');
const { data } = await getToken({
roomName: 'onbook-abc123-1706567890',
userName: 'Jane Smith',
isOwner: true
});
// data.token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."fetchTranscript
Retrieves the transcript after a meeting ends.
Signature:
interface FetchTranscriptRequest {
roomName: string;
}
interface FetchTranscriptResponse {
transcript: TranscriptEntry[];
duration: number; // seconds
}
interface TranscriptEntry {
speaker: string;
text: string;
timestamp: number; // seconds from start
}Behavior:
- Fetches transcript from Daily.co's transcription service
- Returns empty array if transcription was disabled or failed
- Automatically triggered by room expiry webhook (optional)
Permissions: Requires stage-manager, production-manager, or owner role.
Example:
const fetchTranscript = httpsCallable(functions, 'fetchTranscript');
const { data } = await fetchTranscript({
roomName: 'onbook-abc123-1706567890'
});
// data.transcript = [{ speaker: "Jane", text: "Hello everyone", timestamp: 0 }, ...]Environment Setup
Daily API Key
The Daily API key must be stored as a Firebase secret:
firebase functions:secrets:set DAILY_API_KEYSteps:
- Create a Daily.co account at daily.co
- Navigate to Developers → API Keys
- Copy your API key
- Run the Firebase CLI command above
- Redeploy functions:
firebase deploy --only functions
Function Configuration
Functions access the secret via runtime config:
// functions/src/video/createDailyRoom.ts
import { defineSecret } from 'firebase-functions/params';
const dailyApiKey = defineSecret('DAILY_API_KEY');
export const createDailyRoom = onCall(
{ secrets: [dailyApiKey] },
async (request) => {
const daily = new Daily({ apiKey: dailyApiKey.value() });
// ...
}
);Error Handling
Common Errors
| Error Code | Meaning | Resolution |
|---|---|---|
permission-denied | User lacks required role | Check RBAC permissions |
invalid-argument | Missing projectId or roomName | Validate request payload |
unavailable | Daily API unreachable | Retry with exponential backoff |
resource-exhausted | Daily rate limit hit | Wait and retry |
Client-Side Handling
try {
const { data } = await createRoom({ projectId });
return data.roomUrl;
} catch (error) {
if (error.code === 'permission-denied') {
toast.error('Only Stage Managers can start meetings');
} else {
toast.error('Failed to create meeting room');
}
}Webhooks (Future)
Planned webhook endpoints for automatic processing:
| Endpoint | Trigger | Purpose |
|---|---|---|
/webhooks/daily/room-ended | Room expiry | Auto-fetch and save transcript |
/webhooks/daily/participant-joined | Join event | Update presence indicators |
Rate Limits
Daily.co API limits (as of Jan 2026):
| Resource | Limit |
|---|---|
| Room creation | 100/minute |
| Token generation | 1000/minute |
| Concurrent rooms | 10 (free tier) |
For production deployments, upgrade to Daily's paid tier for higher limits.