logo
In-app Chat
ZIMAudio
On this page

SendMessageToAllUsers

POST

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

Push message to all users refers to sending messages with specific content, such as text, images, etc., to all online users (including the message sender themselves) and offline users. This feature is suitable for scenarios such as announcements for all users, cross-room gift floating screens, etc.

  • Online users: Users who have logged in to ZIM and whose heartbeat has not timed out.
  • Offline users: Users whose heartbeat has timed out after logging in to ZIM and reporting ZPNsPushId.
Note
  • To use this feature, please activate ZIM Professional or Flagship service.
  • Messages sent through this API will not create conversations and will not be saved.

Message receiving users can only receive broadcast messages through the following ZIM SDK callback interfaces and know which user sent the message.

iOSAndroidmacOSWindows
broadcastMessageReceivedonBroadcastMessageReceivedbroadcastMessageReceivedonBroadcastMessageReceived
WebMini ProgramFlutterReact Native
broadcastMessageReceivedbroadcastMessageReceivedonBroadcastMessageReceivedbroadcastMessageReceived
uni-app | uni-app xHarmonyOS
broadcastMessageReceivedbroadcastMessageReceived
Note

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

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.

The message receiver's SDK version must be 2.10.0 or above to receive broadcast messages.

QPS Limit
1 time/s, limited to 100 times within 24 hours. If you need to adjust, please contact ZEGOCLOUD Technical Support.

Request

Query Parameters

    Action stringrequired

    Possible values: [SendMessageToAllUsers]

    API prototype parameter

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

    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).

    MessageType numberrequired

    Message type. For applicable types for broadcast messages, please refer to MessageBody description.

    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.

    PushType number

    Push type:

    • 0: Online push to online users.
    • 1: Online push to online users, offline push to offline users.
    • 2: Offline push to all users who have reported ZPNsPushId.

Responses

OK
Schema
    Code number

    Return code.

    Note

    When you initiate a request to send messages to multiple users simultaneously:

    • If you only need to successfully send messages to 1 or more users, Code will return 0, indicating success. In this case, please refer to the specific information in ErrorList to confirm the operation result and understand whether sending messages to some users failed.
    • If sending messages to all users fails, Code will return the relevant return code. For details, please refer to Return codes.

    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
    660000002Input parameter error。Please check the input parameters。
    660400001The input message size exceeds the limit。Please check the input message size。
    660500002Message sender has not logged in to the SDK。Please log in to ZIM SDK before sending messages。
    660500003The frequency of calling the SendMessageToAllUsers API exceeds the limit。Please try again later。
    Message string

    Description of the request result.

    RequestId string

    Request ID.

Previous

Recall a room message

Next

Edit a message

On this page

Back to top