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

Stream Message Resource


A Stream Message is a JSON message that can be sent 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.

Stream Message properties

stream-message-properties page anchor
Resource properties
sidtype: SID<TZ>Not PII

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


datatype: objectPII MTL: 0 days

An arbitrary, schema-less object that contains the Stream Message body. Can be up to 4 KiB in length.


Create a Stream Message resource

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

Publishes a new message to the Stream. The message contains an arbitrary JSON object that is serialized and percent-encoded as a POST parameter.

Parameters

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

StreamSidtype: stringNot PII
Path Parameter

The SID of the Sync Stream to create the new Stream Message resource for.


Request body parameters
Datatype: objectPII MTL: 0 days
Required

A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message body. Can be up to 4 KiB in length.

Create a Stream Message resource

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

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

Output

_10
{
_10
"sid": "TZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"data": {}
_10
}


Rate this page: