# Restore a backup

> Put a VM's disk back to one of its backups. The VM restarts.

`POST /v1/tenants/{tenant}/vms/{name}/backups/{id}/restore`

```bash curl
curl -X POST "https://api.shako.dev/v1/tenants/acme/vms/web1/backups/9f3c1a2e/restore" \
  -H "Authorization: Bearer $SHAKO_API_KEY"
```

```python Python
import os

import requests

response = requests.post(
    "https://api.shako.dev/v1/tenants/acme/vms/web1/backups/9f3c1a2e/restore",
    headers={"Authorization": f"Bearer {os.environ['SHAKO_API_KEY']}"},
)
response.raise_for_status()
print(response.json())
```

```javascript JavaScript
const response = await fetch("https://api.shako.dev/v1/tenants/acme/vms/web1/backups/9f3c1a2e/restore", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.SHAKO_API_KEY}` },
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```

```json 200 (excerpt)
{
  "id": 31,
  "kind": "backup",
  "step": "queued",
  "started_at": 1793494800
}
```

Authenticate with `Authorization: Bearer <API key>` on `https://api.shako.dev`. Role: contributor or owner.

## Path parameters

**tenant** `string` *required*

The tenant's name, from GET /v1/tenants.

**name** `string` *required*

The VM's name.

**id** `string` *required*

The backup's id, from GET .../backups.

## Response

200 with [the backup job object](https://shako.dev/api/objects/backup-job.md).

## Behavior

With backups on, Shako backs up the current disk first (kind pre-restore), so that you can undo the restore. The answer is the job at its start.

The errors: https://shako.dev/api/errors.md. All the endpoints of Backups: https://shako.dev/api/backups.md.
