Chert
Back to Writing

How to place an outbound FaceTime call from your backend

Chert TeamProduct and engineering

With Chert’s Bring Your Own Room integration, your backend starts the call and your agent runs in a LiveKit room you control. The call ID arrives as soon as Chert allocates the call. Wait for the media bridge before the agent speaks.

Prepare the line and LiveKit room

Use a Chert project UUID and line UUID with a current shared allocation or dedicated assignment. The project API key needs facetime:write to create and end calls and facetime:read to read state and events. Use a FaceTime-enabled recipient who has agreed to the call. Free and Shared lines require recipient verification. Dedicated lines follow the line’s recipient policy. Line and recipient requirements.

Join the agent to your room with exactly one eligible, unmuted audio track. Keep it silent while the call rings. Issue a separate bridge JWT with a distinct identity and permission to join, publish, and subscribe in that room. It must have more than 90 seconds left at allocation and an issued lifetime of at most two hours. LiveKit token requirements.

Request the call

On your backend, export the project key, project and line UUIDs, recipient phone number in international format, LiveKit URL, bridge JWT, and agent identity using the variable names below. Set CHERT_CREATE_KEY to a unique 8–200 character value and persist it before sending. Run the example where curl and jq are available.

(
  set -euo pipefail
  body=$(jq -n '{
    direction: "outbound",
    mode: "customer_managed",
    line_id: env.CHERT_LINE_ID,
    destination_type: "phone",
    destination: env.CHERT_RECIPIENT,
    media: {audio: true, video: false},
    livekit_url: env.LIVEKIT_URL,
    participant_token: env.LIVEKIT_BRIDGE_JWT,
    remote_participant_identity: env.LIVEKIT_AGENT_IDENTITY
  }')

  printf '%s' "$body" | curl -sS --fail-with-body --include \
    --request POST 'https://app.chert.dev/api/v1/calls' \
    --header "Authorization: Bearer $CHERT_API_KEY" \
    --header "X-Chert-Project-Id: $CHERT_PROJECT_ID" \
    --header "Idempotency-Key: $CHERT_CREATE_KEY" \
    --header 'Content-Type: application/json' \
    --data-binary @-
)

For FaceTime Video, set video: true, confirm the line is ready for outbound video, and publish the agent’s video track before dialing. Caller-camera capture is enabled separately. For an email recipient, change destination_type to "email" and supply the FaceTime email address. Outbound request reference.

Read the receipt and wait for the bridge

HTTP 201 means Chert allocated the call. Save data.id with your job record. This abridged JSON shows the documented response fields with example values. Call response format.

{
  "data": { "id": "00000000-0000-4000-8000-000000000001" },
  "request_id": "example-request-id"
}

If you lose the response, retry with the original body and create key. A materially different body with the same key returns HTTP 409. Preserve the original key when the outcome is uncertain so a retry cannot start a second call. Create retry behavior.

Read GET /api/v1/calls/{callId}/events with the same project authentication, or use lifecycle webhooks from an assigned integration. The bridge can join LiveKit before the recipient answers. Greet once per call ID on bridge_ready or the corresponding outbound call.started webhook. Ignore activation for calls that already ended or failed. Call lifecycle and webhook reference.

End the call and release the room

Either party can hang up. To end the call from your backend, send POST /api/v1/calls/{callId}/end with an empty JSON object and a separate idempotency key. HTTP 202 acknowledges that request. Observe the call until it reaches a terminal state, then release your agent, dispatch, and room on success or failure. End request and cleanup.

Related guides

Build your first conversation.

Choose a plan, connect your agent, and test the complete flow.

Start building