Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Stream Resource


A Stream is a pub-sub primitive that lets you broadcast JSON messages at a high rate to an elastic group of subscribers.

  • Messages are ephemeral - they can be published (created), but they cannot be queried, updated or deleted
  • The maximum Message payload size as serialized JSON is 4KB.
  • The maximum Message publishing rate per Stream is 30 per second.
  • Message delivery to remote endpoints is not guaranteed.
  • Messages may be received by remote endpoints in a different order than they were published.

See also Stream Message for information about the messages in a stream.


Sync Stream properties

sync-stream-properties page anchor
Resource properties
sidtype: SID<TO>Not PII

The unique string that we created to identify the Sync Stream resource.


unique_nametype: stringPII MTL: 30 days

An application-defined string that uniquely identifies the resource. It can be used in place of the resource's sid in the URL to address the resource.


service_sidtype: SID<IS>Not PII

The SID of the Sync Service(link takes you to an external page) the resource is associated with.


urltype: string<URI>Not PII

The absolute URL of the Message Stream resource.


linkstype: object<URI MAP>Not PII

The URLs of the Stream's nested resources.


date_expirestype: string<DATE TIME>Not PII

The date and time in GMT when the Message Stream expires and will be deleted, specified in ISO 8601(link takes you to an external page) format. If the Message Stream does not expire, this value is null. The Stream might not be deleted immediately after it expires.


date_createdtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


created_bytype: stringPII MTL: 30 days

The identity of the Stream's creator. If the Stream is created from the client SDK, the value matches the Access Token's identity field. If the Stream was created from the REST API, the value is 'system'.


Create a Sync Stream resource

create-a-sync-stream-resource page anchor
POST https://sync.twilio.com/v1/Services/{ServiceSid}/Streams

Parameters

create-parameters page anchor
URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) to create the new Stream in.


Request body parameters
UniqueNametype: stringPII MTL: 30 days

An application-defined string that uniquely identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The unique_name value can be used as an alternative to the sid in the URL path to address the resource.


Ttltype: integerNot PII

How long, in seconds(link takes you to an external page), before the Stream expires and is deleted (time-to-live).

Create a Sync Stream resource

create-a-sync-stream-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncStreams
_11
.create()
_11
.then(sync_stream => console.log(sync_stream.sid));

Output

_14
{
_14
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"created_by": "created_by",
_14
"date_expires": "2015-07-30T21:00:00Z",
_14
"date_created": "2015-07-30T20:00:00Z",
_14
"date_updated": "2015-07-30T20:00:00Z",
_14
"links": {
_14
"messages": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages"
_14
},
_14
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"sid": "TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"unique_name": "unique_name",
_14
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_14
}


Fetch a Sync Stream resource

fetch-a-sync-stream-resource page anchor
GET https://sync.twilio.com/v1/Services/{ServiceSid}/Streams/{Sid}

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Sync Stream resource to fetch.


Sidtype: stringNot PII
Path Parameter

The SID of the Stream resource to fetch.

Fetch a Sync Stream resource

fetch-a-sync-stream-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncStreams('TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.fetch()
_11
.then(sync_stream => console.log(sync_stream.uniqueName));

Output

_14
{
_14
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"created_by": "created_by",
_14
"date_expires": "2015-07-30T21:00:00Z",
_14
"date_created": "2015-07-30T20:00:00Z",
_14
"date_updated": "2015-07-30T20:00:00Z",
_14
"links": {
_14
"messages": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages"
_14
},
_14
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"sid": "TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"unique_name": "unique_name",
_14
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_14
}


Read multiple Sync Stream resources

read-multiple-sync-stream-resources page anchor
GET https://sync.twilio.com/v1/Services/{ServiceSid}/Streams

Note: Without a PageSize query parameter, this will return only the first 50 Message Streams. Add a PageSize query parameter to fetch up to 100 items at once. The example has a PageSize value of 20.

See paging for more information.

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Stream resources to read.


PageSizetype: integerNot PII
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integerNot PII
Query Parameter

The page index. This value is simply for client state.


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

Read multiple Sync Stream resources

read-multiple-sync-stream-resources-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncStreams
_11
.list({limit: 20})
_11
.then(syncStreams => syncStreams.forEach(s => console.log(s.sid)));

Output

_27
{
_27
"streams": [
_27
{
_27
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"created_by": "created_by",
_27
"date_expires": "2015-07-30T21:00:00Z",
_27
"date_created": "2015-07-30T20:00:00Z",
_27
"date_updated": "2015-07-30T20:00:00Z",
_27
"links": {
_27
"messages": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages"
_27
},
_27
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"sid": "TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"unique_name": "unique_name",
_27
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_27
}
_27
],
_27
"meta": {
_27
"first_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams?PageSize=50&Page=0",
_27
"key": "streams",
_27
"next_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams?PageSize=50&Page=1",
_27
"page": 0,
_27
"page_size": 50,
_27
"previous_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams?PageSize=50&Page=0",
_27
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams?PageSize=50&Page=0"
_27
}
_27
}


Update a Sync Stream resource

update-a-sync-stream-resource page anchor
POST https://sync.twilio.com/v1/Services/{ServiceSid}/Streams/{Sid}

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Sync Stream resource to update.


Sidtype: stringNot PII
Path Parameter

The SID of the Stream resource to update.


Request body parameters
Ttltype: integerNot PII

How long, in seconds(link takes you to an external page), before the Stream expires and is deleted (time-to-live).

Update a Sync Stream resource

update-a-sync-stream-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_11
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.syncStreams('TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.update({ttl: 1})
_11
.then(sync_stream => console.log(sync_stream.uniqueName));

Output

_14
{
_14
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"created_by": "created_by",
_14
"date_expires": "2015-07-30T21:00:00Z",
_14
"date_created": "2015-07-30T20:00:00Z",
_14
"date_updated": "2015-07-30T20:00:00Z",
_14
"links": {
_14
"messages": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages"
_14
},
_14
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"sid": "TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"unique_name": "unique_name",
_14
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Streams/TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_14
}


Delete a Sync Stream resource

delete-a-sync-stream-resource page anchor
DELETE https://sync.twilio.com/v1/Services/{ServiceSid}/Streams/{Sid}

URI parameters
ServiceSidtype: stringNot PII
Path Parameter

The SID of the Sync Service(link takes you to an external page) with the Sync Stream resource to delete.


Sidtype: stringNot PII
Path Parameter

The SID of the Stream resource to delete.

Delete a Sync Stream resource

delete-a-sync-stream-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.syncStreams('TOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();


Rate this page: