logo
In-app Chat
ZIMAudio
On this page

ImportPeerMsg

POST

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

If you are using another instant messaging service and want to integrate with ZIM, you can call this API to import the user's historical one-to-one messages (in chronological order) to ZIM.

A one-to-one conversation has two users (user A and B). User A may have deleted some messages, resulting in a different message list that user A can see in this conversation compared to user B. Therefore, for the same one-to-one conversation, this API needs to be called separately for users A and B.

Note

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

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
20 times/s

Verify the effect

After successfully importing messages, you can call the ZIM server-side API Query the message list of one-on-one chats to confirm whether the user's one-to-one conversation messages have been imported completely.

Request

Query Parameters

    Action stringrequired

    Possible values: [ImportPeerMsg]

    API prototype parameter

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

    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

    User ID of the message sender.

    ToUserId stringrequired

    Possible values: <= 32 characters

    User ID of the message receiver.

    MessageType numberrequired

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

    Note

    Signaling messages are not supported.

    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.

    Note

    The OfflinePush and HasReceipt fields are not supported.

    SubMsgType number

    Specific custom type. The value is defined by you, with a value range of [0,200]. Required 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.

    SendMessageTime number

    Message sending timestamp (Unix, millisecond level). Please import in chronological order from earliest to latest.

    • Pass 0 or do not pass: Use "current time".
    • Other values: The earliest can be "current time - number of days for historical message retention specified by the package (for details, please refer to Pricing - Version differences) * 86400000", and the latest must not be later than "current time".

    Cannot be earlier than the number of days for historical message retention specified by the package (for details, please refer to Pricing - Version differences), nor later than the current time.

    ImportedUserId stringrequired

    Must be one of FromUserId or ToUserId, representing whose one-to-one conversation message list is being imported.

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
    660400001The input message size exceeds the limit.Please check the input message size.
    Message string

    Description of the request result.

    RequestId string

    Request ID.

    MsgId string

    Message ID.

    MsgSeq number

    Message seq.

Previous

Edit a message

Next

Import a group message

On this page

Back to top