# clear_site_chat

Source: https://modulify.ai/docs/api/chat/clear-site-chat

Clears the entire transcript of one chat of a site for everyone and throws away every message queued to run next in it. The chat stays open.

- Title: Clear a chat
- Scope: `sites:delete`
- Access: Destructive
- Endpoint: `POST /v1/clear_site_chat`

It clears the chat whose `chatKey` is `main`, the one every site comes with, unless you pass `chatId`. A generation that is currently running in that chat is canceled first. The chat itself stays open, and a chat whose title was written for it, rather than given by somebody, is called `New chat` again until a later message names it. The site itself, its pages, its content and its code backups are untouched, and only the conversation goes. To close a chat altogether, use `archive_chat` instead.

It cannot be undone and there is no export, so read the history with `list_messages` first if any of it is worth keeping. The tool tells the client never to call it to tidy up or to start fresh on its own initiative, only when you have asked for exactly this.

Only the person who started the chat, or someone whose workspace role holds the **Delete projects** permission, may clear it. For the chat whose `chatKey` is `main`, only the **Delete projects** permission counts, and the built-in Member role does not hold it. Anyone else is refused with a `403` reading `Only the person who started this chat, or someone whose role can delete sites, can clear it!` A chat that does not exist or is closed, `main` included, answers `404` with `That chat was not found!` See [Clear a chat](https://modulify.ai/docs/build/multiple-chats#clear-a-chat).

On success the answer reads `Chat cleared successfully.` and carries `removed`, the number of messages cleared, and `cancelledJob`, true when a running generation was canceled.

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/clear_site_chat`, sending the inputs below as a JSON object. The token needs the `sites:delete` scope.

> **Warning**
>
> This method is marked destructive: it deletes or overwrites data. Check the inputs before you call it, and send an [Idempotency-Key](https://modulify.ai/docs/api/idempotency) header whenever you might retry it.

```bash
curl -X POST https://api.modulify.ai/v1/clear_site_chat \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID"}'
```

Over MCP, the same method is the [clear_site_chat tool](https://modulify.ai/docs/mcp/chat/clear-site-chat).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `chatId` | string | No | The chat to clear: `main` for the chat every site comes with, or the `chatKey` of another chat from `list_chats`. Defaults to `main`. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.