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.
Property nameTypeRequiredDescriptionChild properties
The unique string that we created to identify the Stream Message resource.
Pattern:
^TZ[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
An arbitrary, schema-less object that contains the Stream Message body. Can be up to 4 KiB in length.
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.
Property nameTypeRequiredPIIDescription
The SID of the Sync Stream to create the new Stream Message resource for.
Encoding type:
application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createStreamMessage() {11const streamMessage = await client.sync.v112.services("ServiceSid")13.syncStreams("StreamSid")14.streamMessages.create({ data: {} });1516console.log(streamMessage.sid);17}1819createStreamMessage();
Response
1{2"sid": "TZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"data": {}4}