
# Idempotency

Networks fail. To retry a `POST` without doing it twice, send an `Idempotency-Key` header — any unique string up to 255 characters (a UUID is ideal):

```bash
curl https://api.kibanda.africa/v1/products \
  -H "Authorization: Bearer $KIBANDA_KEY" \
  -H "Idempotency-Key: 5f0c2c1e-9a8e-4c55-8f0f-3d2c6f1b2a10" \
  -d '{"name": "Milk 500ml", "price": 6500}'
```

- The first response for a key is saved for **24 hours**; retries get the same status and body, with the header `Idempotent-Replayed: true`.
- Reusing a key with a **different** request returns `400 idempotency_key_reused`.
- If the first request is still running, a retry returns `409 idempotency_request_in_progress`; try again shortly.
- Server errors (5xx) aren't saved, so a retry runs again.
- Keys are per shop. `GET` and `DELETE` are naturally idempotent and ignore the header.

**Tip:** derive the key from your own record — e.g. `odoo-sync-SKU-1001-2026-10-23T08:00` — so a crashed job that restarts sends the same key.
