Skip to main content
Messages contain the data that a client is communicating, such as the contents of a chat message. Clients publish messages on channels, and these messages are received by clients that have subscribed to them.

Message properties

The following are the properties of a message:

Accessing message properties

When you receive a message, you can access all its properties:

Message data types

The data property of a message can contain different types of data:

String data

JSON objects

Binary data

Message extras

The extras field allows you to include additional metadata with your messages:

Push notification extras

When publishing push notifications, use the extras field to include push-specific data:

Message idempotency

You can provide your own message ID to ensure idempotent publishing. If you publish a message with the same ID twice, only one message will be delivered: This is useful for ensuring messages aren’t duplicated during retries or network issues.

Message encoding

Ably automatically handles encoding and decoding of messages:
  • JSON objects are automatically serialized and deserialized
  • Binary data is properly encoded
  • String data is UTF-8 encoded
The encoding property tells you what transformations were applied to the message data. In most cases, this will be empty as the SDK handles decoding automatically.

Message size limits

Messages have the following size limits:
  • Maximum message size: 65,536 bytes (64 KiB)
  • Messages are counted in 5 KiB chunks for billing purposes

Next steps