Menu

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Sync REST: Message Streams

A Message 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 only be published and not 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.

Properties

Each Message Stream resource has the following properties. Unique name attribute is optional and allowed to be null.

account_sid
sid<AC> Not PII

The unique SID identifier of the Twilio Account.

created_by

The identity of the Stream 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'.

date_created
date_time<iso8601> Not PII

The date this Message Stream was created, given in UTC ISO 8601 format.

date_expires
date_time<iso8601> Not PII

Contains the date this Message Stream expires and gets deleted automatically. Contains null if the Stream persists permanently.

date_updated
date_time<iso8601> Not PII

Specifies the date this Message Stream was last updated, given in UTC ISO 8601 format.

links
uri_map Not PII

A dictionary of URL links to nested resources of this Stream.

service_sid
sid<IS> Not PII

The unique SID identifier of the Service Instance that hosts this Message Stream.

sid
sid<TO> Not PII

The unique 34-character SID identifier of the Message Stream.

unique_name

The unique and addressable name of this Message Stream. Optional, up to 256 characters long.

url
url Not PII

The absolute URL for this Message Stream.

Example

{
  "account_sid": "ACxx",
  "service_sid": "ISxx",
  "sid": "TOxx",
  "unique_name": "MyStream",
  "date_created": "2015-11-24T22:18:57Z",
  "date_updated": "2015-11-24T22:18:57Z",
  "date_expires": null,
  "created_by": "system",
  "url": "https://sync.twilio.com/v1/Services/ISxx/Streams/TOxx",
  "links": {
    "messages": "https://sync.twilio.com/v1/Services/ISxx/Streams/TOxx/Messages"
  }
}

Actions


List All Message Streams

GET /v1/Services/ISxx/Streams

Retrieve a list of all Message Streams belonging to the Service Instance.

Note: By default, this will return the first 50 Message Streams. Supply a PageSize parameter to fetch up to 100 items at once. See paging for more information.

Example

Loading Code Sample...
      
      
          
          
          
          
        

      Create a Message Stream

      POST /v1/Services/ISxx/Streams
      

      Create a new Message Stream in the Service Instance, optionally giving it a unique name and expiration deadline.

      Parameters

      Ttl
      Optional
      post integer Not PII

      Time-to-live of this Stream in seconds, defaults to no expiration. In the range [1, 31 536 000 (1 year)], or 0 for infinity.

      UniqueName
      Optional
      post string Not PII

      The unique and addressable name of this Stream. Optional, up to 256 characters long.

      Loading Code Sample...
          
          
              
              
              
              
            

          Retrieve a Message Stream

          GET /v1/Services/ISxx/Streams/TOxx|UniqueName
          

          Fetch information about a specific Message Stream by its SID or unique name

          Example.

          Loading Code Sample...
              
              
                  
                  
                  
                  
                

              Publish Message to Stream

              POST /v1/Services/ISxx/Streams/TOxx|UniqueName/Messages
              

              Publish a new message to the Message Stream. The message contains an arbitrary JSON object, serialized and percent-encoded for POST parameter submission.

              Parameters

              Data
              Required
              post object Not PII

              The body of the Stream Message. Arbitrary JSON object, maximum size 4KB.

              Loading Code Sample...
                  
                  
                      
                      
                      
                      
                    

                  Update a Message Stream

                  POST /v1/Services/ISxx/Streams/TOxx|UniqueName
                  

                  Update the Message Stream expiration deadline, addressed by its SID or unique name.

                  Parameters

                  Ttl
                  Optional
                  post integer Not PII

                  New time-to-live of this Stream in seconds. In the range [1, 31 536 000 (1 year)], or 0 for infinity.

                  Loading Code Sample...
                      
                      
                          
                          
                          
                          
                        

                      Delete a Message Stream

                      DELETE /v1/Services/ISxx/Streams/TOxx|UniqueName
                      

                      Permanently delete a specific Message Stream from current Service Instance, addressed by SID or unique name.

                      Example

                      Loading Code Sample...
                          
                          
                              
                              
                              
                              
                            

                          Need some help?

                          We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

                          Loading Code Sample...