# Restore

Three restores exist, from the most frequent to the rarest. None of them rolls back the data of a database: the tool catalogue has no restore of a database from a backup (see [the MCP reference](../reference/en/mcp.md)).

## 1. Return to an environment's previous release

This is the restore for a deployment that goes wrong. It rebuilds nothing: it puts an already built release live again, in a few seconds. Two calls, in this order.

**Read what will be brought back.** The `deployment_restorable_list` tool (arguments `projectId`, `environmentId`, and `releaseId` to aim at a release other than the previous one) returns:

- `restorable`: true if the restore is possible, otherwise `refusalCode` and `refusalMessage` say why;
- `releaseId` and `commitSha`: the targeted release;
- `notRestored`: what the restore does not bring back, with a category and a detail for each item;
- `confirmationToken`: the proof that you read this list.

**Restore.** The `deployment_rollback` tool takes the same `projectId` and `environmentId`, the `confirmationToken` and, if needed, `releaseId`.

```json
{
  "projectId": "prj_01JQ8ZK4M7NP2RSTVWXYZ34567",
  "environmentId": "env_01JQ8ZK4M7NP2RSTVWXYZ34567",
  "confirmationToken": "<token returned by deployment_restorable_list>"
}
```

The response carries `restoredReleaseId`, `previousReleaseId` and `notRestored`, and an `undoToken`. The environment stays pinned to the restored release: a new deployment does not replace it until you lift the pin with `environment_unpin`.

## 2. Undo the restore

For five minutes, once, with the same account and the same agent session, `action_undo` (argument `undoToken`, the one from the response) puts things back as they were. After that, simply replay the original operation.

## 3. Bring a project back from the trash

A project whose deletion was requested remains recoverable during the grace period. `project_deletion_cancel` withdraws the request, cancels it during the grace period, or restores the project from the trash.

## When it fails

`deployment_rollback` is class E: a person approves the call before it goes out. A refusal names its cause: `confirmation_perimee` (what would be restored has changed: read `deployment_restorable_list` again), `rien_a_restaurer`, `deja_servie`, or `release_refroidie` (the release is outside the fast restore window and needs a confirmation). The codes of each tool are in [the MCP reference](../reference/en/mcp.md).

See also: [Create a project](project.md), [Deploy](deploy.md).
