Publish a message to a channel

POST /channels/{channel_id}/messages

Publish a message to the specified channel

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.

  • The connection ID of the publisher of this message.

  • extras object

    Extras object. Currently only allows for push extra.

    Hide extras attribute Show extras attribute object
    • push object
      Hide push attributes Show push attributes object
      • data string
      • Hide notification attributes Show notification attributes object
        • title string

          Title to display at the notification.

        • body string

          Text below title on the expanded notification.

        • icon string

          Platform-specific icon for the notification.

        • sound string

          Platform-specific sound for the notification.

        • Platform-specific, used to group notifications together.

      • apns object

        Extends and overrides generic values when delivering via APNs. See examples

        Hide apns attribute Show apns attribute object
        • Hide notification attributes Show notification attributes object
          • title string

            Title to display at the notification.

          • body string

            Text below title on the expanded notification.

          • icon string

            Platform-specific icon for the notification.

          • sound string

            Platform-specific sound for the notification.

          • Platform-specific, used to group notifications together.

      • fcm object

        Extends and overrides generic values when delivering via GCM/FCM. See examples

        Hide fcm attribute Show fcm attribute object
        • Hide notification attributes Show notification attributes object
          • title string

            Title to display at the notification.

          • body string

            Text below title on the expanded notification.

          • icon string

            Platform-specific icon for the notification.

          • sound string

            Platform-specific sound for the notification.

          • Platform-specific, used to group notifications together.

      • web object

        Extends and overrides generic values when delivering via web. See examples

        Hide web attribute Show web attribute object
        • Hide notification attributes Show notification attributes object
          • title string

            Title to display at the notification.

          • body string

            Text below title on the expanded notification.

          • icon string

            Platform-specific icon for the notification.

          • sound string

            Platform-specific sound for the notification.

          • Platform-specific, used to group notifications together.

Responses

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"
}