---
title: "Publish a message to a channel"
method: POST
path: "/channels/{channel_id}/messages"
tags: ["Publishing"]
---

# Publish a message to a channel

`POST /channels/{channel_id}/messages`

Publish a message to the specified channel

## Path parameters

- `channel_id` string, required

## Request body

- Message — Message object.
  - `name` string — The event name, if provided.
  - `data` string — The string encoded payload, with the encoding specified below.
  - `id` string — A Unique ID that can be specified by the publisher for [idempotent publishing](https://www.ably.io/documentation/rest/messages#idempotent).
  - `timestamp` integer — Timestamp when the message was received by the Ably, as milliseconds since the epoch.
  - `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](https://www.ably.io/documentation/core-features/authentication#identified-clients) of the publisher of this message.
  - `connectionId` string — The connection ID of the publisher of this message.
  - `extras` Extras — Extras object. Currently only allows for [push](https://www.ably.io/documentation/general/push/publish#channel-broadcast-example) extra.
    - `push` Push
      - `data` string — Arbitrary [key-value string-to-string payload](https://www.ably.io/documentation/general/push/publish#channel-broadcast-example).
      - `notification` Notification
        - `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.
        - `collapseKey` string — Platform-specific, used to group notifications together.
      - `apns` object — Extends and overrides generic values when delivering via APNs. [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure)
        - `notification` Notification
          - `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.
          - `collapseKey` string — Platform-specific, used to group notifications together.
      - `fcm` object — Extends and overrides generic values when delivering via GCM/FCM. [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure)
        - `notification` Notification
          - `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.
          - `collapseKey` string — Platform-specific, used to group notifications together.
      - `web` object — Extends and overrides generic values when delivering via web. [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure)
        - `notification` Notification
          - `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.
          - `collapseKey` string — Platform-specific, used to group notifications together.

## Response `2XX`

OK

- object
  - `channel` string
  - `messageId` string

## Other responses

- `default` — Error

---

[API](https://skmtc.dev/ably/apis/platform-api.md) · [All operations](https://skmtc.dev/ably/apis/platform-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/ably/platform-api/revisions/d9cf7e90bb58/schema)
