Send a community channel message
- For apps/environments that enabled the community channel service on or after 2022-10-13: Community channels include a default subchannel with ID
RCDefault. Messages sent without a subchannel ID go to theRCDefaultsubchannel. Client SDKs must pass this subchannel ID when retrieving message history. - For apps/environments that enabled the service before 2022-10-13: Messages sent without a subchannel ID do not belong to any subchannel. Client SDKs can retrieve messages without a subchannel ID. Contact support to migrate to the latest behavior (this affects sending, receiving, history retrieval, muting, and more).
Send a message to one or more community channels. When sent via the server API, the sender also receives the message if online, and the message is stored in the sender's message history.
Community channel messages can be updated after sending. See Update a community channel message.
Request
POST: https://[Base URL](/platform-chat-api/base-url)/v4/community-channel/message/send
Rate limit: 100 community channel messages per second. Per subchannel: 20 messages per second. Without a subchannel: 20 messages per second per community channel. Sending to 3 community channels counts as 3 messages.
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. Non-members can send messages via the server API. The user must have obtained an access token for push notifications to display sender info correctly. |
toChannelIds | String[] | Yes | Target community channel IDs. Up to 3 community channels. |
toUserIds | String[] | No | For targeted community channel messages: recipient member user IDs. Other community channel users do not receive the targeted message. Only effective when toChannelIds contains a single community channel ID. |
messageType | String | Yes | Message type. Accepts a built-in message type or a custom type value. Custom types must not start with RC: and must not exceed 32 characters. Must be registered in the client SDK. |
content | String | Yes | Message content, max 128 KB.
|
pushContent | String | No | Push notification content for offline recipients.
|
pushData | String | No | Custom data in the push payload. On iOS: appData in the APNs payload. On Android: appData. |
shouldPersist | Number | No | Whether to store this message in the cloud message history. 0: do not store. 1 (default): store. Client-side storage:
|
isCounted | Number | No | Whether to count this message as unread for offline users. 0: do not count. 1 (default): count. |
hasMention | Number | No | Whether this is a mention (@) message. Default: 0. Set to 1 and include mentionedInfo in the content field. See How to send a mention message. |
contentAvailable | Number | No | iOS only. Enables silent push (iOS 7+). 1: enable. 0 (default): disable. |
pushExt | Object | No | Push notification configuration (title, template, etc.). See pushExt parameters below. |
subchannelId | String | No | Subchannel ID. The server validates whether this subchannel exists under the community channel and does not deliver the message if it does not exist. Max 20 characters (letters and digits only). |
hasMetadata | Boolean | No | Whether to enable metadata for this message. Default: false. |
metadata | Object | No | Only effective when hasMetadata is true. Custom KV pairs for message metadata. See Message metadata. Keys: max 32 characters. Values: max 4096 characters. Max 100 KV pairs per request, 300 per message. |
pushExt parameters
Configure push notification properties. Pass as an escaped JSON string.
| Parameter | Type | Required | Description |
|---|---|---|---|
title | String | No | Push title, max 50 characters. |
templateId | String | No | Push template ID for multi-language push. |
forceShowPushContent | Number | No | Force display of pushContent. 0 (default): no. 1: force. |
pushConfigs | Array | No | Provider-specific settings. Supported: MI, HONOR, HW, OPPO, VIVO, APNs, FCM. |
pushConfigs.HONOR.importance | String | No | HONOR priority. NORMAL or LOW. |
pushConfigs.HONOR.image | String | No | HONOR large icon URL (HTTPS, max 512 KB). |
pushConfigs.HW.channelId | String | No | Huawei channel ID. |
pushConfigs.HW.importance | String | No | Huawei priority. NORMAL or LOW. |
pushConfigs.HW.image | String | No | Huawei large icon URL (HTTPS, max 512 KB). |
pushConfigs.HW.category | String | No | Huawei message category (uppercase, e.g., IM). |
pushConfigs.MI.channelId | String | No | Xiaomi channel ID. |
pushConfigs.MI.large_icon_uri | String | No | Xiaomi large icon URL (120×120 px, PNG/JPG). |
pushConfigs.OPPO.channelId | String | No | OPPO channel ID. |
pushConfigs.OPPO.category | String | No | OPPO content category. |
pushConfigs.OPPO.notify_level | Number | No | OPPO notification type. 1/2/16. |
pushConfigs.VIVO.classification | Number | No | VIVO category. 0 or 1. |
pushConfigs.APNs.thread-id | String | No | iOS notification group ID. |
pushConfigs.APNs.apns-collapse-id | String | No | iOS collapse ID. iOS 10.0+. |
pushConfigs.APNs.richMediaUri | String | No | iOS large icon URL. iOS 10.0+. |
pushConfigs.APNs.interruption-level | String | No | iOS 15+. Values: passive, active, time-sensitive, critical. |
pushConfigs.FCM.channelId | String | No | FCM channel ID. |
pushConfigs.FCM.collapse_key | String | No | FCM collapse key. |
pushConfigs.FCM.imageUrl | String | No | FCM large icon URL. Max 1 MB. |
pushConfigs.OHOS.category | String | No | HarmonyOS push category (e.g., IM). |
pushConfigs.OHOS.image | String | No | HarmonyOS large icon URL (HTTPS). |
pushConfigs.MEIZU.noticeMsgType | Number | No | Meizu type. 1: private. 2: public. |
pushExt example
{
"title":"you have a new message.",
"templateId":"123456",
"forceShowPushContent":0,
"pushConfigs": [
{
"HW": {
"channelId": "hw-123",
"importance": "NORMAL",
"image":"https://example.com/image.png"
}
},
{
"MI": {
"channelId": "mi-123",
"large_icon_uri":"https://example.com/image.png"
}
},
{
"OPPO": {
"channelId": "oppo-123",
"notify_level": 2,
"category": "IM"
}
},
{
"VIVO" : {"classification": "0"}
},
{
"APNs": {
"thread-id": "123",
"apns-collapse-id":"123456",
"richMediaUri":"https://example.com/image.png"
}
},
{
"FCM": {
"channelId":"rongcloud_channelid",
"collapse_key":"1234",
"imageUrl":"https://example.com/image.png"
}
},
{
"OHOS": {
"category": "IM",
"image":"https://example.com/image.png"
}
},
{
"MEIZU": {
"noticeMsgType": 1
}
}
]
}
Request example
POST /v4/community-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": "why456",
"toChannelIds": ["why66-ultra"],
"messageType": "RC:TxtMsg",
"content": "{\"content\":\"hh0217890\"}",
"shouldPersist": 1,
"hasMention": 0
}
Response
| Property | Type | Description |
|---|---|---|
code | Number | Status code. 0 indicates success. See Server API status codes. |
result | Object | Response data object. |
result.messageUIDs | Array | List of message UIDs. |
result.messageUIDs[i].channelId | String | Community channel ID, corresponding to toChannelIds in the request. |
result.messageUIDs[i].messageUID | String | Unique ID of the message sent to the corresponding community channel. |
Response example
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"code": 0,
"result": {
"messageUIDs": [
{
"channelId": "2191",
"messageUID": "XXXX-JJJJ-KKK-LLLL"
}
]
}
}