# Operations, retries and errors

> Asynchronous calls, idempotency keys, errors and quotas.

## Operations

Calls that change a branch (create, checkpoint, reset, pause, wake, delete) return `202 Accepted` with an **operation**:

```json
{"operation": {"id": "op_...", "kind": "reset", "state": "pending", ...}}
```

Poll `GET /v1/operations/{id}?wait=10s`. The server holds the request up to `wait` (max 30 s) and returns as soon as `state` is `succeeded` or `failed`. On success, `result` has details such as the new `generation`. On failure, `error` says why. The SDK and CLI wait for you by default.

## Idempotency

Send an `Idempotency-Key` header with any mutating call. If the network fails, retry with the **same key and body**:

| Retry | Response |
|---|---|
| Same key, same body, first request finished | The first response again, with `Idempotent-Replayed: true` |
| Same key, first request still running | `409 request_in_progress` |
| Same key, different body | `422 idempotency_mismatch` |

Keys are kept for 24 hours. The Python SDK adds a key to every mutating call and retries automatically.

## Errors

Every error has the same shape:

```json
{"error": {"code": "not_found", "message": "not found"}}
```

| Status | Codes |
|---|---|
| 400 | `invalid_request`, `invalid_json` |
| 401 | `unauthorized` |
| 404 | `not_found` (also for resources in another organization) |
| 409 | `conflict`, `not_running`, `request_in_progress` |
| 422 | `idempotency_mismatch` |
| 429 | `quota_exceeded`, `rate_limited` |
| 501 | `not_implemented` (L1/L2), `not_configured` |
| 503 | `wake_failed` |

## Quotas

Defaults per organization:

| Quota | Default |
|---|---|
| Branches (excluding deleted) | 100,000 |
| Running or creating branches | 1,000 |
| Branch creations per minute | 600 |
| Branches per create call (`count`) | 100 |
