Modulify

Restore a site code backup

restore_code_backup

Rolls the source code of a site back to an earlier code backup and reloads the preview from it, deleting the whole site chat history.

POST /v1/restore_code_backupScopesites:deleteDestructive

It does far more than its name suggests. It deletes the entire site chat history: every message exchanged with the site agent is removed for everyone in the project and cannot be brought back, the agent loses all memory of what was discussed, and any messages queued to run next are thrown away unsent. Any file the agent wrote since that code backup is reverted, and files added since are deleted.

No backup is taken first, unlike restore_backup. The tool tells the client never to call it speculatively: it has to tell you plainly that your whole conversation with the agent will be deleted, and get your agreement first. Restoring does not publish, so the live site keeps serving what you published last.

If a generation is running, it refuses with a 409 reading AI is currently generating. Stop it before restoring this code backup! unless cancelActiveJob is set, which stops that generation mid-flight. It also refuses with a 409 when another code backup is already being restored for the site (Another code backup is already being restored for this site!), and when the latest changes of the site are still being saved after about 30 seconds of waiting (Your latest changes are still being saved. Try restoring again in a moment!). In both of those cases nothing was changed, so try again in a moment.

Like restore_backup, it is refused while the site code is being moved into GitHub, when Modulify has lost access to the GitHub repository that holds the site or that repository was deleted, and when the code lives in the workspace's own GitHub but the workspace is on the Free plan. See Restore a backup.

Request

Call it with a POST to https://api.modulify.ai/v1/restore_code_backup, 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/restore_code_backup \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","codeBackupId":"CODE_BACKUP_ID"}'

Over MCP, the same method is the restore_code_backup tool.

Inputs

Input Type Required Description
projectId string Yes The site id.
codeBackupId string Yes The code backup to roll back to, from list_code_backups.
cancelActiveJob boolean No True to stop a generation that is running instead of refusing. Set it only when you have agreed to lose that work.

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.