Skip to main content
The <Stream> instruction starts streaming the media from a call to a specific WebSocket address in near-real-time. Audio will be delivered as base64-encoded RTP payloads (no headers), wrapped in JSON payloads.

Attributes

ATTRIBUTEDESCRIPTIONOPTIONSDEFAULT
url The destination WebSocket address where the stream is going to be delivered. -
track Specifies which track should be streamed. inbound_track, outbound_track, both_tracksinbound_track
name Specifies custom name for the stream instance -
codec Specifies the codec to be used for the streamed audio. When set to ‘default’ or when transcoding is not possible, the codec from the call will be used. Currently, transcoding is only supported between PCMU and PCMA codecs. PCMU, PCMA, G722, OPUS, AMR-WB, defaultdefault
bidirectionalMode Bidirectional streaming mode mp3, rtpmp3
bidirectionalCodec Bidirectional streaming codec, used only with bidirectionalMode=rtp PCMU, PCMA, G722, OPUS, AMR-WBPCMU
bidirectionalSamplingRate Bidirectional streaming sampling rate in Hz 8000, 16000, 240008000
statusCallback A URL for Telnyx to send webhook requests to on stream status events (e.g. stream started, stopped, or failed). -
statusCallbackMethod HTTP request type used for statusCallback. GET, POSTPOST

Child verbs/nouns

NOUN/VERBDESCRIPTION
Parameter Custom key-value parameter to pass to the WebSocket server. Parameters are included in the start message sent over the WebSocket connection.

Parameter Attributes

ATTRIBUTEDESCRIPTIONOPTIONSDEFAULT
name The name of the custom parameter. -
value The value of the custom parameter. -

Examples

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Start>
    <Stream url="wss://yourdomain.com/stream" track="both_tracks" />
  </Start>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Start>
    <Stream url="wss://yourdomain.com/stream" statusCallback="https://example.com/stream-events">
      <Parameter name="customer_id" value="12345" />
      <Parameter name="call_type" value="support" />
    </Stream>
  </Start>
</Response>

Expected callbacks

If statusCallback is set, stream status callbacks are sent for the following events:
  • stream-started — Stream has started
  • stream-stopped — Stream has stopped
  • stream-failed — Stream failed to start or was interrupted
See Stream Callback for the full payload reference.