Skip to main content

Send an open channel message

Send a message from a user to one or more open channels.

  • By default, the message is not synced to the sender's client. To enable sync, see the isEchoToSender parameter.
  • You can send to multiple open channels in a single request (recommended max: 10).
tip
  • Users do not need to join an open channel to send messages through this API.
  • To broadcast a message to all open channels in your app, use the Broadcast to all open channels API.

Request

POST: https://[Base URL](/platform-chat-api/base-url)/v4/open-channel/message/send

Rate limit: 100 messages per second. Sending to 10 open channels counts as 10 messages.

Authentication: All server API requests require signature verification. See API request signing.

Request body

Content type: application/json

ParameterTypeRequiredDescription
fromUserIdStringYesSender's user ID.
toChannelIdsString[]YesTarget open channel IDs. You can specify multiple IDs (recommended max: 10).
messageTypeStringYesMessage 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.
contentStringYesMessage content, max 128 KB.
  • Built-in types: Pass the JSON content object serialized as a string. See User content message format.
  • Custom types: The format is flexible and not limited to JSON.
shouldPersistNumberNoWhether to store this message in the cloud message history. 0: do not store. 1 (default): store (requires the Open Channel Cloud Message Storage service).

In most cases, client-side storage does not depend on this parameter:
  1. Built-in types: the client SDK uses the type's own storage flag.
  2. Custom types: the client SDK uses the flag set at registration.
  3. Unregistered types: the client SDK falls back to this parameter, but cannot parse the message.
The client automatically clears local open channel message history when the user exits the open channel.
isEchoToSenderNumberNoWhether to sync the sent message to the sender's client. 1: sync. 0 (default): do not sync. See How to sync sent messages to the sender's client.
priorityNumberNoMessage priority level. Default: 0 (standard priority).
  • 1: Allowlisted message (high delivery guarantee; requires the open channel allowlist feature).
  • 2: High priority.
  • 3: Low priority (dropped first under load; requires the open channel message priority service).

Request example

HTTP
POST /v4/open-channel/message/send HTTP/1.1
Host: api.sg-light-api.com
App-Key: uwd1c0sxdlx2
Timestamp: 1585127132438
Nonce: 14314
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Content-Type: application/json

{
"fromUserId": "2191",
"toChannelIds": ["2192", "2193"],
"messageType": "RC:TxtMsg",
"content": "{\"content\":\"hello\"}"
}

Response

The response body contains a JSON object with the following properties:

PropertyTypeDescription
codeNumberStatus code. 0 indicates success. See Server API status codes.
resultObjectResponse data object.
result.messageUIDsArrayList of message UIDs.
result.messageUIDs[i].channelIdStringOpen channel ID, corresponding to toChannelIds in the request.
result.messageUIDs[i].messageUIDStringUnique ID of the message sent to the corresponding open channel.

Response example

HTTP
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"code": 0,
"result": {
"messageUIDs": [
{
"channelId": "2192",
"messageUID": "XXXX-JJJJ-KKK-LLLL"
},
{
"channelId": "2193",
"messageUID": "XXXX-JJJJ-KKK-LLKL"
}
]
}
}