Stream
StreamAction forks call audio to a WebSocket endpoint. The socket must advertise the audio.drachtio.org subprotocol or the PBX handshake fails.
StreamAction forks call audio to a WebSocket endpoint. The socket must advertise the audio.drachtio.org subprotocol or the PBX handshake fails. Streaming is billed at KES 0.50 a minute, metered per second, from the moment the stream starts until it stops or the call ends. It is charged after the call as its own Streaming line on your statement, on top of the call's own per-minute rate.
| Parameter | Type | JSON key | Required | Description |
|---|---|---|---|---|
URL | string | url | Yes | URL is the wss:// (or ws://) fork endpoint. Required. |
Track | string | track | No | Track selects which leg is forked: inbound_track, outbound_track, or both_tracks. Empty means the PBX default. |
Connect | *bool | connect | No | Connect answers and HOLDS the leg for the fork's lifetime. Load-bearing: without it the fork is fire-and-forget on a document that ends immediately, and the call hangs up after about a second. Every production caller sets it. Tri-state so an unset value can defer to the PBX default rather than silently meaning false. |
OutputSamplingRate | int | outputSamplingRate | No | OutputSamplingRate is the PCM rate delivered TO the socket: 8000 or 16000. Frames are 16-bit little-endian signed PCM. |
BidirectionalSamplingRate | int | bidirectionalSamplingRate | No | BidirectionalSamplingRate is the rate the socket RETURNS audio at; the PBX resamples to the channel codec. Set it whenever the socket plays audio back, or playback behaviour is undefined. |
InputSamplingRate | int | inputSamplingRate | No | InputSamplingRate is an informational hint about the source rate. |
Name | string | name | No | Name is a friendly label echoed back in status events. |
Record | *bool | record | No | Record requests recording of the forked leg. |
HeaderMetadata | string | headerMetadata | No | HeaderMetadata is a flat JSON object string delivered in the FIRST WebSocket TEXT frame as its headers field — NOT as HTTP headers on the handshake, despite the name. |
OpenMetadata | string | openMetadata | No | OpenMetadata is an opaque UTF-8 string delivered in the first TEXT frame. |
StatusCallback | string | statusCallback | No | StatusCallback receives stream-started / stream-stopped / stream-error. |
StatusEvents | string | statusEvents | No | StatusEvents is a space-separated subset of "stream-started stream-stopped stream-error". |
import { sauti } from "@sautikit/node";
res.json(sauti.stream({
url: "wss://your-app.example.com/audio",
connect: true,
track: "both_tracks",
bidirectionalSamplingRate: 16000,
}));{
"actions": [
{
"stream": {
"url": "wss://your-app.example.com/audio",
"connect": true,
"track": "both_tracks",
"bidirectionalSamplingRate": 16000
}
}
]
}<Stream url="wss://your-app.example.com/audio" connect="true" track="both_tracks" bidirectionalSamplingRate="16000" />