> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete message

> Soft-delete a chat message

## Overview

Returns an async function that soft-deletes a message. The message is removed from the local Redux store immediately. On the server, the message's content is cleared and `userDeletedAt` is set — the record is retained for threading consistency.

> [!NOTE]
>
> Requires `ChatProvider` in the component tree.

## Usage Example

```tsx theme={null}
import { useDeleteMessage } from "@sublay/react-js";

function MessageActions({
  conversationId,
  messageId,
}: {
  conversationId: string;
  messageId: string;
}) {
  const deleteMsg = useDeleteMessage();

  return (
    <button onClick={() => deleteMsg({ conversationId, messageId })}>
      Delete
    </button>
  );
}
```

## Parameters

The hook returns a function. That function accepts:

**conversationId** `string` *required*

The ID of the conversation that contains the message.

**messageId** `string` *required*

The ID of the message to delete.

## Returns

`Promise<void>`

## Notes

* Other participants see the deletion in real-time via the `message:deleted` socket event, which is handled automatically by `ChatProvider`. Their local copy of the message will have `userDeletedAt` set and `content: null`.
* For integration guidance, see [Chat: Messages](https://docs.sublay.io/v7/sdk/chat/messages.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.