---
title: "Discard draft changes (all, or only what you name)"
method: POST
path: "/api/v1/sites/{slug}/revert"
tags: ["Draft & publish"]
---

# Discard draft changes (all, or only what you name)

`POST /api/v1/sites/{slug}/revert`

## Request

- Base URL: `https://api.dotsy.ai`
- URL: `https://api.dotsy.ai/api/v1/sites/{slug}/revert`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer

Throws away staged changes and brings the draft back to what is live. Only the draft is touched: the live site and its published version stay as they are. Name `keys` and/or `routes` to discard part of the draft, or send `key` for one content file. Send an empty body to discard everything, which cannot be undone.

## Path parameters

- `slug` string, required

## Request body

- RevertDraftsRequest: What to discard. `keys` and `routes` (when either is non-empty) pick a subset; otherwise `key` picks one content key; an empty body or `{}` discards ALL drafts. A `keys` or `routes` list that is present but empty selects nothing and is a 400 (`empty_selection`), never "all".
  - `key` string: Discard the draft of this one content key. Ignored when `keys` or `routes` is non-empty.
  - `keys` string[]: Discard the drafts of these content keys. Unknown keys are ignored.
  - `routes` string[]: Discard the drafts of these route paths. Unknown paths are ignored. Combine with `keys` for a page and its route.

## Response `200`

Discarded.

- RevertDraftsResponse
  - `ok` true, required
  - `reverted` integer, required: How many staged items were discarded. 0 when nothing matched.

## Other responses

- `400`: The body is not valid (`invalid_body`, with `issues`), or `keys`/`routes` was present but empty (`empty_selection`): nothing was discarded.
- `401`: Missing or invalid credentials.
- `403`: The key or token cannot edit this site (viewer role, read-only key, or a key scoped to other sites).
- `404`: No such site, or it is not visible to this account (`site_not_found`).
- `409`: Nothing was discarded: `draft_busy` or `draft_not_visible_yet`. Retry shortly.

---

[API](https://skmtc.dev/dotsy/apis/dotsy-api.md) · [All operations](https://skmtc.dev/dotsy/apis/dotsy-api/llms.txt) · [OpenAPI document](https://skmtc.dev/dotsy/apis/dotsy-api/revisions/4272ed3b85d7?raw)
