---
title: "Restore a snapshot"
method: POST
path: "/snapshots/{id}/restore"
tags: ["Snapshots"]
---

# Restore a snapshot

`POST /snapshots/{id}/restore`

## Request

- Base URL: `https://app.mandala.computer/api/v1`
- URL: `https://app.mandala.computer/api/v1/snapshots/{id}/restore`
- Auth: HTTP bearer

Puts this snapshot back onto the computer it came from, replacing its current disk. Needs that computer to still exist — an orphaned snapshot cannot be restored, only cloned.

A snapshot held by two hosts at once — a move part way through handing its history over — is served from the copy on the host its computer now lives on. One that cannot be attributed that way, such as an orphan, answers 409 until the handover finishes; nothing is changed.

A snapshot taken before its computer moved to another host (`POST /computers/{id}/move`) is carried to the new host after the move. Until it lands, restoring it answers 409 with `reason: "contention"`, saying it is still being carried over; try again in a few minutes. If the carry failed, the 409, with no `reason`, says it is still on the host the computer moved from, and that does not clear on its own: clone it instead, or ask support to move it. Nothing is changed either way. Cloning the snapshot works while it is being carried, except while the new host is taking it over, when a clone can answer `409` as well; retry once the carry has finished.

IT LEAVES THE COMPUTER RUNNING, whatever state it was in. A restore of a stopped computer boots it, and that is a start like any other: charged, and refusable by your plan. A disk snapshot comes back to a fresh boot; a memory one resumes the captured session. Either way any suspended session the computer was holding is discarded, since it was saved against the disk being replaced. On a host without enough free disk space for it, a restore answers `503` before anything is touched. If space runs short after the disk has been replaced, the start at the end can still be refused with `503` (“this host is low on disk space…”), and the computer is left stopped on the restored disk: start it once space there has been freed. If that message adds that its paused QEMU could not be stopped, stop the computer before trying again.

A computer that holds secrets restored from a DISK snapshot gets them delivered afresh at that boot, with their current values, exactly as a start delivers them; the snapshot never carried them. This delivery has the same workspace-conflict refusals and recovery as `POST /computers/{id}/start`. One restored from a memory snapshot resumes holding what it held when the snapshot was taken. A memory snapshot taken without sealing is refused onto a computer that now holds secrets (`409`, `reason: "unsupported"`), and a sealed one with `400` and no `reason` when the platform will not open its saved memory for this computer, for example because a secret it held has since been deleted or moved out of the computer’s scope. Both are checked before anything is stopped, and then nothing is stopped or replaced. The saved memory is opened again when it loads, so a refusal that arrives only then — a secret deleted in the meantime, say — ends the restore after the disk has been replaced, leaving the computer stopped.

A MEMORY SNAPSHOT ONLY LOADS INTO THE SHAPE IT CAME OFF. Resize the computer after capturing one and the restore is refused — the vCPU count and the memory size are part of a saved memory image, not decoration around it. The refusal names the shape to go back to; `clone` is the other way out: a clone resumes the session in a new computer at the captured shape — for a snapshot of a computer that held secrets only with `inherit_secrets: true`, and otherwise it is built from the disk and says so with `memory_dropped: true` — or, with `memory: false`, is built from the disk alone; one built from the disk lands stopped and boots fresh when you start it (see `POST /snapshots/{id}/clone`). Refused before anything is taken down, so a computer that gets this answer is untouched.

Requires the `member` role or higher.

## Path parameters

- `id` string, required

## Headers

- `Idempotency-Key` string

## Response `200`

Restored.

- LifecycleAck
  - `ok` boolean, required: Always `true`. A failure is a status code, not `ok: false`.
  - `operation_id` string: This call’s operation, already `succeeded`: the step was done before the answer was sent. Read it with `GET /operations/{id}`. Absent, with the call still done, in the rare case the operation could not be recorded; a client must not treat its absence as a failure of the call.

## Other responses

