> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Restore a database snapshot

> Overwrite a database's data with a snapshot using POST /v2/databases/{database_id}/snapshots/restore. The snapshot's engine must match the database.

<Warning>This route has a rate limit of 1 request every 60 seconds.</Warning>

<ParamField header="Authorization" type="string" placeholder="API Key" required>
  The API key for your account. You can find this in your [account settings](https://squarecloud.app/en/account/security).
</ParamField>

Requires an API key with the `snapshots:write` [scope](/en/api-reference/authentication#scopes).

Restores a database in-place from a previously taken snapshot, identified by the `snapshotId` and `versionId` returned from [Create Snapshot](/en/api-reference/endpoint/databases/snapshots/create) or [List Snapshots](/en/api-reference/endpoint/databases/snapshots/list). The snapshot's engine must match the target database's `type`, you cannot restore a Redis snapshot onto a MongoDB database, for example.

This overwrites the database's current data with the snapshot's contents; there is no undo beyond taking another snapshot first. While the restore is running, [Start](/en/api-reference/endpoint/databases/start), [Stop](/en/api-reference/endpoint/databases/stop) and [Delete Database](/en/api-reference/endpoint/databases/delete) are rejected for that database. Rate limited to 1 restore per 60 seconds per user, and 1 restore per 120 seconds per database.

## Parameters

<ParamField path="database_id" type="string" placeholder="Database ID" required>
  The ID of the database.
</ParamField>

<ParamField body="snapshotId" type="string" placeholder="Snapshot ID" required>
  The snapshot `name` from the listing (the database ID suffixed with `_<type>` and, on newer snapshots, `_<origin>`), passed exactly as returned.
</ParamField>

<ParamField body="versionId" type="string" placeholder="Snapshot Version Key" required>
  The snapshot's `version_id`, as [List Snapshots](/en/api-reference/endpoint/databases/snapshots/list) returns it.
</ParamField>

## Response

<ResponseField name="status" type="string">
  Indicates whether the call was successful: `success` if it was, `error` if not.
</ResponseField>

<ResponseExample>
  ```json theme={"system"}
  {
    "status":"success"
  }
  ```
</ResponseExample>

## Common errors

| Code | HTTP | Meaning |
| - | - | - |
| `MISSING_PARAMETERS` | 400 | `snapshotId` or `versionId` was not provided. |
| `INVALID_SNAPSHOT_ID` | 400 | `snapshotId` is not a snapshot name as returned by the listing (an ID, optionally with up to two `_<tag>` suffixes). |
| `INVALID_VERSION_ID` | 400 | `versionId` does not match the expected format. |
| `SNAPSHOT_DATABASE_MISMATCH` | 400 | The snapshot's engine does not match this database's `type`. |
| `SNAPSHOT_NOT_FOUND` | 404 | No snapshot exists for the given `snapshotId` and `versionId`. |
| `DATABASE_NOT_FOUND` | 404 | The database does not exist or is not owned by the caller. |
| `SNAPSHOT_RESTORE_FAILED` | 404 | The restore failed. This is the only failure code; `SNAPSHOT_NOT_FOUND` means the snapshot does not exist. |

## Related

* CLI: [`squarecloud db snapshot restore`](/en/cli-reference/snapshots#squarecloud-db-snapshot-restore)
* SDKs: [`api.databases.snapshots.restore()`](/en/sdks/js/databases) (JavaScript), [`client.databases.snapshots.restore()`](/en/sdks/py/databases) (Python), [`c.Databases.Snapshots.Restore()`](/en/sdks/go/databases) (Go)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.