> Index of every page on this site: [llms.txt](https://docs.a-line.cloud/llms.txt)

# Idempotency

> Retry create requests safely with the Idempotency-Key header.

Five operations accept an `Idempotency-Key` header, so a retry after a
timeout does not create a second copy:

- [create_project](/api/reference/projects#create-a-project-in-a-cluster)
- [create_app](/api/reference/apps#create-an-app-in-a-cluster-from-a-container-image-or-a-catalog-template)
- [trigger_deploy](/api/reference/apps#deploy-the-apps-current-image-again)
- [rollback_deploy](/api/reference/apps#roll-the-app-back-to-what-a-past-deploy-released)
- `trigger_backup`

The key is any string of 1 to 255 visible ASCII characters, such as a UUID
you generate per attempt. Keys are kept per API key.

```http api
POST /v1/clusters/{cluster_id}/apps/{app_id}/deploys
Authorization: Bearer $ALC_API_KEY
Idempotency-Key: 9f3c6c2e-2d4b-4b7e-a1f0-6e5d8c7b9a10
Content-Type: application/json

{ "strategy": "rolling" }
```

## How a retry is answered

| The retry                                          | The answer                                                   |
| -------------------------------------------------- | ------------------------------------------------------------ |
| Same key and body, within 24 hours                 | The first response again, with `Idempotent-Replayed: true`.  |
| Same key, different body                           | `422`.                                                       |
| Same key while the first request still runs        | `409`. Wait and retry.                                       |
| Same key after the first request failed            | Runs again: a failed request does not keep its key.          |

Requests without the header run normally.