- `400`: The request was malformed — a bad resolution string, a missing `command`, a `{pid}` or `{window}` that is not one. It is also what a well-formed request gets when the thing it names cannot be acted on and never will be — a restore onto a computer that is gone, for instance. Either way it is final: the message says what is wrong, and sending it again unchanged answers the same. That is the whole difference from a `503`, which means ask again shortly. Also a malformed `Idempotency-Key`, with `code: "idempotency_key_invalid"`: empty, longer than 255 characters, a character outside printable ASCII or a space, or the header sent twice.
- `401`: Platform authentication required or refused: reason is missing, invalid, or revoked, with WWW-Authenticate: Bearer (invalid_token for invalid/revoked).
- `402`: Your plan refused this: a quota, or a payment that has not gone through. On an agent run it can instead be `Insufficient AI credits` with `top_up_url` (a run funded by the account’s AI credits), or the model provider’s own billing refusal of your `X-Model-Key`, relayed.
- `403`: The credential is recognized but its holder lacks the required role or membership, or the holder/account is suspended, or the holder has not verified their email address. An ordinary denial for too low a role may carry no `reason`. The email one carries none either, and its message begins `Verify your email before`: it answers a create, a clone of a computer or a snapshot, a new API key and a new SSH key, and is cleared by verifying the address in the dashboard. `reason: "revoked"` marks authority that is gone: a suspended account or a lost membership (refused as the request arrives, or if it happens while the request is in flight), or a role that was lowered while the request was in flight. The message identifies the refusal; replacing a valid key alone does not restore authority, and sending the same call again does not help.
- `404`: No such resource in your scope — a computer, snapshot, secret, webhook, SSH key, API key, workspace, operation and so on — or no such endpoint; a confirmed missing guest file is no such file in the guest.
- `405`: This public path exists but does not accept that method. Allow lists only its public methods, with HEAD for GET and metadata OPTIONS.
- `409`: Refused for the state something is in — resizing a computer that is running, running a command on one that is stopped, taking a snapshot while another capture of it is running. WHETHER RETRYING HELPS IS IN THE BODY, NOT THE STATUS, and this is the one thing to take from this entry. Some of these describe a state that is passing: a guest agent still inside its boot window, a guest agent busy with another call, a move already running on the account. Those clear on their own and the same request works a moment later. The rest describe a DECISION about the request you sent — the size does not fit, the computer is the wrong one for this, the saved session cannot travel — and no amount of retrying turns one of those into a yes. A client that treats 409 as uniformly transient loops forever on half of them. Where the platform can say which it is, it sends `reason` beside `error` — one word, meant to be switched on rather than read: `contention` and `starting` clear on their own, `unavailable` means the computer is not running and only starting it helps, `running` means the computer is running and only stopping it helps (a resize), `unsupported` means waiting will not change the answer — this computer cannot do it at all, or it needs another step first, which the message names (a stop, or removing its secret bindings, for example) — `exists` means a create-only upload found its path taken, `name_taken` means a secret of that name is already in that scope, `stale_revision` means a secret changed since the `revision_id` you sent was read (or a computer’s bound list since the `version` you sent), and `stale_capture` means the screenshot capture you named is no longer held: a newer one replaced it, or its host’s daemon restarted or the computer moved. `starting` covers the two minutes after a start or a restart, and after a reboot from inside the guest on a computer last cold-started recently enough to report one (a stop and a start gives an older one that); a guest agent that is still silent after that is a `502`. Match on that and never on the sentence, which is prose and is rewritten. **Absent means no classification was given** — treat it, and any word you do not recognise, as no answer, because not every refusal here has one yet. It is what the guest routes answer: the clipboard on a stopped computer used to be a 409 indistinguishable from a clipboard whose selection was claimed for an instant, and a blanket retry loop spun against the first until its deadline. Every 409 that clears on its own carries `contention` or `starting`: a host busy with another build or with no room for one, an operation already running on the same computer or snapshot (a capture, a copy, a delete, a restore or clone reading it, another agent run), a lock another request holds, a move or a delivery settling. So a 409 with no word, or with any other word, is not one that waiting fixes: read the sentence for the step it names. The ones worth knowing by name, because each has a next step that is not "wait": A resize past what the computer’s host can run carries `move`, an object rather than a message: `{"required":true,"possible":true}` means another host in this region could run it and the computer has to be moved there first — `POST /computers/{id}/move` with the same sizing fields is how you agree to that, and it is a separate call because relocating a computer is not something a resize should do to you quietly. `possible:false` means nowhere in the region can, and the size is the thing to change. The move itself then refuses for the things it re-decides at the moment it runs, and only one of those is worth waiting on: a computer that is running or suspended has to be stopped or resumed-and-stopped by you, a size that fits where it already is wants an ordinary resize instead, and a region with nowhere to put it wants a smaller size. `Another computer on this account is being moved right now` is the one that clears by itself, and it carries `reason: "contention"` — one move runs per account, and `GET /moves` says which. And the terminal socket refuses twice over: `reason: "unavailable"` with `resume_required: true` on a suspended computer, which clears when you start it and not before, and `reason: "unsupported"` on a running computer whose hardware carries no terminal channel — one last started before interactive terminals existed — which needs a stop and a start. Not a restart, which resets the same machine, and not a retry, which never comes good. With an `Idempotency-Key`, two more. `code: "idempotency_in_progress"`, with `reason: "contention"`, `Retry-After` and the `operation_id`: the call with this key is still being carried out — send it again shortly for its answer. `code: "idempotency_outcome_unknown"`, with no `reason`: the platform did not hear how the call with this key ended (as after a `5xx` answer to it that named an `operation_id`), so do NOT send it again blindly; read the computer, and the operation the body names, to see whether it took effect. Also, for a computer that holds secrets restored from a disk snapshot, the secret refusals of `POST /computers/{id}/start`, with its words: `contention` while the computer is being moved to another workspace or a change to its secrets is still being saved, `unsupported` for a workspace change whose outcome was lost, bindings recorded in a workspace the computer is no longer in, a host list of bindings that does not match the recorded one, a bound secret that is gone or cannot be delivered, or secrets delivery not switched on for this deployment.
- `422`: The `Idempotency-Key` on this request was used within its 24 hours with a different request (`code: "idempotency_key_reused"`). Nothing was done: a key stands for one request, so send this one under a new key. This `Idempotency-Key` was used within its 24 hours with a different request (`code: "idempotency_key_reused"`). Nothing was done; send this request under a new key.
- `429`: You are asking faster than your plan allows. `Retry-After` says how many seconds to wait, and every metered response — anything past authentication and the re-check that your credential’s authority still holds — carries `RateLimit-Remaining`, so you do not have to be refused to find out. A `401`, a `403` from that re-check, an `OPTIONS` answer and an unexpected `500` carry none. The budget is spent in proportion to what a call costs rather than per request. What a call costs, in budget units, by kind (each operation’s exact figure is its `x-rate-cost` in the OpenAPI document): 1 to read one thing; 5 for a listing that spans the fleet, and 5 for a call into a running guest such as a screenshot or an exec; 10 for a power change and 10 to move file bytes; 25 for `GET /usage`, `GET /credits`, creating a public URL, and creating, rotating or testing a webhook; 50 to capture a snapshot; 100 to create, clone or restore a computer, and 100 to start an agent run, whose actions are then charged as they happen. The account-wide budget, as what an idle caller may spend at once and what refills each minute: No plan 1200 at once and 1200 a minute; Solo 4800 at once and 4800 a minute; Studio 12000 at once and 12000 a minute; Swarm 21600 at once and 21600 a minute. A single API key gets half of either. A `401` for a missing or unusable credential costs nothing: it is refused before anything is metered. A few refusals at the door cost one unit: a `403` because the role is too low or the route refuses an API key confined to a workspace, a `404` for a path that matches nothing, a `405`, and an `Idempotency-Key` answered from its stored result or still in progress. Everything else is charged in full when it is admitted, before it is carried out, so a refusal after that has spent the whole cost: a `400`, `402` or `409` from the route, a `403` its handler sends (on most routes, a suspended account included), and a model provider’s `401` on an agent run. The budget belongs to the account and is shared across everything on it, and any single API key may spend at most half of it. `RateLimit-Limit` is whichever of those two is binding on the request that carried it — usually the per-key half, and the account-wide figure when other keys have already spent more of it than this one has. All three `RateLimit-*` headers describe the same one, so `limit` minus `remaining` is what has been spent against it. A few `429`s are not about this budget, say so in their message, and can carry no `Retry-After`: a model provider’s rate limit relayed on an agent run. The cap on forks of one snapshot waiting for their secrets sends its own bounded expiry-based `Retry-After` with `reason: "contention"` (see `POST /snapshots/{id}/clone`).
- `500`: The application could not finish this: an unexpected exception, a build that broke, or a storage fault. Application refusals carry the request correlation ID; unexpected internal details are not returned.
- `503`: Something this depends on — a hypervisor, a store, or a host’s capacity — could not answer or take this right now. A read can be retried shortly. A change answered `503` may or may not have happened — a failure after the request was sent is answered the same way, with or without a warning in the message — so read the current state before retrying anything that is not safe to repeat, such as a create or a command. On the collection reads, `allow_partial=1` accepts a knowingly short answer instead. Also a sealed session the platform could not open, seal or carry just then — the service that holds its key did not answer, or the host failed moving the saved session — which is the platform’s fault and not the request’s. Read the computer’s status, then send the restore again; it usually clears in a moment. Sent with an `Idempotency-Key`, sending it again under the same key is safe: when the host refused it before changing anything, its key was released and the answer names no `operation_id`, so the resend is carried out; when the answer names an `operation_id`, the outcome is unknown and the resend answers `409 idempotency_outcome_unknown` — read the computer and that operation instead.

---

[API](https://skmtc.dev/mandala/apis/mandala-computer-api.md) · [All operations](https://skmtc.dev/mandala/apis/mandala-computer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mandala/apis/mandala-computer-api/revisions/2afbb87fa703?raw)
