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
Property nameTypePIIDescription
sidSID<TZ>
Not PII

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

Pattern: ^TZ[0-9a-fA-F]{32}$Min length: 34Max length: 34

dataobject
PII 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.

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

The SID of the Sync Service to create the new Stream Message in.


StreamSidstringrequired

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

Property nameTypeRequiredPIIDescription
Dataobjectrequired

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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function createStreamMessage() {
_19
const streamMessage = await client.sync.v1
_19
.services("ServiceSid")
_19
.syncStreams("StreamSid")
_19
.streamMessages.create({ data: {} });
_19
_19
console.log(streamMessage.sid);
_19
}
_19
_19
createStreamMessage();

Output

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


Rate this page: