> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# stream

> Start a background audio stream from the call to a WebSocket endpoint.

[statuscallbacks]: #statuscallbacks

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`](/docs/swml/reference/calling/stop-stream) or the call ends. You can run more than one stream at once by giving each its own `control_id`.

## **Properties**

An object that accepts the following properties.

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

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

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

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.

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

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

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

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

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

## **Variables**

Whether the stream started successfully.

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.

See the [Stream status callback](/docs/apis/rest/calls/webhooks/stream-status-callback) webhook page for the full field reference.

***

## **Examples**

### Stream to a WebSocket endpoint

```yaml
version: 1.0.0
sections:
  main:
    - stream:
        url: wss://example.com/audio-stream
```

```json
{
  "version": "1.0.0",
  "sections": {
    "main": [
      {
        "stream": {
          "url": "wss://example.com/audio-stream"
        }
      }
    ]
  }
}
```

### Stream both tracks with status callbacks

```yaml
version: 1.0.0
sections:
  main:
    - stream:
        url: wss://example.com/audio-stream
        name: live-transcription
        track: both_tracks
        status_url: https://example.com/stream-status
        custom_parameters:
          customer_tier: gold
```

```json
{
  "version": "1.0.0",
  "sections": {
    "main": [
      {
        "stream": {
          "url": "wss://example.com/audio-stream",
          "name": "live-transcription",
          "track": "both_tracks",
          "status_url": "https://example.com/stream-status",
          "custom_parameters": {
            "customer_tier": "gold"
          }
        }
      }
    ]
  }
}
```