Skip to main content

Delete a message

Delete a specific message by sending a delete command message. When mobile clients receive the delete command, the original message is removed and replaced with a delete notification (RC:RcNtf).

The delete command message is stored in message history. When SDKs retrieve history, they receive both the delete command and the original message. Mobile SDKs handle the deletion logic internally, so no additional development is required.

tip

When deleting a message via the server API, the sender's client executes the deletion if online. If the sender's client is offline for an extended period, the deleted message may still appear on the sender's client upon reconnection (recipient-side is unaffected).

Enable the Multi-device message sync service so the sender's SDK handles this automatically on reconnection. See Message management service configuration.

Request

POST: https://[Base URL](/platform-chat-api/base-url)/v4/message/delete

Rate limit: 100 requests per second.

Authentication: All server API requests require signature verification. See API request signing.

Request body

Content type: application/json

ParameterTypeRequiredDescription
fromUserIdStringYesSender's user ID of the original message.
channelTypeNumberYesChannel type. Supported values: 1 (direct), 3 (group), 4 (open channel), 6 (system), 10 (community).
channelIdStringYesTarget ID. Depending on the channelType, this may be a user ID, group ID, open channel ID, community channel ID, or system target ID.
subchannelIdStringNoCommunity channel subchannel ID. Only applicable when deleting community channel messages.
  • If the original message specified a subchannel ID, you must provide the same subchannel ID to delete it.
  • If the original message did not specify a subchannel ID, do not provide one.
messageUIDStringYesUnique ID of the message to delete. Obtainable via the message routing service (msgUID field) or from [message history logs].
sentAtNumberNoTimestamp (in milliseconds) when the original message was sent. Obtainable via message routing (msgTimestamp field) or from [message history logs] (dateTime field).
isAdminNumberNoWhether the deletion is performed by an admin. Default: 0. When set to 1, a delete notification is displayed indicating an admin performed the deletion.
isDeleteNumberNoWhether the recipient's client should delete the original message record. Default: 0.
  • 0: Replace the original message content with a delete notification (gray bar). The original record is preserved.
  • 1: Delete the original message record entirely. No delete notification is displayed.
Note: Deleted community channel messages are not preserved in server-side history. If isDelete is 0, mobile clients show a delete notification locally, but Web clients show no record, which may cause inconsistency.
disablePushBooleanNoWhether to suppress push notifications for the deletion. Default: false. When true, offline users do not receive a delete notification. Not supported for open channels or community channels.
extraStringNoCustom extension data. Not supported for community channels (channelType 10).
disableUpdateLastMsgBooleanNoWhether to prevent updating the last message in the channel. Only effective for messages stored on the client.

Request example

HTTP
POST /v4/message/delete HTTP/1.1
Host: api.sg-light-api.com
App-Key: uwd1c0sxdlx2
Nonce: 14314
Timestamp: 1408710653491
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Content-Type: application/json

{
"fromUserId": "fDR2cVpxxR5zSMUNh3yAwh",
"channelId": "MersNRhaKwJkRV9mJR5JXY",
"channelType": 1,
"messageUID": "5FGT-7VA9-G4DD-4V5P",
"sentAt": 1507778882124
}

Response

PropertyTypeDescription
codeNumberStatus code. 0 indicates success. See status codes.

Response example

HTTP
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{"code":0}