Connect a live call to your agent
const url = 'https://your-machine.your-tailnet.ts.net/v1/calls/example/stream';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"url":"wss://agent.example.com/ws","format":"raw","parameters":{"additionalProperty":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://your-machine.your-tailnet.ts.net/v1/calls/example/stream \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "url": "wss://agent.example.com/ws", "format": "raw", "parameters": { "additionalProperty": "example" } }'The gateway opens a WebSocket to url and streams the call both ways. A ringing incoming
call is answered first. Replaces any stream already attached. Closing the socket from
your side hangs up the call.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Your agent’s WebSocket. The gateway connects to it when the call is answered.
object
ws:// or wss://.
Example
wss://agent.example.com/wsraw: 16 kHz s16le binary frames. twilio: Twilio Media Streams JSON with 8 kHz mu-law,
compatible with Twilio integrations such as Pipecat’s.
Sent to your agent in the start message (Twilio customParameters).
object
Responses
Section titled “Responses”Stream attached.
object
Your agent’s WebSocket. The gateway connects to it when the call is answered.
object
ws:// or wss://.
raw: 16 kHz s16le binary frames. twilio: Twilio Media Streams JSON with 8 kHz mu-law,
compatible with Twilio integrations such as Pipecat’s.
Sent to your agent in the start message (Twilio customParameters).
object
object
object
Your agent’s WebSocket. The gateway connects to it when the call is answered.
object
ws:// or wss://.
raw: 16 kHz s16le binary frames. twilio: Twilio Media Streams JSON with 8 kHz mu-law,
compatible with Twilio integrations such as Pipecat’s.
Sent to your agent in the start message (Twilio customParameters).
object
Example
{ "stream": { "url": "wss://agent.example.com/ws", "format": "raw" }, "status": "off", "call": { "remoteNumber": "+919876543210", "direction": "outgoing", "state": "queued", "stream": { "url": "wss://agent.example.com/ws", "format": "raw" } }}The request didn’t validate.
object
object
Validation details
Example
{ "error": { "code": "VALIDATION_ERROR", "message": "invalid request", "issues": [] }}The call has already ended.
object
object
Validation details
Example
{ "error": { "code": "DEVICE_OFFLINE" }}