---
title: "Roll back a site"
method: POST
path: "/sites/{id}/rollback"
tags: ["Deployments"]
---

# Roll back a site

`POST /sites/{id}/rollback`

## Request

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

Re-ships an earlier deployment's commit to production. Defaults to the previous shipped deployment (the "undo the bad deploy" case); pass `deployment_id` to target a specific historical deployment instead. Asynchronous: responds `202` with a new `pending` deployment whose status moves to `live`/`failed`. Poll `GET /sites/{id}/deployments` to track it.

## Path parameters

- `id` string, required

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `deployment_id` string: Id of a specific deployment to roll back to (e.g. "dpl_abc123"), from the deploy history. Omit to roll back to the previous shipped deployment.
  - `restore_database` boolean: Also rewind the site's database to the schema that deployment was serving, using the restore point captured before the deploy that followed it. Off by default: rolling code back is cheap, but a database restore discards every row written since the target shipped. Returns `no_restore_point` when no restore point was recorded after the target.

## Response `202`

The queued rollback deployment

- Deployment
  - `id` string, required
  - `object` string, required
  - `site` string, required
  - `status` 'pending' | 'building' | 'live' | 'failed' | 'superseded' | 'unpublished', required
  - `commit_sha` string, nullable, required
  - `is_live` boolean, required
  - `url` string, nullable, required
  - `triggered_by` string, nullable, required
  - `error_message` string, nullable, required
  - `db_bookmark` string, nullable, required
  - `current_stage` string, nullable, required
  - `stages` unknown[], required
    - unknown
  - `duration_seconds` number, nullable, required
  - `elapsed_seconds` number, nullable, required
  - `started_at` string, nullable, required
  - `finished_at` string, nullable, required
  - `created_at` string, required

## Other responses

- `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)
