logo
In-app Chat
ZIMAudio
On this page

SendRoomMessage

POST

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

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

The client will receive message notifications in the room 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
roomMessageReceivedonRoomMessageReceivedroomMessageReceivedonRoomMessageReceived
WebMini ProgramFlutterReact Native
roomMessageReceivedroomMessageReceivedonRoomMessageReceivedroomMessageReceived
Unity3Duni-app | uni-app xHarmonyOS
onReceiveRoomMessageroomMessageReceivedroomMessageReceived
Note

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

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. If you need to adjust, please contact ZEGOCLOUD sales to understand the specific billing rules.

Request

Query Parameters

    Action stringrequired

    Possible values: [SendRoomMessage]

    API prototype parameter

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

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

    RoomId stringrequired

    Possible values: <= 32 characters

    Room ID.

    MessageType numberrequired

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

    Priority numberrequired

    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.

    SenderUnaware number

    When sending messages through this server-side API, whether the client corresponding to FromUserId in the request parameters can perceive this sending:

    • 0: Can perceive.
    • 1: (Default) Cannot perceive.

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.
    660300001The input RoomId does not exist.Please confirm if the input RoomId is correct.
    660300013Room messages do not support receipts.Please delete the "HasReceipt" field in the request message body.
    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.
    Message string

    Description of the request result.

    RequestId string

    Request 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 group message

Next

Recall a one-to-one message

On this page

Back to top