Broadcast to all open channels
Broadcast a message to all open channels in your app. Only users currently in an open channel receive the message — users who join later do not receive it.
- Open channel broadcast messages cannot be stored in the server-side open channel message history (Open Channel Cloud Message Storage).
- Open channel broadcast messages do not keep open channels alive.
- By default, the message is not synced to the sender's client. To enable sync, see the
isEchoToSenderparameter.
Prerequisites
Enable the Open Channel Broadcast Message service for the current App Key before using this API. See Message management service configuration.
If the service is not enabled, the API returns error 1009. Repeated requests exceeding the rate limit while the service is disabled return HTTP 429 Too Many Requests (error code 1008).
Request
POST: https://[Base URL](/platform-chat-api/base-url)/v4/open-channel/message/broadcast
Rate limit: 1 request per second.
Authentication: All server API requests require signature verification. See API request signing.
Request body
Content type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
fromUserId | String | Yes | Sender's user ID. |
messageType | String | Yes | Message type. Accepts a built-in message type or a custom message type value. Custom types must not start with RC: and must not exceed 32 characters. The custom type must be registered in the client SDK. |
content | String | Yes | Message content, max 128 KB.
|
isEchoToSender | Number | No | Whether to sync the sent message to the sender's client. 1: sync (only works when the sender is online). 0 (default): do not sync. See How to sync sent messages to the sender's client. |
Request example
HTTP
POST /v4/open-channel/message/broadcast HTTP/1.1
Host: api.sg-light-api.com
App-Key: uwd1c0sxdlx2
Timestamp: 1585127132438
Nonce: 14314
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Content-Type: application/json
{
"fromUserId": "2191",
"messageType": "RC:TxtMsg",
"content": "{\"content\":\"hello\"}",
"isEchoToSender": 1
}
Response
| Property | Type | Description |
|---|---|---|
code | Number | Status code. 0 indicates success. See Server API status codes. |
Response example
HTTP
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{"code": 0}