# archive_chat

Source: https://modulify.ai/docs/mcp/chat/archive-chat

Closes a chat of a site for everyone, and clears its messages and everything queued in it.

- Title: Close a chat
- Scope: `sites:delete`
- Access: Destructive

Changes from the chat that were not merged into the site yet are discarded, and changes it already merged stay on the site. It cannot be undone, so the tool tells the client never to call it on its own initiative, only when you have asked for exactly this. To empty a chat but keep it open, use `clear_site_chat` instead. See [Close a chat](https://modulify.ai/docs/build/multiple-chats#close-a-chat).

Every chat can be closed, including the one whose `chatKey` is `main`, the chat every site comes with. Once it is closed, `list_chats` leaves it out, and `create_chat`, or `send_message` to `main`, opens it again, empty and called `New chat`. That works on every plan, Free included, so a site with no open chat can always start its chat again.

Because it cannot be undone, it needs the `sites:delete` scope, like `clear_site_chat` and `remove_queued_message`. That scope is not ticked when you create a token. See [Tokens and scopes](https://modulify.ai/docs/mcp/tokens-and-scopes).

Only the person who started the chat, or someone whose workspace role holds the **Delete projects** permission, may close it. For `main`, only the **Delete projects** permission counts. Anyone else is refused with a `403` reading `Only the person who started this chat, or someone whose role can delete sites, can close it!`

A chat with a generation running in it is refused with a `409` reading `Stop this chat before closing it!`, so cancel that generation with `cancel_job` first. While the chat's changes are being merged or discarded, including the merge at the end of a turn, it is refused with a `409` reading `Wait for this chat to finish first!`, which is safe to try again in a moment. Closing a chat on a site that works in copies discards its unmerged changes. When it has some and the site's preview is asleep, the close first waits a short time for the preview to wake so its copy goes too, and when the preview cannot be reached in time the changes are discarded all the same. `main` then rebuilds its copy from the merged site the next time it runs. A chat that does not exist or is already closed, including one somebody else closed a moment earlier, answers `404` with `That chat was not found!` When closing `main` fails part way through, it stays open with its unmerged changes, and the answer is a `500` reading `Something went wrong while closing the chat!` Multiple chats are a paid plan feature, but a chat can still be closed after a downgrade.

On success the answer reads `Chat closed successfully.` and carries the `chatId` of the chat that was closed.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id, from `list_sites` or `get_site`. |
| `chatId` | string | Yes | The `chatKey` of the chat to close, from `list_chats`. |