Skip to main content

Send a community channel message

tip
  • 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 the RCDefault subchannel. 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

ParameterTypeRequiredDescription
fromUserIdStringYesSender'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.
toChannelIdsString[]YesTarget community channel IDs. Up to 3 community channels.
toUserIdsString[]NoFor 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.
messageTypeStringYesMessage 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.
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.
pushContentStringNoPush notification content for offline recipients.
  • For user content types, optional — the server uses a default push message.
  • For notification/signal types (except recall command), required for push notifications.
  • For custom types needing push, required.
  • For custom types not needing push, leave empty.
pushDataStringNoCustom data in the push payload. On iOS: appData in the APNs payload. On Android: appData.
shouldPersistNumberNoWhether to store this message in the cloud message history. 0: do not store. 1 (default): store. Client-side storage:
  1. Built-in types: determined by the type's storage flag.
  2. Registered custom types: determined by the registration flag.
  3. Unregistered types: falls back to this parameter, but the client cannot parse the message.
isCountedNumberNoWhether to count this message as unread for offline users. 0: do not count. 1 (default): count.
hasMentionNumberNoWhether this is a mention (@) message. Default: 0. Set to 1 and include mentionedInfo in the content field. See How to send a mention message.
contentAvailableNumberNoiOS only. Enables silent push (iOS 7+). 1: enable. 0 (default): disable.
pushExtObjectNoPush notification configuration (title, template, etc.). See pushExt parameters below.
subchannelIdStringNoSubchannel 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).
hasMetadataBooleanNoWhether to enable metadata for this message. Default: false.
metadataObjectNoOnly 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.

ParameterTypeRequiredDescription
titleStringNoPush title, max 50 characters.
templateIdStringNoPush template ID for multi-language push.
forceShowPushContentNumberNoForce display of pushContent. 0 (default): no. 1: force.
pushConfigsArrayNoProvider-specific settings. Supported: MI, HONOR, HW, OPPO, VIVO, APNs, FCM.
pushConfigs.HONOR.importanceStringNoHONOR priority. NORMAL or LOW.
pushConfigs.HONOR.imageStringNoHONOR large icon URL (HTTPS, max 512 KB).
pushConfigs.HW.channelIdStringNoHuawei channel ID.
pushConfigs.HW.importanceStringNoHuawei priority. NORMAL or LOW.
pushConfigs.HW.imageStringNoHuawei large icon URL (HTTPS, max 512 KB).
pushConfigs.HW.categoryStringNoHuawei message category (uppercase, e.g., IM).
pushConfigs.MI.channelIdStringNoXiaomi channel ID.
pushConfigs.MI.large_icon_uriStringNoXiaomi large icon URL (120×120 px, PNG/JPG).
pushConfigs.OPPO.channelIdStringNoOPPO channel ID.
pushConfigs.OPPO.categoryStringNoOPPO content category.
pushConfigs.OPPO.notify_levelNumberNoOPPO notification type. 1/2/16.
pushConfigs.VIVO.classificationNumberNoVIVO category. 0 or 1.
pushConfigs.APNs.thread-idStringNoiOS notification group ID.
pushConfigs.APNs.apns-collapse-idStringNoiOS collapse ID. iOS 10.0+.
pushConfigs.APNs.richMediaUriStringNoiOS large icon URL. iOS 10.0+.
pushConfigs.APNs.interruption-levelStringNoiOS 15+. Values: passive, active, time-sensitive, critical.
pushConfigs.FCM.channelIdStringNoFCM channel ID.
pushConfigs.FCM.collapse_keyStringNoFCM collapse key.
pushConfigs.FCM.imageUrlStringNoFCM large icon URL. Max 1 MB.
pushConfigs.OHOS.categoryStringNoHarmonyOS push category (e.g., IM).
pushConfigs.OHOS.imageStringNoHarmonyOS large icon URL (HTTPS).
pushConfigs.MEIZU.noticeMsgTypeNumberNoMeizu type. 1: private. 2: public.

pushExt example

JSON
{
"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

HTTP
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

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

Response example

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

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