Delete a chat message. Users can delete messages only in the following cases:
- The Allow Message Deleting setting is enabled in the workspace's Message settings.
- If the Block Message Deleting After (n) Minutes message setting has a non-zero value, the
bypass-time-limit-edit-and-deletepermission is required to delete messages after the defined time limit. - In read-only rooms, the
post-readonlypermission is required to delete messages, or the user must be unmuted. - The
delete-own-messagepermission is required to delete users' own messages. - The
delete-messagepermission is required for users to delete messages from other users.
You can delete a message by its roomId and msgId, or delete a message by its fileId to remove the message that holds an uploaded file.
Changelog
| Version | Description |
|---|---|
| 8.6.0 | Added fileId to delete a message by the file it contains. |
| 0.48.0 | Added |
The authToken of the authenticated user.
The userId of the authenticated user.
{
"roomId": "ByehQjC44FwMeiLbX",
"msgId": "7aDSXtjMA3KPLxLjt",
"asUser": false
}{
"fileId": "9aFcj4XmgQ7eYpLbT"
}Provide either roomId and msgId together, or fileId on its own.
The room ID. Required when deleting by msgId.
The ID of the message to delete. Required together with roomId.
The ID of the uploaded file whose message you want to delete. Use this instead of roomId and msgId to delete the message that contains the file.
Should the message be deleted as the user who sent it? It is false by default.
OK
{
"_id": "jEnjsxuoDJamGjbH2",
"ts": "1696533809813",
"message": {
"_id": "jEnjsxuoDJamGjbH2",
"rid": "6GFJ3tbmHiyHbahmC",
"u": {
"_id": "5fRTXMt7DMJbpPJfh",
"username": "test.test",
"name": "Testtest"
}
},
"success": true
}Bad Request
{
"success": false,
"error": "No message found with the id of \\\"MvHcX2WKSrmdArmktz\\\"."
}Unauthorized
{
"status": "error",
"message": "You must be logged in to do this."
}