Skip to main content

Callback for Modifying Message Content

Function Description

The App business server can use this callback to modify message content, such as replacing non-compliant content or sensitive words.


  • To enable the callback, it is necessary to configure the callback URL and activate the corresponding switch for this callback protocol. Configuration methods can be found in the Callback Explanation document.
  • The direction of the callback is an HTTP/HTTPS POST request initiated by OpenIMServer to the App backend.
  • After receiving the callback request, the App business server must verify whether the command parameter in the request URL is its SDKNAME parameter.
  • The APP business server must respond to this request within the timeout period.

Scenarios That May Trigger This Callback

  • App users send messages through the client.
  • App users send messages through the REST API.
  • App users send group messages through the client.
  • App administrators send group messages through the REST API.

Timing of the Callback

  • Before OpenIMServer delivers the group message to group members.

Interface Description

Request URL Example

In the following example, the callback URL configured by the App is https://callbackurl.


Request Parameter Description

httpsRequest protocol is HTTPS, method is POST
https://callbackurlCallback URL
CallbackCommandFixed value: callbackMsgModifyCommandCommand
contenttypeFixed value: JSON
Header NameExample ValueMandatoryTypeDescription
operationID1646445464564RequiredstringoperationID for global link tracing

Request Packet Example

"sendID": "sender123",
"callbackCommand": "callbackMsgModifyCommandCommand",
"serverMsgID": "serverMsg123",
"clientMsgID": "clientMsg123",
"senderPlatformID": 1,
"senderNickname": "Sender",
"sessionType": 1,
"msgFrom": 1,
"contentType": 1,
"status": 1,
"createTime": 1673048592000,
"content": "Hello, World!",
"seq": 123,
"atUserList": ["user123", "user456"],
"faceURL": "",
"ex": "Extra data"

Request Packet Field Explanation

sendIDstringUnique identifier of the sender
callbackCommandstringCallback command, here for message modification callback
serverMsgIDstringServer-generated message ID
clientMsgIDstringClient-generated message ID
senderPlatformIDint32Sender's platform ID
senderNicknamestringSender's nickname
sessionTypeint32Session type, indicating one-on-one or group chat
msgFromint32Message origin, indicating sent or received
contentTypeint32Content type of the message
statusint32Status of the message
createTimeint64Message creation timestamp (milliseconds)
contentstringContent of the message
sequint32Message sequence number
atUserList[]stringList of group member IDs mentioned
faceURLstringSender's avatar URL
exstringAdditional data field

Response Packet Example

Allow Modification

Allows modification of the message.

"actionCode": 0,
"errCode": 0,
"errMsg": "Success",
"errDlt": "",
"nextCode": 0,
"content": "Modified content",
"recvID": "receiver123",
"groupID": "group123",
"clientMsgID": "clientMsg456",
"serverMsgID": "serverMsg456",
"senderPlatformID": 1,
"senderNickname": "ModifiedSender",
"senderFaceURL": "",
"sessionType": 1,
"msgFrom": 1,
"contentType": 1,
"status": 1,
"options": {
"option1": true,
"option2": false
"offlinePushInfo": {
"title": "Modified Notification",
"content": "Modified Content",
"pushFlag": 1,
"sound": "default",
"badge": 1
"atUserIDList": ["user789", "user101112"],
"msgDataList": [65, 66, 67],
"attachedInfo": "Modified Info",
"ex": "Modified Extra data"

Response Packet Field Explanation

actionCode0Indicates if the business system's callback was executed correctly. 0 means the operation was successful.
errCode5001Custom error code, ranging between 5000-9999. Set when actionCode is not 0; set when nextCode is 1.
errMsg"An error message"Simple error message corresponding to the custom error code.
errDlt"Detailed error information"Detailed error information corresponding to the custom error code.
nextCode1Next step instruction, 1 means to refuse to continue executing, set when actionCode is 0.
contentstringModified message content.
recvIDstringReceiver's user ID.
groupIDstringUnique identifier of the group.
clientMsgIDstringClient-generated message ID.
serverMsgIDstringServer-generated message ID.
senderPlatformIDint32Sender's platform ID.
senderNicknamestringModified sender's nickname.
senderFaceURLstringModified sender's avatar URL.
sessionTypeint32Session type.
msgFromint32Message origin.
contentTypeint32Content type of the message.
statusint32Status of the message.
optionsmap[string]boolModified message options.
offlinePushInfoOfflinePushInfoModified offline push information.
atUserIDList[]stringList of mentioned group member IDs.
msgDataList[]byteModified message data list.
attachedInfostringModified additional information.
exstringModified additional data field.