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
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/accounts/{account}/calls/current | Read the current call state |
| POST | /v1/accounts/{account}/calls/tickets | Get a single-use ticket for a WebSocket |
| WebSocket | /v1/accounts/{account}/calls/socket | Send 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:
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
| Event | When it arrives |
|---|---|
call.offered | An incoming call you can answer or reject now |
call.pending | An incoming call that is not yet actionable, or null when none is |
call.state | A call’s state changed. Stop audio at ending; ended means it is over |
call.control | A direct-call contact muted their microphone or changed their camera |
call.peer_status | A direct-call contact is ringing, joined, busy or did not answer |
track.updated | Your send track changed generation after a mute, camera, clear-audio or clear-video command |
calls.availability | Whether the account is in a call changed |
conference.invitations | The 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_videoto 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.watchwithenabled: falsewhen nobody looks at the other person’s video, such as while your call window is hidden, andtruewhen someone looks again. AddtrackIdto 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
- Check
conferenceCreate,conferenceJoin,conferenceInviteandconferenceAudioin the snapshot before you use them. - To create a call, send
call.dialwith"kind": "conference", the group ID and 1 to 100 invitees. - To join one, pick an entry from
conferenceInvitationsand sendcall.joinwith itsinvitationIdandinvitationRevision. Usecall.join, notcall.answer, for conference invitations. - After the call connects,
call.inviteadds contacts. Results arrive ascall.invitation_result, and asubmittedresult does not mean the contact has joined. Membership changes arrive asparticipant.updated. call.hangupleaves 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.resultwith"status": "error"and acode. A repeated identical request can return"status": "replayed". - A socket-level problem sends
call.error. Most of these also close the socket. The exception isoutcome_unknown, which leaves the socket open. - On the media socket,
capacitymeans 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
requestIdonly for an identical command.
The full list of codes is in the reference.