Stream Resource
Support for Twilio Regions 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).
Resource properties The SID of the Stream resource.
The user-specified name of this Stream, if one was given when the Stream was created. This can be used to stop the Stream.
The status of the Stream. Possible values are stopped
and in-progress
.
Possible values:
in-progress
stopped
date_updated
type: string<DATE TIME RFC 2822> Not PIIThe URI of the resource, relative to https://api.twilio.com
.
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Streams.json
URI parameters Request body parameters Required
Relative or absolute URL where WebSocket connection will be established.
The user-specified name of this Stream, if one was given when the Stream was created. This can be used to stop the Stream.
The tracks to be included in the Stream. Possible values are inbound_track
, outbound_track
, both_tracks
. Default value is inbound_track
.
Possible values:
inbound_track
outbound_track
both_tracks
StatusCallback
type: string<URI> Not PIIAbsolute URL to which Twilio sends status callback HTTP requests.
StatusCallbackMethod
type: enum<HTTP METHOD> Not PIIThe HTTP method Twilio uses when sending status_callback
requests. Possible values are GET
and POST
. Default is POST
.
Parameter1.Value
type: string Not PIIParameter2.Value
type: string Not PIIParameter3.Value
type: string Not PIIParameter4.Value
type: string Not PIIParameter5.Value
type: string Not PIIParameter6.Value
type: string Not PIIParameter7.Value
type: string Not PIIParameter8.Value
type: string Not PIIParameter9.Value
type: string Not PIIParameter10.Name
type: string Not PIIParameter10.Value
type: string Not PIIParameter11.Name
type: string Not PIIParameter11.Value
type: string Not PIIParameter12.Name
type: string Not PIIParameter12.Value
type: string Not PIIParameter13.Name
type: string Not PIIParameter13.Value
type: string Not PIIParameter14.Name
type: string Not PIIParameter14.Value
type: string Not PIIParameter15.Name
type: string Not PIIParameter15.Value
type: string Not PIIParameter16.Name
type: string Not PIIParameter16.Value
type: string Not PIIParameter17.Name
type: string Not PIIParameter17.Value
type: string Not PIIParameter18.Name
type: string Not PIIParameter18.Value
type: string Not PIIParameter19.Name
type: string Not PIIParameter19.Value
type: string Not PIIParameter20.Name
type: string Not PIIParameter20.Value
type: string Not PIIParameter21.Name
type: string Not PIIParameter21.Value
type: string Not PIIParameter22.Name
type: string Not PIIParameter22.Value
type: string Not PIIParameter23.Name
type: string Not PIIParameter23.Value
type: string Not PIIParameter24.Name
type: string Not PIIParameter24.Value
type: string Not PIIParameter25.Name
type: string Not PIIParameter25.Value
type: string Not PIIParameter26.Name
type: string Not PIIParameter26.Value
type: string Not PIIParameter27.Name
type: string Not PIIParameter27.Value
type: string Not PIIParameter28.Name
type: string Not PIIParameter28.Value
type: string Not PIIParameter29.Name
type: string Not PIIParameter29.Value
type: string Not PIIParameter30.Name
type: string Not PIIParameter30.Value
type: string Not PIIParameter31.Name
type: string Not PIIParameter31.Value
type: string Not PIIParameter32.Name
type: string Not PIIParameter32.Value
type: string Not PIIParameter33.Name
type: string Not PIIParameter33.Value
type: string Not PIIParameter34.Name
type: string Not PIIParameter34.Value
type: string Not PIIParameter35.Name
type: string Not PIIParameter35.Value
type: string Not PIIParameter36.Name
type: string Not PIIParameter36.Value
type: string Not PIIParameter37.Name
type: string Not PIIParameter37.Value
type: string Not PIIParameter38.Name
type: string Not PIIParameter38.Value
type: string Not PIIParameter39.Name
type: string Not PIIParameter39.Value
type: string Not PIIParameter40.Name
type: string Not PIIParameter40.Value
type: string Not PIIParameter41.Name
type: string Not PIIParameter41.Value
type: string Not PIIParameter42.Name
type: string Not PIIParameter42.Value
type: string Not PIIParameter43.Name
type: string Not PIIParameter43.Value
type: string Not PIIParameter44.Name
type: string Not PIIParameter44.Value
type: string Not PIIParameter45.Name
type: string Not PIIParameter45.Value
type: string Not PIIParameter46.Name
type: string Not PIIParameter46.Value
type: string Not PIIParameter47.Name
type: string Not PIIParameter47.Value
type: string Not PIIParameter48.Name
type: string Not PIIParameter48.Value
type: string Not PIIParameter49.Name
type: string Not PIIParameter49.Value
type: string Not PIIParameter50.Name
type: string Not PIIParameter50.Value
type: string Not PIIParameter51.Name
type: string Not PIIParameter51.Value
type: string Not PIIParameter52.Name
type: string Not PIIParameter52.Value
type: string Not PIIParameter53.Name
type: string Not PIIParameter53.Value
type: string Not PIIParameter54.Name
type: string Not PIIParameter54.Value
type: string Not PIIParameter55.Name
type: string Not PIIParameter55.Value
type: string Not PIIParameter56.Name
type: string Not PIIParameter56.Value
type: string Not PIIParameter57.Name
type: string Not PIIParameter57.Value
type: string Not PIIParameter58.Name
type: string Not PIIParameter58.Value
type: string Not PIIParameter59.Name
type: string Not PIIParameter59.Value
type: string Not PIIParameter60.Name
type: string Not PIIParameter60.Value
type: string Not PIIParameter61.Name
type: string Not PIIParameter61.Value
type: string Not PIIParameter62.Name
type: string Not PIIParameter62.Value
type: string Not PIIParameter63.Name
type: string Not PIIParameter63.Value
type: string Not PIIParameter64.Name
type: string Not PIIParameter64.Value
type: string Not PIIParameter65.Name
type: string Not PIIParameter65.Value
type: string Not PIIParameter66.Name
type: string Not PIIParameter66.Value
type: string Not PIIParameter67.Name
type: string Not PIIParameter67.Value
type: string Not PIIParameter68.Name
type: string Not PIIParameter68.Value
type: string Not PIIParameter69.Name
type: string Not PIIParameter69.Value
type: string Not PIIParameter70.Name
type: string Not PIIParameter70.Value
type: string Not PIIParameter71.Name
type: string Not PIIParameter71.Value
type: string Not PIIParameter72.Name
type: string Not PIIParameter72.Value
type: string Not PIIParameter73.Name
type: string Not PIIParameter73.Value
type: string Not PIIParameter74.Name
type: string Not PIIParameter74.Value
type: string Not PIIParameter75.Name
type: string Not PIIParameter75.Value
type: string Not PIIParameter76.Name
type: string Not PIIParameter76.Value
type: string Not PIIParameter77.Name
type: string Not PIIParameter77.Value
type: string Not PIIParameter78.Name
type: string Not PIIParameter78.Value
type: string Not PIIParameter79.Name
type: string Not PIIParameter79.Value
type: string Not PIIParameter80.Name
type: string Not PIIParameter80.Value
type: string Not PIIParameter81.Name
type: string Not PIIParameter81.Value
type: string Not PIIParameter82.Name
type: string Not PIIParameter82.Value
type: string Not PIIParameter83.Name
type: string Not PIIParameter83.Value
type: string Not PIIParameter84.Name
type: string Not PIIParameter84.Value
type: string Not PIIParameter85.Name
type: string Not PIIParameter85.Value
type: string Not PIIParameter86.Name
type: string Not PIIParameter86.Value
type: string Not PIIParameter87.Name
type: string Not PIIParameter87.Value
type: string Not PIIParameter88.Name
type: string Not PIIParameter88.Value
type: string Not PIIParameter89.Name
type: string Not PIIParameter89.Value
type: string Not PIIParameter90.Name
type: string Not PIIParameter90.Value
type: string Not PIIParameter91.Name
type: string Not PIIParameter91.Value
type: string Not PIIParameter92.Name
type: string Not PIIParameter92.Value
type: string Not PIIParameter93.Name
type: string Not PIIParameter93.Value
type: string Not PIIParameter94.Name
type: string Not PIIParameter94.Value
type: string Not PIIParameter95.Name
type: string Not PIIParameter95.Value
type: string Not PIIParameter96.Name
type: string Not PIIParameter96.Value
type: string Not PIIParameter97.Name
type: string Not PIIParameter97.Value
type: string Not PIIParameter98.Name
type: string Not PIIParameter98.Value
type: string Not PIIParameter99.Name
type: string Not PIIParameter99.Value
type: string Not PII
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.
_14 // Download the helper library from https://www.twilio.com/docs/node/install
_14 // Find your Account SID and Auth Token at twilio.com/console
_14 // and set the environment variables. See http://twil.io/secure
_14 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14 const authToken = process.env.TWILIO_AUTH_TOKEN;
_14 const client = require('twilio')(accountSid, authToken);
_14 client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_14 name: 'My Media Stream',
_14 url: 'wss://example.com/a-websocket-server'
_14 .then(stream => console.log(stream.sid));
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "call_sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "sid": "MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "name": "My Media Stream",
_10 "status": "in-progress",
_10 "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000",
_10 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
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.
_18 // Download the helper library from https://www.twilio.com/docs/node/install
_18 // Find your Account SID and Auth Token at twilio.com/console
_18 // and set the environment variables. See http://twil.io/secure
_18 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18 const authToken = process.env.TWILIO_AUTH_TOKEN;
_18 const client = require('twilio')(accountSid, authToken);
_18 client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_18 name: 'My Media Stream',
_18 'parameter1.name': 'agent_name',
_18 'parameter1.value': 'Mary',
_18 'parameter2.name': 'Department',
_18 'parameter2.value': 'sales',
_18 url: 'wss://example.com/a-websocket-server'
_18 .then(stream => console.log(stream.sid));
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "call_sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "sid": "MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "name": "My Media Stream",
_10 "status": "in-progress",
_10 "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000",
_10 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
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
.
URI parameters Path Parameter
The SID or the name
of the Stream resource to be stopped
Request body parameters Required
The status of the Stream you wish to stop. Only possible value is stopped
.
An example request is shown below.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .streams('MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .update({status: 'stopped'})
_11 .then(stream => console.log(stream.name));
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "call_sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "sid": "MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000",
_10 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
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
.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .update({status: 'stopped'})
_11 .then(stream => console.log(stream.name));
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "call_sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "sid": "MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000",
_10 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/MZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"