Skip to content

Control calls over WebSocket

Use the control socket to place, answer and end calls and to receive call events. Every message and field is listed in the calls WebSocket reference. Audio and video frames travel on a separate socket, described in the call media guide.

Routes and snapshot

MethodPathPurpose
GET/v1/accounts/{account}/calls/currentRead the current call state
POST/v1/accounts/{account}/calls/ticketsGet a single-use ticket for a WebSocket
WebSocket/v1/accounts/{account}/calls/socketSend commands and receive events

Every route needs a bearer token with the calls scope. Clients that cannot set headers, such as browsers, can instead pass a ticket as ?ticket=. Ask for one with {"socket":"control"}; it is single-use and expires after 20 seconds.

Read the snapshot before you act:

Terminal window
curl -sS -H "Authorization: Bearer $TOKEN" \
"$BASE/v1/accounts/$ACCOUNT/calls/current"
{
"capabilities": {"directAudio": true, "directVideo": true, "conferenceCreate": true},
"availability": {"busy": false, "ownedByThisClient": false},
"currentOffer": null,
"currentCall": null
}

This example is abridged. The full shape is in the CallSnapshot reference. A capability that is missing means unavailable, so check it before you send a command. The hello event carries the same fields.

Protocol version

Within five seconds of opening the socket, announce the versions you support:

{"type": "call.hello", "supportedProtocolVersions": [3, 4]}

Wait for hello and check protocolVersion. The daemon speaks versions 3 and 4 and picks the highest one you both support. Version 4 adds call.clear_video and the shared_clock option on media.attach; version 3 clients keep working. If you omit the announcement, the daemon treats you as version 1 and rejects you with a protocol.error before it closes the socket with code 1002. The CLI, SDK and OpenClaw plugin announce [3, 4] and hold back version 4 commands when they talk to a version 3 daemon.

Readiness

Before a call can carry audio, prepare your audio path and send call.ready with the PCM format you will use (16 kHz, mono, 20 ms frames in the snapshot’s audioFormat). A new connection is passive until it does this. Send ready: false to withdraw readiness. The reference lists the scope options.

Place, answer and end a call

Each command has a requestId of your choosing. The daemon replies with command.result carrying the same ID.

Dial a contact. The socket that dials owns the call.

{
"type": "call.dial",
"requestId": "dial-1",
"target": {"kind": "direct", "contactId": "CONTACT_ID"},
"callType": "voice"
}

The command.result contains callId and ownerToken. Keep the ownerToken secret; the media socket needs it. Wait for call.state with "state": "connected".

Answer an incoming call with the latest revision from call.offered:

{
"type": "call.answer",
"requestId": "answer-1",
"callId": "CALL_ID",
"expectedRevision": 3
}

The first client to answer owns the call. Others receive already_claimed.

Hang up after the call is connected:

{
"type": "call.hangup",
"requestId": "hangup-1",
"callId": "CALL_ID",
"expectedRevision": 5
}

Use call.cancel to stop your outgoing call before it is answered, and call.reject to decline an incoming one. They take the same fields.

Events to handle

EventWhen it arrives
call.offeredAn incoming call you can answer or reject now
call.pendingAn incoming call that is not yet actionable, or null when none is
call.stateA call’s state changed. Stop audio at ending; ended means it is over
call.controlA direct-call contact muted their microphone or changed their camera
call.peer_statusA direct-call contact is ringing, joined, busy or did not answer
track.updatedYour send track changed generation after a mute, camera, clear-audio or clear-video command
calls.availabilityWhether the account is in a call changed
conference.invitationsThe list of conference calls you can join was replaced; an empty list clears it

Ignore any event type you don’t recognize, on both sockets. The daemon can add event types, and closing the socket on one would drop a live call.

Video controls

  • Clear queued video. On protocol version 4, send call.clear_video to drop queued outgoing video without turning your camera off, for example to interrupt a synthetic video reply. The send track gets a new generation (track.updated), and the daemon asks your encoder for a fresh keyframe.
  • Stop watching. Send call.watch with enabled: false when nobody looks at the other person’s video, such as while your call window is hidden, and true when someone looks again. Add trackId to change one participant’s video; without it the command covers every receive track, including later ones. See stop watching.
{"type": "call.clear_video", "requestId": "clear-video-1", "callId": "CALL_ID"}
{"type": "call.watch", "requestId": "watch-1", "callId": "CALL_ID", "enabled": false}

Conference calls

  1. Check conferenceCreate, conferenceJoin, conferenceInvite and conferenceAudio in the snapshot before you use them.
  2. To create a call, send call.dial with "kind": "conference", the group ID and 1 to 100 invitees.
  3. To join one, pick an entry from conferenceInvitations and send call.join with its invitationId and invitationRevision. Use call.join, not call.answer, for conference invitations.
  4. After the call connects, call.invite adds contacts. Results arrive as call.invitation_result, and a submitted result does not mean the contact has joined. Membership changes arrive as participant.updated.
  5. call.hangup leaves the call without ending it for the other participants.

Direct-to-conference promotion is not available in this version.

Errors

  • A rejected command returns command.result with "status": "error" and a code. A repeated identical request can return "status": "replayed".
  • A socket-level problem sends call.error. Most of these also close the socket. The exception is outcome_unknown, which leaves the socket open.
  • On the media socket, capacity means outgoing audio arrived faster than it plays.
  • A lost reply does not mean the command failed, and it does not authorize an automatic retry. Read the snapshot first.
  • Use the same requestId only for an identical command.

The full list of codes is in the reference.