Skip to content

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:

typescript
interface CreateRoomRequest {
  projectId: string;
}

interface CreateRoomResponse {
  roomName: string;
  roomUrl: string;
}

Behavior:

  • Creates room with name pattern: onbook-{projectId}-{timestamp}
  • Sets 2-hour expiry (exp property)
  • Enables transcription by default
  • Returns full room URL for client-side joining

Permissions: Requires stage-manager, production-manager, or owner role.

Example:

typescript
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:

typescript
interface GetTokenRequest {
  roomName: string;
  userName: string;
  isOwner?: boolean;
}

interface GetTokenResponse {
  token: string;
}

Behavior:

  • Generates meeting token with user's display name
  • isOwner: true grants room control privileges (kick, mute others)
  • Token expires with the room (2 hours max)

Permissions: Any authenticated project member.

Token Types:

RoleisOwnerCapabilities
Stage ManagertrueFull room control
Production ManagertrueFull room control
OwnertrueFull room control
All OthersfalseJoin and participate only

Example:

typescript
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:

typescript
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:

typescript
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:

bash
firebase functions:secrets:set DAILY_API_KEY

Steps:

  1. Create a Daily.co account at daily.co
  2. Navigate to DevelopersAPI Keys
  3. Copy your API key
  4. Run the Firebase CLI command above
  5. Redeploy functions: firebase deploy --only functions

Function Configuration

Functions access the secret via runtime config:

typescript
// 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 CodeMeaningResolution
permission-deniedUser lacks required roleCheck RBAC permissions
invalid-argumentMissing projectId or roomNameValidate request payload
unavailableDaily API unreachableRetry with exponential backoff
resource-exhaustedDaily rate limit hitWait and retry

Client-Side Handling

typescript
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:

EndpointTriggerPurpose
/webhooks/daily/room-endedRoom expiryAuto-fetch and save transcript
/webhooks/daily/participant-joinedJoin eventUpdate presence indicators

Rate Limits

Daily.co API limits (as of Jan 2026):

ResourceLimit
Room creation100/minute
Token generation1000/minute
Concurrent rooms10 (free tier)

For production deployments, upgrade to Daily's paid tier for higher limits.