Send a broadcast message across chat rooms

Update time: 2023/10/23 07:49:47

You can send broadcast messages across chat room by calling the corresponding Server API. This feature is suitable for sending announcements to participants in all chat rooms. All participants in chat rooms can receive broadcast messages.

Considerations

  • You need to activate the feature for use. To activate the feature, contact the sales manager using the WhatsApp provided on the homepage of CommsEase official website
  • Broadcast messages can only be forwarded online and will not be recorded in the message history.
  • A maximum of 10 messages can be sent per minute across chat rooms.

Request URL

httpPOST https://api.netease.im/nimserver/chatroom/broadcast.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

Request parameters

  • For information about how to set the header in a POST request, see API Call methods.

  • The settings of the body in a POST request:

ParameterTypeRequiredDescription
msgId String Yes Client message ID, using random strings such as uuid, messages with the same msgId will be deduplicated by the client
fromAccid String Yes The accid of a sender
msgType int Yes Message type:
0: Text message,
1: Image message,
2: audio,
3: video,
4: geolocation,
6: file,
10: tip,
100: Custom message. Note that for apps that are not connected to GuardEase content moderation, this type of messages will not be processed by the moderation service.
subType int No Custom message type, greater than 0
resendFlag int No Resent message flag, 0: non-resent message, 1: resent message. Resent messages will be checked for deduplication by msgid
attach String No Text message: message body;
For other types of messages, see Message example
Up to 4,096 characters
ext String No Extension field, custom content in JSON format, up to 4,096 characters.
highPriority Boolean No Optional, true: high-priority messages that are delivered first; false: low-priority messages. The default value is false.
Select proper parameters for your apps so that the delivery of high-priority messages within the application can be guaranteed first. If you set all messages to high priority, no effect takes place. Up to 10 high priority messages per second are allowed in a chat room. The priority of additional messages will be converted to normal. High-priority broadcast messages across chat rooms cannot be resent.
useYidun int No Optional, whether the GuardEase content moderation service is used for a single message, the optional value is 0.
0: Do not use GuardEase content moderation but use generic moderation for messages.

If unspecified, by default, use Content Moderator provided by GuardEase to check the content if the application has enabled the Content Moderator service.
yidunAntiCheating String No Optional, exclusive field for Content Moderation provided by GuardEase, in JSON, up to 1,024 characters (For details, see the GuardEase content moderation API reference)
bid String No Optional, content moderation ID used to implement "a single message using the corresponding moderation configuration", if unspecified, the original moderation configuration will be used
antispam String No Specify whether the message (antispamCustom) must be moderated by the content moderation service for apps that have enabled the content moderation service.
true or false. The default value is false.
Only valid for messages of 100 custom message type.
notifyTargetTags String No Optional, tag expression, up to 128 characters
antispamCustom StringNo The parameter is valid only if the antispam parameter is set to true.
Custom content for moderation in JSON format, the length limit is the same as the body field, and cannot exceed 5,000 characters. The format of antispamCustom:

{"type":1,"data":"custom content"}

Fields:
1. type: 1: text; 2: image.
2. data: Text or image URL.
env String No The environment for data sync. Different endpoints for data sync use different environments.

Example

cURL request

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'fromAccid=zhangsan&msgType=0&attach=This+is+test+msg&msgId=c9e6c306-804f-4ec3-b8f0-573778829419' 'https://api.netease.im/nimserver/chatroom/broadcast.action'

Example success response

json"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "desc":{
    "time": "1456396333115", 
    "fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV84NDU4OF8xNDU1ODczMjA2NzUwX2QzNjkxMjI2LWY2NmQtNDQ3Ni0E2LTg4NGE4MDNmOGIwMQ==",
    "msgid_client": "c9e6c306-804f-4ec3-b8f0-573778829419",
    "fromClientType": "REST",
    "attach": "This+is+test+msg",
    "roomId": "36",
    "fromAccount": "zhangsan",
    "fromNick": "Joe",
    "type": "0",
    "ext": "",
    "highPriorityFlag":1 //High-priority message flag, without this flag means non-high priority
  } 
}

Status codes

The status code is returned in the response body. For more information, see Status codes.

Was this page helpful?
Yes
No
  • Considerations
  • Request URL
  • Request parameters
  • Example
  • cURL request
  • Example success response
  • Status codes