---
title: "Publish message to channel"
method: POST
path: "/api/realtime/{project_id}/publish"
tags: ["Realtime"]
---

# Publish message to channel

`POST /api/realtime/{project_id}/publish`

## Request

- Base URL: `https://core.blink.new`
- URL: `https://core.blink.new/api/realtime/{project_id}/publish`
- Auth: HTTP bearer

Publish a message to a realtime channel. The message is persisted in a Redis
Stream and immediately broadcast to all active WebSocket subscribers via
Redis Pub/Sub.

Streams are automatically trimmed to 1 000 messages to prevent unbounded
memory growth.

## Path parameters

- `project_id` string, required

## Request body

- RealtimePublishRequest
  - `channel` string, required: Channel name to publish to
  - `type` string, required: Message type identifier
  - `data` unknown, required
  - `userId` string: Optional user ID for the message
  - `metadata` object: Optional metadata for the message

## Response `200`

Message published successfully

- RealtimePublishResponse
  - `messageId` string: Unique identifier for the published message
  - `channel` string: Channel the message was published to
  - `timestamp` integer: Unix timestamp when message was published

## Other responses

- `400`: Validation error
- `401`: Authentication required or invalid API key
- `500`: Internal server error

---

[API](https://skmtc.dev/blink/apis/blink-apis.md) - [All operations](https://skmtc.dev/blink/apis/blink-apis/llms.txt) - [OpenAPI document](https://skmtc.dev/blink/apis/blink-apis/revisions/4c59c706078e?raw)
