---
title: "Put an earlier version of a page back at the same URL."
method: POST
path: "/sites/{idOrSlug}/versions/{versionId}/restore"
tags: ["Sites"]
---

# Put an earlier version of a page back at the same URL.

`POST /sites/{idOrSlug}/versions/{versionId}/restore`

## Request

- Base URL: `https://api.stacktr.ee`
- URL: `https://api.stacktr.ee/sites/{idOrSlug}/versions/{versionId}/restore`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://api.stacktr.ee/oauth/authorize`, token URL `https://api.stacktr.ee/oauth/token`, scopes: `sites:write`)

Swaps the chosen snapshot back into the live page. Same id, same link, same read history, so nothing needs re-sending. The CURRENT content is snapshotted FIRST, as a new version with source `restore`, so this is itself undoable and the new version id comes back as `new_version`. Script hashes and the page title and description are recomputed from the restored HTML, exactly as a normal update does. SINGLE-FILE ONLY: on a multi-file page this puts index.html back and leaves the other files unchanged, and the response carries `partial: true` saying so. Owner-authed, and only for a page that is currently serving: a retired page answers 409 site_deleted and has to be restored with POST /sites/{idOrSlug}/restore first.

## Response `200`

Restored; the link now serves that version.

- object
  - `ok` boolean, required
  - `restored` string, required: The versionId that is now live.
  - `new_version` string, nullable: The version id holding what was live a moment ago, so this restore can be undone. Null when the snapshot could not be written; the restore still happened.
  - `size_bytes` integer
  - `partial` boolean: Present and true only on a multi-file page: index.html was put back, the other files are unchanged.
  - `message` string

## Other responses

- `400`: The page is end-to-end encrypted, so there is nothing readable to put back.
- `401`: Missing or invalid credentials.
- `403`: Account suspended. A restore puts content back on the public web, so it meets the same blocklist a publish does.
- `404`: No such page on this account (not_found), no such version on it (version_not_found), or the stored copy is gone (version_gone). Nothing was changed in any of them.
- `409`: The page cannot take this write in its current state. Read `error`: `site_deleted` means it has stopped serving and is being kept for 30 days: restore it with POST /sites/{idOrSlug}/restore and retry, and do NOT publish it again, which would create a second page at a different URL. `managed_portal` means it is a generated client portal that rebuilds from its space. `slug already taken` means another page holds that public slug, including a retired page still reserving it for its restore window.

---

[API](https://skmtc.dev/stacktr/apis/stacktree-api.md) · [All operations](https://skmtc.dev/stacktr/apis/stacktree-api/llms.txt) · [OpenAPI document](https://skmtc.dev/stacktr/apis/stacktree-api/revisions/5878cce46977?raw)
