> ## Documentation Index
> Fetch the complete documentation index at: https://docs.styne.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkpoints and rewind

> Save a sandbox or a browser at known steps, and go back to any of them without losing its id.

A checkpoint saves the sandbox as it is now, with its memory and disk, as the next step of its timeline. Rewind sends the
sandbox back to a step and it keeps its id. Both belong to the reliability features of the Pro and Scale plans (see
[Plans and billing](https://docs.styne.ai/billing.md)). A browser session is a sandbox with the same id, so the same calls take a browser id.

## Take a checkpoint

`POST /sandboxes/{id}/checkpoints` takes an optional body; the answer is `201` with the new step.

| Field | Meaning |
| - | - |
| `label` | Up to 200 characters and no control characters, for example `cart filled`. |
| `keepLast` | 1 to 1,000. After the new step is saved, the sandbox's own steps older than the newest `keepLast` are deleted, and the answer lists them as `pruned`. |

Each step is a saved [snapshot](https://docs.styne.ai/snapshots.md) named `<sandbox id>.cp<step>`, so it also counts toward your saved snapshots
([limits](https://docs.styne.ai/limits.md)). Start a new sandbox from it with `POST /sandboxes` and `{"snapshot": "<name>"}`: the branch keeps its own
checkpoints after that step. Two checkpoints taken at the same moment can answer `409`; repeat the call.

## Read the timeline

`GET /sandboxes/{id}/checkpoints` answers `sandboxID`, `checkpoints` (oldest first) and `ownBytes`, the disk the sandbox's own
steps hold. The steps of the snapshots the sandbox was started from come first and carry `inherited: true`. Each step has its
`label`, `step`, `parent` and `created`. The sandbox does not have to be running.

## Rewind

`POST /sandboxes/{id}/rewind` with `{"checkpoint": "<checkpointID>"}` takes a checkpoint or a saved snapshot of your account.
The sandbox goes back to it, keeps its id, and its next checkpoint follows that step. The answer carries `sandboxID`,
`checkpointID`, `step`, `generation` and `tookMs`.

| Answer | When |
| - | - |
| `400` | The body is not `{"checkpoint": "<checkpointID>"}`; the message says what is missing. |
| `402` | Your plan does not include checkpoints and rewind (`plan_required`); they come with the Pro and Scale plans. Taking a checkpoint answers the same. |
| `404` | The checkpoint or saved snapshot does not exist for your account. |
| `409` | The checkpoint is kept on another node than the sandbox. Start a new sandbox from it with `{"snapshot": "<name>"}`. |

## Operations

| Method | Path | What it does |
| - | - | - |
| `POST` | `/sandboxes/{id}/checkpoints` | Save a checkpoint of a sandbox as the next step of its timeline |
| `GET` | `/sandboxes/{id}/checkpoints` | List a sandbox's checkpoints, oldest first |
| `POST` | `/sandboxes/{id}/rewind` | Go back to a checkpoint or saved snapshot; the sandbox keeps its id |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.