Send multiple directional messages

Update time: 2023/10/23 08:43:29

Send multiple directional messages at once in a chat room


Users can send messages to specified members in the chat room. Message types, such as text, image, audio, video, location, files, alert, and custom messages are supported.

  • This API can send or resend multiple messages at once by setting resendFlag. For details, see the description of this parameter in Request Parameters below.
  • Saving directional messages in message history is not supported.

Request URI

httpPOST  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:

ParameterType RequiredDescription
roomid Long YesChat room ID
msgList String Yes The list of messages to be sent, JSONArray, up to 10 messages can be sent at once. The fields of each message:
  • msgId: Message ID, String, required
  • msgType: Message type, Integer, required
    0: Text message, 1: Image message, 2: Audio message, 3: Video message, 4: Location message, 6: File message, 10: Alert, 100: Custom messageFor applications that are not integrated to the GuardEase moderation service, the custom message will not be forwarded for review
  • attach: message body, String, The format is the same as the `body` field in message format example, with a maximum length of 4096 characters.
  • ext: extension field, String, custom content, JSON, up to 4096 characters
  • subType: custom message subtype, Integer, a value greater than 0
  • >
  • resendFlag: the flag for resending a message, Integer
    0: non-resent message, 1: resent message. If the message is resent, the logic for removing duplicates will be applied according to `msgId`
[{"attach":"oadsjfadhsfis89d","ext":"fidsuf9a8dhsigsfdj","msgId":"adfdas8fua8d9g","msgType":0,"subType": 1,"resendFlag" :0}]
fromAccid String Yesuser account sending the message, accid
toAccids String YesList of recipient accids, JSONArray, up to 100 accounts.
route IntegerNoWhether the message is synced using webhooks
0: No; 1: Yes (default)< /td>
useYidun Integer No Whether a message (including custom messages) uses GuardEase moderation service. Set the value to 0. Any other values indicate that the value is unspecified.
0: indicates that the message is not audited by the GuardEase moderation service when the moderation service is activated.
If you do not specify this field, the message will be forwarded to GuardEase moderation service for review by default when the service is activated.
yidunAntiCheating String No The parameter for anti-cheating detection transferred in pass-through mode to GuardEase, JSON, with a maximum length of 1024 characters, (For details, please see GuardEase anti-spam exclusive field)
yidunAntiSpamExt String No The parameter for anti-spam enhanced transferred in pass-through mode to GuardEase, JSON, with a maximum length of 1024 characters, (for details, see GuardEase moderation service custom extension field)
bid String No Custom business ID of GuardEase moderation service. Custom moderation allows you to review the content of a single message in addition to the default moderation service. To configure custom moderation rules, contact our technical support using WhatsApp or online support for help.
antispam Boolean No For applications that have activated GuardEase moderation service, whether the message are reviewed by GuardEase (antispamCustom), default value:false
Only valid for custom messages (message type: 100)
antispamCustom StringNo Custom moderation rules. Valid when the `antispam` parameter is set to `true`, JSON, length limit is the same as the body field. The maximum length is 5000 characters, the required antispamCustom format is as follows:
{"type":1,"data":"custom content"}
Field description:
1. type: 1: text; 2: image; 3: video
2. data: Text or image URL
env String NoThe environment name specified in the CommsEase console sync webhooks as shown in the figure below. A maximum of 32 characters are allowed.

Response fields

code IntegerResponse status code
fail StringMessage delivery failure description, JSONArray, returned in the format of "Client message ID: reason for failure"
success StringDetails of the successful delivery description, JSONArray, returned in the format of "Client Message ID: Successful delivery details", For details of each successfully sent message, please refer to the above Response fields


Example request (cURL)

curlcurl -X POST -H "CheckSum: 18f5435a7bf28***8797f75265495034" -H "AppKey: fe41664****7ad2547" -H "Nonce: 12345" -H "CurTime: 1508481877" -H "Content-Type: application/x-www-form-urlencoded" -H "Cache-Control: no-cache" -d 'roomid=765788&msgList=[{"attach":"oadsjfadhsfis89d","ext":"fidsuf9a8dhsigsfdj","msgId":"adfdas8fua8d9g","msgType":0,"resendFlag":0}]&fromAccid=fromAccid&toAccids=["accid1","accid2"]' ''

Example success response

json"Content-Type": "application/json; charset=utf-8"
  "fail": [
      "57gadfgsdhlaisfjlaskdmfa": "parameter resendFlag should be used for RESEND!"
  "code": 200,
  "success": [
      "gsfdgs45hd15h1s56safda": {
        "ext": "fadsfag80ad7fg98s9giapo[ga",
        "fromNick": "yx2",
        "msgid_client": "gsfdgs45hd15h1s56safda",
        "fromAccount": "yx2",
        "fromClientType": "REST",
        "attach": "afsdfaf807sadf98asdfl;ajskdflasd",
        "time": "1668566975724",
        "type": "2",
        "highPriorityFlag": "1",
        "roomId": "72"
      "akdsuhfaiuofyai7syfhakjds": {
        "ext": "fadsfag80ad7fg98s9giapo[ga",
        "fromNick": "yx2",
        "msgid_client": "akdsuhfaiuofyai7syfhakjds",
        "fromAccount": "yx2",
        "fromClientType": "REST",
        "attach": "",
        "time": "1668566975825",
        "type": "1",
        "highPriorityFlag": "1",
        "roomId": "72"

Example error response

json"Content-Type": "application/json; charset=utf-8"
    "desc":"msgContents size exceeded" //Message body exceeded the size limit.

Status codes

The following status codes are related to responses of this API. For the complete error codes, see Status codes.

Code Description Recommendation
200 Success -
414 Parameter error Check the format and restrictions of arguments based on the error message
403 Illegal operation Exceptions, such as invalid chat room name, hit moderation rules or without the chat room permission.
419 Limit of chat rooms exceeded. -
13009 The scheduled closing of chat rooms is disabled Enable the scheduled closing function in the CommsEase console.
Was this page helpful?
  • Overview
  • Request URI
  • Request parameters
  • Response fields
  • Example
  • Example request (cURL)
  • Example success response
  • Example error response
  • Status codes