# restore_backup

Source: https://modulify.ai/docs/api/backups/restore-backup

Replaces the entire current content of a site with the content of an earlier backup.

- Title: Restore a site backup
- Scope: `sites:write`
- Access: Destructive
- Endpoint: `POST /v1/restore_backup`

Every page, component and setting the site holds today is overwritten, and any work done since that backup was taken is dropped. The tool tells the client to confirm with you which backup you mean, and to say plainly what you will lose, before calling it.

The one safety net is that Modulify first takes a `Pre-restore Backup` of the current state, typed `automatic`, so restoring the wrong backup can itself be undone by restoring that one. A restore does not bring back stored files, database rows, environment variables or the site's source files, and the live site keeps serving its last published version until you publish again.

A restore never changes which GitHub repository holds the site code, the site's custom domains or a domain verification in progress. It is refused, with the same message `send_message` and `publish_site` give, 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 [Move your code to GitHub](https://modulify.ai/docs/editor/move-code-to-github).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/restore_backup`, sending the inputs below as a JSON object. The token needs the `sites:write` 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/restore_backup \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","backupId":"BACKUP_ID"}'
```

Over MCP, the same method is the [restore_backup tool](https://modulify.ai/docs/mcp/backups/restore-backup).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site to restore into. |
| `backupId` | string | Yes | The backup to restore, from `list_backups`. Either its `_id` or its `BackupId` works. |

## 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.