Merge the unmerged changes of a chat

merge_chat_changes

Tries again to merge the unmerged changes of a chat into the site.

POST /v1/merge_chat_changesScopechat:writeMakes changes

Each chat works in its own copy of the site. When the end of a turn cannot merge its changes automatically, for example because another chat changed the same lines, they are kept as unmerged changes, which list_chats shows as pending. This tries the merge again. See Changes not merged.

The response carries the outcome in integration, where state reads:

state What it means
landed The changes are on the site now
no-changes Nothing was left to merge
conflicted, pending or rejected They still could not be merged and stay unmerged. Send a message to that chat asking the agent to resolve the conflicts

integration also lists the files that conflict in conflicts, each with its path and kind.

It is refused with a 409 while a generation runs in that chat or its changes are already being merged or discarded (Wait for this chat to finish first!), while the site finishes a restore or move or its preview moves to a new environment or a bigger machine (Changes cannot be saved to this site while it finishes a restore or move. Try again in a moment!) and when the chat has no unmerged changes (This chat has no unmerged changes!). It is also refused while the site is locked, like every tool that changes a locked site, and while its GitHub repository blocks editing, with the same message send_message gives.

Two refusals are safe to try again in a moment:

Status When The message
409 Another chat's changes are being merged into the site right now Another chat is merging changes right now. Try again in a moment!
503 The site or its repository could not be reached to finish the merge The site could not be reached to finish this. Try again in a moment!

Request

Call it with a POST to https://api.modulify.ai/v1/merge_chat_changes, sending the inputs below as a JSON object. The token needs the chat:write scope.

It makes changes, so send an Idempotency-Key header whenever you might retry it. A retry with the same key gets the first answer back instead of running again.

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

Over MCP, the same method is the merge_chat_changes tool.

Inputs

Input Type Required Description
projectId string Yes The site id, from list_sites or get_site.
chatId string No The chat to merge: 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 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.