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

# Idempotency

> Retry safely without booking or messaging twice.

Networks fail. If you send `POST /appointments`, the booking is made, but the response never reaches you, a blind retry books the patient twice and sends two confirmations.

Send an `Idempotency-Key` header on every `POST`, `PUT`, `PATCH` and `DELETE`:

```bash theme={null}
curl -X POST https://docistra.com/api/v1/appointments \
  -H "Authorization: Bearer $DOCISTRA_API_KEY" \
  -H "Idempotency-Key: 6f1d1c2e-3b8a-4c55-9e0e-2a7f1b9c0d11" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
```

* Use a new unique value (a UUID is ideal) for each operation, and the same value when you retry that operation.
* The first response is saved for 24 hours. A retry with the same key returns it again, with the header `Idempotent-Replayed: true`, and nothing runs twice.
* The same key with a different body or path returns `422 idempotency_key_reused`.
* A retry while the first request is still running returns `409 idempotency_in_progress`. Wait a moment and retry.
* Server errors (5xx) are not saved, so a retry runs again.
* The header is optional. Without it, a request works as usual but has no retry protection.


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