Discard the unmerged changes of a chat
discard_chat_changes
Throws away the unmerged changes of a chat, keeping everything it already merged into the site.
It removes the changes from the chat that could not be merged into the site automatically, which list_chats shows as pending, and anything its copy of the site still holds. Changes that were already merged stay on the site. See Changes not merged.
It cannot be undone, so the tool tells the client to try merge_chat_changes first and to confirm with you before discarding. For the same reason it needs the sites:delete scope, which is not ticked when you create a token, and chatId has no default: the client has to name the chat, main included.
Request
Call it with a POST to https://api.modulify.ai/v1/discard_chat_changes, sending the inputs below as a JSON object. The token needs the sites:delete scope.
This method is marked destructive: it deletes or overwrites data. Check the inputs before you call it, and send an Idempotency-Key header whenever you might retry it.
curl -X POST https://api.modulify.ai/v1/discard_chat_changes \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"projectId":"PROJECT_ID","chatId":"CHAT_ID"}'Over MCP, the same method is the discard_chat_changes tool.
When it is refused
| Status | When | The message |
|---|---|---|
409 |
A generation runs in that chat, or its changes are already being merged or discarded | Wait for this chat to finish first! |
409 |
The site does not work with several chats yet, so nothing is kept unmerged | This chat has no unmerged changes! |
503 |
The site could not be reached to throw the changes away | The site could not be reached to finish this. Try again in a moment! |
The 503 is safe to try again in a moment.
Who can discard
Discarding needs the same permission as closing a chat. Only the person who started the chat, or someone whose workspace role holds the Delete projects permission, may discard its changes, and anyone else is refused with a 403 reading Only the person who started this chat, or someone whose role can delete sites, can discard its unmerged changes! For main, the chat every site comes with, only someone with Delete projects may, and anyone else is refused with a 403 reading Only someone whose role can delete sites can discard the unmerged changes of this chat! See Members and roles.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
projectId |
string | Yes | The site id, from list_sites or get_site. |
chatId |
string | Yes | The chat whose unmerged changes to discard: main for the chat every site comes with, or the chatKey of another chat from list_chats. There is no default. |
Response
Every call answers with the JSON envelope 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 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 explains every status code a call can answer with.