Calling

stream

View as MarkdownOpen in Claude

Stream the call’s audio to a WebSocket endpoint you control. The stream runs in the background: execution continues to the next instruction while audio is delivered to your endpoint in real time, which is useful for live transcription, voice analytics, or other custom media processing.

The stream keeps running until you stop it with stop_stream or the call ends. You can run more than one stream at once by giving each its own control_id.

Properties

stream
objectRequired

An object that accepts the following properties.

stream.url
stringRequired

The secure WebSocket URI (wss://) to stream the call’s audio to.

stream.control_id
stringDefaults to Auto-generated, stored in the stream_control_id variable

Identifier for this stream, used to stop it later with stop_stream. Must be unique among the active streams on the call.

stream.name
string

A friendly name to identify this stream. Included in the stream’s status events.

stream.track
stringDefaults to inbound_track

Which side of the call’s audio to stream: inbound_track for what the caller says, outbound_track for what the caller hears, or both_tracks for both.

stream.codec
string

Codec to use for the streamed audio. Freeform and endpoint-specific; common values include PCMU, PCMA, and OPUS.

stream.status_url
string

HTTP or HTTPS URL to deliver stream status events. Learn more about status callbacks.

stream.status_url_method
stringDefaults to POST

HTTP method used to deliver stream status events to status_url. Possible values: GET, POST.

stream.authorization_bearer_token
string

Bearer token sent in the Authorization header when connecting to the WebSocket endpoint.

stream.custom_parameters
object

Custom key-value pairs included in the first message sent to your WebSocket endpoint when the stream connects.

Variables

stream_result
success | failed

Whether the stream started successfully.

stream_control_id
string

Identifier assigned to this stream. stop_stream uses it to stop the right one.

StatusCallbacks

When you set status_url, SignalWire POSTs a calling.call.stream event to it whenever the stream changes state: params.state is streaming when the stream starts and finished when it ends.

Payload
1{
2 "event_type": "calling.call.stream",
3 "event_channel": "swml:451ed9ff-e568-4222-8af9-4f9ab7428d09",
4 "timestamp": 1777565701.5623918,
5 "project_id": "4d0d6f16-5881-4fcc-92a4-02c51a91954d",
6 "space_id": "451ed9ff-e568-4222-8af9-4f9ab7428d09",
7 "params": {
8 "call_id": "2e1e66e5-5d07-413d-9668-55542992eec0",
9 "node_id": "a0d4e6e5-5d07-413d-9668-55542992eec0",
10 "segment_id": "2e1e66e5-5d07-413d-9668-55542992eec0",
11 "control_id": "stream-control-1",
12 "state": "streaming",
13 "url": "wss://example.com/stream"
14 }
15}

See the Stream status callback webhook page for the full field reference.


Examples

Stream to a WebSocket endpoint

1version: 1.0.0
2sections:
3 main:
4 - stream:
5 url: wss://example.com/audio-stream

Stream both tracks with status callbacks

1version: 1.0.0
2sections:
3 main:
4 - stream:
5 url: wss://example.com/audio-stream
6 name: live-transcription
7 track: both_tracks
8 status_url: https://example.com/stream-status
9 custom_parameters:
10 customer_tier: gold