Skip to main content
Messages represent the data payloads sent and received on Ably channels. Each message contains the message data, metadata, and optional event name.

Message Properties

name
string
Optional event name for the message. Used to filter subscriptions.
data
any
The message payload. Supported types:
  • String
  • JSON object or array
  • Binary data (Buffer, ArrayBuffer, Uint8Array)
  • null
id
string
Unique message ID assigned by Ably.
timestamp
integer
Timestamp when message was received by Ably (milliseconds since epoch).
clientId
string
Client ID of the publisher.
connectionId
string
Connection ID of the publisher.
encoding
string
Encoding information for the message data (for example, json, utf-8, base64).
extras
object
Optional metadata and ancillary payloads:
  • headers - Custom string-to-string headers
  • push - Push notification payload
  • ephemeral - Mark message as ephemeral
  • privileged - Privileged message markers

Message Structure

Example message object:

Publishing Messages

Publish messages using the channel’s publish 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
The 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

Message Size Limits

Default message size limit: 64 KB Custom limits available for enterprise accounts. Configure in SDK:

Message History

Retrieve message history: See Channels API for full history options.

Build docs developers (and LLMs) love