logo
In-app Chat
On this page

Edit a message


Description

The ZIM server supports developers in editing a message sent in a one-to-one or group conversation.

Upon successful editing of a message, the callback on message sent will be triggered.

Note

By default, only messages sent within the last 24 hours can be edited. For editing older messages, please contact ZEGOCLOUD technical support for configuration.

Request method and endpoint

  • Request method: POST
  • Request endpoint:
    • One-to-one message: https://zim-api.zego.im/?Action=EditC2cMsgBody
    • Group message: https://zim-api.zego.im/?Action=EditGroupMsgBody
  • Transmission protocol: HTTPS
  • QPS limit: 20 times/second.

Request parameters

The following table describes only the method-specific request parameters and some common request parameters. For the complete list of common request parameters, see Accessing Server APIs.

ParameterTypeRequiredDescription
FromUserIdStringYesThe user ID of the message editor.
Note
When editing group messages, this user must be a member of the target group.
SenderIdStringYesThe ID of the message sender.
  • This field is required when editing a one-to-one message.
  • This field is optional when editing a group message.
ConvIdStringYesThe conversation ID.
  • When editing a one-to-one message, fill in the userID of the other participant.
  • When editing a group message, fill in the groupID of the target group.
MsgTypeNumberYesThe message type. Supported values:
  • 1: Text.
  • 10: Combined.
  • 200: Custom.
ConvMsgSeqNumberYesThe message sequence. How to obtain:
  • If you need to edit a one-to-one conversation message sent by the client, retrieve MsgSeq via the Callback on message sent.
  • If you need to edit a one-to-one message sent by the server API Send a one-to-one message, get MsgSeq from the API response data.
  • If you need to edit a group conversation message sent by the server API Send group messages, get MsgSeq from the API response data.
EditTypeNumberYesThe edit type. Supported values:
  • 1: EM_MSG (edit the content of the message), which modifies the Message field in MessageBody; in this case, Message cannot be empty.
  • 2: EM_PAYLOAD (edit the extended content of the message), which modifies the ExtendedData field in MessageBody; in this case, ExtendedData can be empty.
  • 4: EM_AT (edit the reminder attributes of the message), which modifies AtListInfo or IsAtAll; in this case, both AtListInfo and IsAtAll can be empty.
  • 8: EM_AT_ALL (edit whether to remind all users), which modifies IsAtAll.
  • 16: EM_SUBMSGTYPE (edit the type of custom message), which modifies subMsgType; in this case, MsgType must be 200.
You can perform bitwise operations on any of the above values to indicate editing multiple properties of the message simultaneously, e.g., 3: select both EM_MSG and EM_PAYLOAD to modify the Message and ExtendedData fields in MessageBody.
MessageBodyObjectNoRequired when EditType includes EM_MSG or EM_PAYLOAD.
Please refer to the MessageBody Description for the structure of this parameter, including the Message and ExtendedData field descriptions for text messages, combined messages, and custom messages.
AtListInfoObjectNoThe list of users to be mentioned. Required when EditType includes EM_AT.
Please refer to the AtListInfo Description for the structure of this parameter.
IsAtAllBoolNoWhether all users are to be mentioned. Required when EditType includes EM_AT_ALL.
SubMsgTypeNumberNoThe type of custom message defined by you, with a value range of [0, 200]. Required when EditType includes EM_SUBMSGTYPE.

AtListInfo Structure

ParameterTypeDescription
AtListArray of StringThe mentioned user ID list, can be empty.

Request example

  • Request URL:

    Untitled
    https://zim-api.zego.im/?Action=EditGroupMsgBody
    &<Common request parameters>
    
    1
    Copied!
  • Request body:

    Untitled
    {
        "FromUserId": "editer",
        "SenderId": "sender",
        "ConvId": "conv_id_007",
        "MsgType": 200,
        "ConvMsgSeq": 110,
        "EditType": 31,
        "MessageBody": {
            "Message": "edit msg",
            "ExtendedData": "extend data"
        },
        "AtListInfo": {
            "AtList": [
                "userA",
                "userB"
            ]
        },
        "IsAtAll": false,
        "SubMsgType": 101
    }
    
    1
    Copied!

Response parameters

ParameterTypeDescription
CodeNumberReturn code.
MessageStringDescription of the result.
RequestIdStringRequest ID.
StateMsgSeqNumberMessage status sequence.
EditMsgSeqNumberMessage edit sequence.
LatestEditTimeNumberThe Unix timestamp of the last message edit, in seconds (s).

Response example

Untitled
{
    "Code": 0,
    "Message": "success",
    "RequestId": "343649807833778782",
    "StateMsgSeq": 1,
    "EditMsgSeq": 1,
    "LatestEditTime": "173436478"
}
1
Copied!

Return codes

Return CodeDescriptionSuggested Action
660000002Input parameter error.Please check the parameters.
661000001Exceeded editable time.If you need to edit older messages, please contact ZEGOCLOUD technical support.
661000005Edit failed.Please contact ZEGOCLOUD technical support.

Previous

Push a message to all users

Next

Import a one-to-one message