Media Streams is now available in the Ireland (IE1) and Australia (AU1) Regions.
The Stream resource represents a live audio stream during a live call.
Creating a Stream resource creates a unidirectional Media Stream. You can stop a unidirectional Media Stream by updating the status
of a Stream resource, regardless of whether the Stream was created via TwiML (with <Start><Stream>
) or via REST API (with the Stream resource).
sid
type: SID<MZ>The SID of the Stream resource.
^MZ[0-9a-fA-F]{32}$
34
34
account_sid
type: SID<AC>The SID of the Account that created this Stream resource.
^AC[0-9a-fA-F]{32}$
34
34
call_sid
type: SID<CA>The SID of the Call the Stream resource is associated with.
^CA[0-9a-fA-F]{32}$
34
34
name
type: stringThe user-specified name of this Stream, if one was given when the Stream was created. This can be used to stop the Stream.
status
type: enum<string>The status of the Stream. Possible values are stopped
and in-progress
.
in-progress
stopped
date_updated
type: string<date-time-rfc-2822>The date and time in GMT that this resource was last updated, specified in RFC 2822 format.
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Streams.json
AccountSid
type: SID<AC>The SID of the Account that created this Stream resource.
^AC[0-9a-fA-F]{32}$
34
34
CallSid
type: SID<CA>The SID of the Call the Stream resource is associated with.
^CA[0-9a-fA-F]{32}$
34
34
Url
type: string<uri>RequiredRelative or absolute URL where WebSocket connection will be established.
Name
type: stringThe user-specified name of this Stream, if one was given when the Stream was created. This can be used to stop the Stream.
Track
type: enum<string>The tracks to be included in the Stream. Possible values are inbound_track
, outbound_track
, both_tracks
. Default value is inbound_track
.
inbound_track
outbound_track
both_tracks
StatusCallback
type: string<uri>Absolute URL to which Twilio sends status callback HTTP requests.
StatusCallbackMethod
type: enum<http-method>The HTTP method Twilio uses when sending status_callback
requests. Possible values are GET
and POST
. Default is POST
.
GET
POST
Create a Stream resource during a live call in order to start a new unidirectional Media Stream. Twilio sends the call's forked audio stream to the url
specified in this request.
A sample request is shown below.
You can also create a unidirectional Media Stream with custom parameters.
Twilio sends these custom parameters to your WebSocket server in the start
WebSocket message. Learn more on the WebSocket Messages page.
Use the parameter[x].name
and parameter[x].value
parameters to specify key-value pairs. For example, parameter1.name
is the key and parameter1.value
is the value of a key-value pair. You can provide up to 99 key-value pairs (parameter99.name
and parameter99.value
).
An example request is shown below.
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Streams/{Sid}.json
To stop a live unidirectional Media Stream, update the Stream resource's status
to stopped
.
AccountSid
type: SID<AC>The SID of the Account that created this Stream resource.
^AC[0-9a-fA-F]{32}$
34
34
CallSid
type: SID<CA>The SID of the Call the Stream resource is associated with.
^CA[0-9a-fA-F]{32}$
34
34
Status
type: enum<string>RequiredThe status of the Stream you wish to stop. Only possible value is stopped
.
stopped
An example request is shown below.
You can also use the Stream name
(if provided when creating the Stream) to stop the Stream. The example below shows how to stop a Stream with a name
of myStream
.