logo
In-app Chat
ZIMAudio
On this page

SendGroupMessage

POST

https://zim-api.zego.im/

Send group messages and push them to all online users in the group.

The client will receive group message notifications through the ZIM SDK callback interface.

Note
After enabling the content moderation feature, messages sent by the server will be moderated by default. If messages sent by the server do not need to be moderated, please contact ZEGOCLOUD Technical Support for configuration.
iOSAndroidmacOSWindows
groupMessageReceivedonGroupMessageReceivedgroupMessageReceivedonGroupMessageReceived
WebMini ProgramFlutterReact Native
groupMessageReceivedgroupMessageReceivedonGroupMessageReceivedgroupMessageReceived
Unity3Duni-app | uni-app xHarmonyOS
onReceiveGroupMessagegroupMessageReceivedgroupMessageReceived
Note

The parameters FromUserId and GroupId only support numbers, English characters, and '!','#','$','%','&','(',')','+','-',':',';','<','=','.','>','?','@','[',']','^','_',' ','{','}','|','~'.

Note

If the sender's SDK version (for version information, please refer to Release notes) is lower than 2.0.0, the ZIM server only supports Command type messages with MessageType of 2, and does not support other types.
To provide developers with a better experience, ZEGOCLOUD recommends that developers use the latest version of the SDK.

If the sender requests to send a text message with MessageType 1, the sender's corresponding client (SDK version needs to be 2.7.0 or above) will also receive the message.

For sending and receiving custom messages with MessageType 200, the SDK version of the sender's and receiver's corresponding clients needs to be 2.8.0 or above.

If the receiver's SDK version is in the [2.0.0, 2.8.0) range, they can receive custom messages, but the message type will be displayed as unknown and the message content cannot be obtained. To obtain this message, please upgrade the SDK to version 2.8.0 or above.

If the receiver's SDK version is 1.x.x, they will not be able to receive custom messages, nor will they receive unknown messages.

QPS Limit
10 times/s

Request

Query Parameters

    Action stringrequired

    Possible values: [SendGroupMessage]

    API prototype parameter

    https://zim-api.zego.im/?Action=SendGroupMessage

    AppId uint32required

    💡Public parameter. Application ID, assigned by ZEGOCLOUD. Get it from the ZEGOCLOUD Admin Console.

    SignatureNonce stringrequired

    💡Public parameter. A 16-character hexadecimal random string (hex encoding of 8-byte random number). Refer to Signature example for how to generate.

    Timestamp int64required

    💡Public parameter. Current Unix timestamp, in seconds. Refer to Signature example for how to generate, with a maximum error of 10 minutes.

    SignatureVersion stringrequired

    Possible values: [2.0]

    Default value: 2.0

    💡Public parameter. Signature version number.

    Signature stringrequired

    💡Public parameter. Signature, used to verify the legitimacy of the request. Refer to Signing the requests for how to generate an API request signature.

Body

required
    FromUserId stringrequired

    Possible values: <= 32 characters

    Sender's user ID (who has logged in to the ZIM service by calling the login method on the client, or has completed registration by calling the server-side API).

    GroupId stringrequired

    Possible values: <= 32 characters

    Group ID.

    MessageType int32required

    Message type. For applicable types for group conversations, please refer to MessageBody description.

    Priority int32required

    Possible values: [1, 2, 3]

    Message priority (for details, please refer to Basic concepts - Message priority). Values are as follows:

    • 1: Low.
    • 2: Medium.
    • 3: High.
    MessageBody objectrequired

    Message content. For specific parameter format, please refer to MessageBody description.

    SubMsgType number

    Specific custom type. The value is defined by the developer, with a value range of [0,200]. This parameter only needs to be assigned when MessageType is a custom message.

    SearchedContent string

    Search field for custom messages. This field can only be filled in when MessageType is a custom message, with a default maximum length of 64 bytes. This field applies to the client. Unless this field is filled in, the associated custom message cannot be searched through the client.

    SendMsgOptions object
    Optional configuration items.
    NoUnread boolean

    Whether this message will increase the receiver's unread message count.

    • false: (Default) Yes.
    • true: No.
    TargetOption object

    Configuration items for group targeted messages.

    Note

    If the TargetOption parameter is configured, this message will not be counted in the unread count regardless of whether NoUnread is set to false or true.

    ReceiverUserIds string[]

    User ID list.

    Inclusive boolean

    Target type.

    • false: (Default) Reverse targeting, i.e., users listed in ReceiverUserIds will not receive this message.
    • true: Forward targeting, i.e., only users listed in ReceiverUserIds will receive this message.

Responses

OK
Schema
    Code number

    Return code.

    The following only lists the return codes related to the API business logic. For the complete return codes, please refer to Return codes.

    Return codeDescriptionSuggested Solution
    660000025After passing 1 for IsBase64 in MessageBody, sending base64-encoded signaling messages failed. Please confirm:
    • Please confirm whether IsBase64 needs to be 1, i.e., whether binary type signaling messages need to be sent.
    • Please confirm whether the message content is base64 encoded.
    660400001The input message size exceeds the limit.Please check the input message size.
    660500002Message sender has not logged in to the SDK.Please have the user log in first before sending messages.
    660600001The input GroupId does not exist.Please confirm if the input GroupId is correct.
    Message string

    Description of the request result.

    RequestId string

    Request ID.

    MsgSeq number

    Message Seq. When the message type is a signaling message, this field is empty. Can be used for Recall a group message.

    MsgId number

    Message ID.

    AuditInfos object[]
    Audit structure array. When the array is not empty, it indicates that there are messages that failed the audit, and you can view the reason for the audit failure through this structure.
  • Array[
  • Index number

    This parameter may have the following situations:

    • When you have enabled the ZIM content moderation service and have not rejected the message through the message not sent yet callback:
      • For combined messages, this parameter indicates the index of the Item that failed the audit in the combined message, starting from 0.
      • For other types of messages, this parameter is always 0.
    • When you reject this message after receiving the message not sent yet callback, this parameter is always 0 regardless of the message type.
    Reason string

    Rejection reason.

  • ]

Previous

Send a one-to-one message

Next

Send a room message

On this page

Back to top