Place a call
const url = 'https://your-machine.your-tailnet.ts.net/v1/calls';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"deviceId":"phone-7f3a91c2","to":"+919876543210","stream":{"url":"wss://agent.example.com/ws","format":"twilio","parameters":{"campaign":"renewals"}},"webhookUrl":"https://example.com/gateway/events"}'};
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 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "deviceId": "phone-7f3a91c2", "to": "+919876543210", "stream": { "url": "wss://agent.example.com/ws", "format": "twilio", "parameters": { "campaign": "renewals" } }, "webhookUrl": "https://example.com/gateway/events" }'Queues a call on a phone. The response comes back as soon as the phone has the command; the
call’s progress arrives as webhooks (call.dialing, call.active, call.disconnected, …)
and in GET /v1/calls/{callId}.
Pass stream to connect the call to your agent’s WebSocket when it’s answered.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Which phone places the call.
Gets this call’s events instead of the default webhook.
Your own data, stored with the call and returned on reads and webhooks.
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
Examples
Call with an AI agent attached
{ "deviceId": "phone-7f3a91c2", "to": "+919876543210", "stream": { "url": "wss://agent.example.com/ws", "format": "twilio", "parameters": { "campaign": "renewals" } }, "webhookUrl": "https://example.com/gateway/events"}Plain call
{ "deviceId": "phone-7f3a91c2", "to": "+919876543210"}Responses
Section titled “Responses”Call queued and sent to the phone.
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
object
object
Where to join this call’s audio yourself (WebSocket).
object
object
The phone is sending audio right now.
Example
{ "call": { "remoteNumber": "+919876543210", "direction": "outgoing", "state": "queued", "stream": { "url": "wss://agent.example.com/ws", "format": "raw" } }, "command": { "type": "command", "action": "dial" }, "media": { "path": "/v1/calls/9b2e/media", "format": { "encoding": "pcm_s16le", "sampleRate": 16000, "channels": 1, "frameMs": 20 } }}The request didn’t validate.
object
object
Validation details
Example
{ "error": { "code": "VALIDATION_ERROR", "message": "invalid request", "issues": [] }}Missing or invalid API key.
object
object
Validation details
Example
{ "error": { "code": "UNAUTHORIZED", "message": "invalid API key or session" }}Not found.
object
object
Validation details
Example
{ "error": { "code": "NOT_FOUND", "message": "call not found" }}The phone isn’t connected to the gateway.
object
object
Validation details
Example
{ "error": { "code": "DEVICE_OFFLINE", "message": "device is offline" }}