---
title: "Restore a site's database to a point in time"
method: POST
path: "/sites/{id}/db/restore"
tags: ["Sites"]
---

# Restore a site's database to a point in time

`POST /sites/{id}/db/restore`

## Request

- Base URL: `https://api.crevio.co/v1`
- URL: `https://api.crevio.co/v1/sites/{id}/db/restore`
- Auth: API key in header `Authorization`

Rewinds the site's database to a restore point or an ISO 8601 `timestamp` — the undo for data you didn't mean to lose. One of the two is required. Restore points come from `db/migrations`, where every applied change carries the `restore_to` it began from; nothing has to capture one in advance.

The restore overwrites current state, but earlier points are retained, so an overshoot can itself be undone via `previous_bookmark`. Points are kept for 30 days.

**This is not how a schema change is removed.** A restore rewinds this database's shape too, but the development database still has the newer one — so the next deploy compares them and puts it back. To drop a table for good, remove it from the development database and deploy.

## Path parameters

- `id` string, required

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `bookmark` string: A restore point, as returned by `db/migrations` (`restore_to`) or by a migration's own response.
  - `timestamp` string: An ISO 8601 timestamp to rewind to (nearest point at or before).
  - `environment` 'development' | 'production': Which database to use. A site normally has exactly one, `production`, and that is the default — the live database the site reads. `development` is only valid if a separate development database has been provisioned for this site; asking for one that doesn't exist is an error rather than a silent fall back to production. The response echoes the environment that was used.

## Response `200`

Restore result

- object
  - `object` string
  - `bookmark` string
  - `previous_bookmark` string
  - `message` string

## Other responses

- `400`: Bad request
- `401`: Authentication required
- `404`: Resource not found
- `422`: Validation error
- `429`: Rate limit exceeded — 600 requests per minute per credential. Retry after the number of seconds in `Retry-After`.

---

[API](https://skmtc.dev/crevio/apis/crevio-api-v1.md) · [All operations](https://skmtc.dev/crevio/apis/crevio-api-v1/llms.txt) · [OpenAPI document](https://skmtc.dev/crevio/apis/crevio-api-v1/revisions/2219f18ad651?raw)
