Skip to content

Connect a live call to your agent

POST
/v1/calls/{callId}/stream
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.

callId
required
string
Media typeapplication/json

Your agent’s WebSocket. The gateway connects to it when the call is answered.

object
url
required

ws:// or wss://.

string

Example

wss://agent.example.com/ws
format

raw: 16 kHz s16le binary frames. twilio: Twilio Media Streams JSON with 8 kHz mu-law, compatible with Twilio integrations such as Pipecat’s.

string
default: raw
Allowed values: raw twilio
parameters

Sent to your agent in the start message (Twilio customParameters).

object
key
additional properties
string

Stream attached.

Media typeapplication/json
object
stream
One of:

Your agent’s WebSocket. The gateway connects to it when the call is answered.

object
url
required

ws:// or wss://.

string
format

raw: 16 kHz s16le binary frames. twilio: Twilio Media Streams JSON with 8 kHz mu-law, compatible with Twilio integrations such as Pipecat’s.

string
default: raw
Allowed values: raw twilio
parameters

Sent to your agent in the start message (Twilio customParameters).

object
key
additional properties
string
status
string
Allowed values: off waiting connecting live ended error
error
string
call
object
id
required
string
deviceId
required
string
remoteNumber
required
string
direction
required
string
Allowed values: outgoing incoming
state
required
string
Allowed values: queued dialing ringing active held ended rejected failed
nativeCallId
string
webhookUrl
string format: uri
metadata
object
key
additional properties
any
stream

Your agent’s WebSocket. The gateway connects to it when the call is answered.

object
url
required

ws:// or wss://.

string
format

raw: 16 kHz s16le binary frames. twilio: Twilio Media Streams JSON with 8 kHz mu-law, compatible with Twilio integrations such as Pipecat’s.

string
default: raw
Allowed values: raw twilio
parameters

Sent to your agent in the start message (Twilio customParameters).

object
key
additional properties
string
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
answeredAt
string format: date-time
endedAt
string format: date-time

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.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
issues

Validation details

Array

Example

{
"error": {
"code": "VALIDATION_ERROR",
"message": "invalid request",
"issues": []
}
}

The call has already ended.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
issues

Validation details

Array

Example

{
"error": {
"code": "DEVICE_OFFLINE"
}
}