Skip to content

Delete messages

A user can delete messages they sent in a DM or group chat. In a group chat, a super admin can also delete another member’s message. The content type must be deletable.

When a user deletes a message, a DeleteMessage content type containing the target message ID is sent to the conversation. Each installation, the sender’s included, validates the deletion when it processes it from the conversation. It then marks the target as deleted and removes its content from the local database. An archive carries the mark, so a restore does not bring the content back.

When you query messages, the client automatically:

  • Replaces deleted messages with a placeholder that indicates whether the sender or a super admin deleted it
  • Filters out the DeleteMessage content type from message lists

The deletion mechanism does NOT remove the original message from:

  • The backend
  • Copies an app already received or exported
  • Freed pages of the local database file
Cannot be deletedReason
Membership changes and group updatesThey are the group transcript
Leave requestsThey are the group transcript
ReactionsQueries hide them when their target is deleted
Read receiptsThey have no content to remove
Actions and intentsThey are not user-authored content
A deletionRemoving it would hide the original with no record
An unknown content typeThe SDK does not silently drop unknown data
PlatformMethod
Browser, Node, React Nativeconversation.deleteMessage(messageId)
Kotlinconversation.deleteMessage(messageId)
Swiftconversation.deleteMessage(id: messageId)

You can also call delete() on a loaded message. Each form queues the deletion and returns the ID of the deletion message. The deletion publishes with the conversation’s next publish or sync, and the target changes when it is processed.

A message that this installation stored and has not sent is cancelled instead: it and its queued send are removed, nothing is published, and the call returns the message’s own ID. If its send is already in flight, the call throws an InvalidInput error with code MessageInFlight; retry after the send completes.

The call throws when the message is absent, the caller is not the sender or a super admin, the message is already deleted, or its type cannot be deleted.

Use the client event stream and select the message.deleted event kind. The event contains the conversation ID, target message ID, and deletion cause. Read the affected message again to update the UI. Events carry IDs and state values, not message content.

The cause distinguishes a conversation deletion from a local deletion. message.expired is a separate event for disappearing-message cleanup. The SDKs do not have streamDeletedMessages or streamMessageDeletions methods.