---
title: "Subscribe to channel messages"
method: POST
path: "/channel/{channelId}/subscribe"
tags: ["Channel"]
---

# Subscribe to channel messages

`POST /channel/{channelId}/subscribe`

## Request

- Base URL: `https://api.chatbotkit.com/api/v1`
- URL: `https://api.chatbotkit.com/api/v1/channel/{channelId}/subscribe`
- Auth: HTTP bearer

Subscribe to a channel to receive real-time messages published to it.
This endpoint returns a streaming response that will continuously send
message events as they are published to the channel via the publish
endpoint. The connection remains open until the client closes it or
an error occurs.

## Path parameters

- `channelId` string, required: The ID of the channel to subscribe to (minimum 16 characters)

## Request body

- object
  - `historyLength` integer: Number of historical messages to replay from the channel before subscribing to live updates. When provided, the subscriber will first receive up to this many recent messages that were published before the subscription started. This is useful for catching up on messages that may have been published during connection setup.

## Response `200`

Successfully subscribed to channel messages

## Other responses

- `default`: An error response

---

[API](https://skmtc.dev/chatbotkit/apis/cbk-api.md) · [All operations](https://skmtc.dev/chatbotkit/apis/cbk-api/llms.txt) · [OpenAPI document](https://skmtc.dev/chatbotkit/apis/cbk-api/revisions/13d250576136?raw)
