Publish a message to a channel
Publish a message to the specified channel
Path parameters
-
channel_id
string Required The Channel's ID.
Body
-
name
string The event name, if provided.
-
data
string The string encoded payload, with the encoding specified below.
-
encoding
string 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.
-
clientId
string The client ID of the publisher of this message.
-
connectionId
string The connection ID of the publisher of this message.
-
extras
object Extras object. Currently only allows for push extra.
POST
/channels/{channel_id}/messages
curl \
-X POST https://rest.ably.io/channels/{channel_id}/messages \
-H "Content-Type: application/json" \
-d '{"name":"string","data":"string","encoding":"string","clientId":"string","connectionId":"string","extras":{"push":{"data":"string","notification":{"title":"string","body":"string","icon":"string","sound":"string","collapseKey":"string"},"apns":{"notification":{"title":"string","body":"string","icon":"string","sound":"string","collapseKey":"string"}},"fcm":{"notification":{"title":"string","body":"string","icon":"string","sound":"string","collapseKey":"string"}},"web":{"notification":{"title":"string","body":"string","icon":"string","sound":"string","collapseKey":"string"}}}}}'
Request example
{
"name": "string",
"data": "string",
"encoding": "string",
"clientId": "string",
"connectionId": "string",
"extras": {
"push": {
"data": "string",
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
},
"apns": {
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
}
},
"fcm": {
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
}
},
"web": {
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
}
}
}
}
}
Request examples
{
"name": "string",
"data": "string",
"encoding": "string",
"clientId": "string",
"connectionId": "string",
"extras": {
"push": {
"data": "string",
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
},
"apns": {
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
}
},
"fcm": {
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
}
},
"web": {
"notification": {
"title": "string",
"body": "string",
"icon": "string",
"sound": "string",
"collapseKey": "string"
}
}
}
}
}
Response examples (2XX)
# Headers
x-ably-serverid: string
# Payload
{
"channel": "string",
"messageId": "string"
}
Response examples (2XX)
# Headers
x-ably-serverid: string
# Payload
{
"channel": "string",
"messageId": "string"
}
Response examples (default)
# Headers
x-ably-errorcode: 42
x-ably-errormessage: string
x-ably-serverid: string
# Payload
{
"message": "string",
"code": 42,
"statusCode": 42,
"href": "string",
"serverId": "string"
}
Response examples (default)
# Headers
x-ably-errorcode: 42
x-ably-errormessage: string
x-ably-serverid: string
# Payload
{
"message": "string",
"code": 42,
"statusCode": 42,
"href": "string",
"serverId": "string"
}