Message Properties
Optional event name for the message. Used to filter subscriptions.
The message payload. Supported types:
- String
- JSON object or array
- Binary data (Buffer, ArrayBuffer, Uint8Array)
- null
Unique message ID assigned by Ably.
Timestamp when message was received by Ably (milliseconds since epoch).
Client ID of the publisher.
Connection ID of the publisher.
Encoding information for the message data (for example,
json, utf-8, base64).Optional metadata and ancillary payloads:
headers- Custom string-to-string headerspush- Push notification payloadephemeral- Mark message as ephemeralprivileged- Privileged message markers
Message Structure
Example message object:Publishing Messages
Publish messages using the channel’spublish method:
Receiving Messages
Receive messages by subscribing to channels:Message Extras
Custom Headers
Add custom metadata to messages:Push Notifications
Include push notification payload:Ephemeral Messages
Mark messages as ephemeral (not persisted):Message Encoding
Ably automatically encodes and decodes message payloads:- JSON: Objects and arrays are JSON-encoded
- Binary: Binary data is base64-encoded for transport
- UTF-8: Strings are UTF-8 encoded
encoding property indicates the encoding applied.
Batch Publishing
Publish multiple messages atomically: Batch benefits:- Atomic delivery (all or nothing)
- Single rate limit operation
- Combined size limit check
- Better performance
