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.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
fromUserId | String | Yes | Sender's user ID of the original message. |
channelType | Number | Yes | Channel type. Supported values: 1 (direct), 3 (group), 4 (open channel), 6 (system), 10 (community). |
channelId | String | Yes | Target ID. Depending on the channelType, this may be a user ID, group ID, open channel ID, community channel ID, or system target ID. |
subchannelId | String | No | Community channel subchannel ID. Only applicable when deleting community channel messages.
|
messageUID | String | Yes | Unique ID of the message to delete. Obtainable via the message routing service (msgUID field) or from [message history logs]. |
sentAt | Number | No | Timestamp (in milliseconds) when the original message was sent. Obtainable via message routing (msgTimestamp field) or from [message history logs] (dateTime field). |
isAdmin | Number | No | Whether the deletion is performed by an admin. Default: 0. When set to 1, a delete notification is displayed indicating an admin performed the deletion. |
isDelete | Number | No | Whether the recipient's client should delete the original message record. Default: 0.
isDelete is 0, mobile clients show a delete notification locally, but Web clients show no record, which may cause inconsistency. |
disablePush | Boolean | No | Whether 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. |
extra | String | No | Custom extension data. Not supported for community channels (channelType 10). |
disableUpdateLastMsg | Boolean | No | Whether to prevent updating the last message in the channel. Only effective for messages stored on the client. |
Request example
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
| Property | Type | Description |
|---|---|---|
code | Number | Status code. 0 indicates success. See status codes. |
Response example
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{"code":0}