Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions content/api/rest-sdk/messages.textile

This file was deleted.

99 changes: 99 additions & 0 deletions src/pages/docs/api/rest-sdk/messages.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: Messages
meta_description: "Client Library SDK REST API Reference Message documentation."
meta_keywords: "Ably, Ably REST, API Reference, REST SDK, REST interface, REST API, Message"
redirect_from:
- /docs/api/versions/v1.1/rest-sdk/messages
- /docs/api/versions/v1.0/rest-sdk/messages
- /docs/api/versions/v0.8/rest-sdk/messages
---

A `Message` represents an individual message that is sent to or received from Ably.

### name <a id="name" />

The event name, if provided. <br />_Type: `String`_

### data <a id="data" />

The message payload, if provided.<br />_Type: <If lang="javascript,nodejs,go">`String`, `StringBuffer`, `JSON Object`</If><If lang="java">`String`, `ByteArray`, `JSONObject`, `JSONArray`</If><If lang="csharp">`String`, `byte[]`, `plain C# object that can be serialized to JSON`</If><If lang="ruby">`String`, `Binary` (ASCII-8BIT String), `Hash`, `Array`</If><If lang="python">`String`, `Bytearray`, `Dict`, `List`</If><If lang="php">`String`, `Binary String`, `Associative Array`, `Array`</If><If lang="objc">`NSString *`, `NSData *`, `NSDictionary *`, `NSArray *`</If><If lang="swift">`String`, `NSData`, `Dictionary`, `Array`</If><If lang="flutter">`String`, `Map`, `List`</If>_

### extras <a id="extras" />

Metadata and/or ancillary payloads, if provided. Valid payloads include [`push`](/docs/push/publish#payload), `headers` (a map of strings to strings for arbitrary customer-supplied metadata), [`ephemeral`](/docs/pub-sub/advanced#ephemeral), and [`privileged`](/docs/platform/integrations/webhooks#skipping) objects.<br />_Type: <If lang="javascript,nodejs,flutter,go">`JSON Object`</If><If lang="java">`JSONObject`, `JSONArray`</If><If lang="csharp">plain C# object that can be converted to JSON</If><If lang="ruby">`Hash`, `Array`</If><If lang="python">`Dict`, `List`</If><If lang="swift">`Dictionary`, `Array`</If><If lang="objc">`NSDictionary *`, `NSArray *`</If><If lang="php">`Associative Array`, `Array`</If>_

### id <a id="id" />

A Unique ID assigned by Ably to this message.<br />_Type: `String`_

### clientId <a id="client-id" />

The client ID of the publisher of this message.<br />_Type: `String`_

### connectionId <a id="connection-id" />

The connection ID of the publisher of this message.<br />_Type: `String`_

### connectionKey <a id="connection-key" />

A connection key, which can optionally be included for a REST publish as part of the [publishing on behalf of a realtime client functionality](/docs/pub-sub/advanced#publish-on-behalf).<br />_Type: `String`_

### timestamp <a id="timestamp" />

Timestamp when the message was first received by the Ably, as <If lang="javascript,nodejs,php,flutter,go,python,java,csharp,objc,swift">milliseconds since the epoch</If><If lang="ruby">a `Time` object</If><br />_Type: <If lang="javascript,nodejs,php,flutter,go,python">`Integer`</If><If lang="java">`Long Integer`</If><If lang="csharp">`DateTimeOffset`</If><If lang="ruby">`Time`</If><If lang="objc,swift">`NSDate`</If>_

### encoding <a id="encoding" />

This will typically be empty as all messages received from Ably are automatically decoded client-side using this value. However, if the message encoding cannot be processed, this attribute will contain the remaining transformations not applied to the `data` payload.<br />_Type: `String`_

<If lang="javascript,nodejs">

### action <a id="action" />

The action type of the message, one of the [`MessageAction`](/docs/api/realtime-sdk/types#message-action) enum values.<br />_Type: `int enum { MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETE, META, MESSAGE_SUMMARY }`_

### serial <a id="serial" />

A server-assigned identifier that will be the same in all future updates of this message. It can be used to add annotations to a message. Serial will only be set if you enable annotations in [channel rules](/docs/channels#rules).<br />_Type: `String`_

### annotations <a id="annotations" />

An object containing information about annotations that have been made to the object.<br />_Type: [`MessageAnnotations`](/docs/api/realtime-sdk/types#message-annotations)_

</If>

## Message constructors <a id="constructors" />

### Message.fromEncoded <a id="message-from-encoded" />

`Message.fromEncoded(Object encodedMsg, ChannelOptions channelOptions?) -> Message`

A static factory method to create a [`Message`](/docs/api/realtime-sdk/types#message) from a deserialized `Message`-like object encoded using Ably's wire protocol.

#### Parameters

| Name | Description | Type |
|------|-------------|------|
| encodedMsg | a `Message`-like deserialized object. | `Object` |
| channelOptions | an optional [`ChannelOptions`](/docs/api/realtime-sdk/types#channel-options). If you have an encrypted channel, use this to allow the library can decrypt the data. | `Object` |

#### Returns

A [`Message`](/docs/api/realtime-sdk/types#message) object

### Message.fromEncodedArray <a id="message-from-encoded-array" />

`Message.fromEncodedArray(Object[] encodedMsgs, ChannelOptions channelOptions?) -> Message[]`

A static factory method to create an array of [`Messages`](/docs/api/realtime-sdk/types#message) from an array of deserialized `Message`-like object encoded using Ably's wire protocol.

#### Parameters

| Name | Description | Type |
|------|-------------|------|
| encodedMsgs | an array of `Message`-like deserialized objects. | `Array` |
| channelOptions | an optional [`ChannelOptions`](/docs/api/realtime-sdk/types#channel-options). If you have an encrypted channel, use this to allow the library can decrypt the data. | `Object` |

#### Returns

An `Array` of [`Message`](/docs/api/realtime-sdk/types#message) objects