Idempotency (Safe Retries)
Network errors or timeouts may force you to resend a request. Idempotency prevents the same request from being accidentally processed twice (e.g. duplicate orders, double charges).
How It Works
Add an Idempotency-Key header to mutating requests (POST, DELETE). It must be
a unique UUID v4 value:
curl -X POST https://api.rabisu.com/api/v1/orders \
-u "rsk_live_xxx:rsks_yyy" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 9f1c2d3e-4b5a-6c7d-8e9f-0a1b2c3d4e5f" \
-d '{ "product_id": 101, "period": "monthly" }'
Behavior:
| Case | Result |
|---|---|
| No key | Processed normally (no idempotency protection). |
| Key present, same body | The first response within 24h is returned from cache — the operation is not re-executed. |
| Key present, different body | 422 idempotency_key_reuse — the same key cannot be used with different content. |
Endpoints Where It Is Required
Some financial / destructive endpoints require Idempotency-Key; if missing,
400 missing_idempotency_key is returned:
POST /orders— create an orderPOST /services/{id}/upgrade— resource upgrade (difference invoice)POST /services/{id}/rebuild— OS reinstallPOST /services/{id}/power/{action}— power actionsDELETE /services/{id}— service termination (disk is wiped)
Recommendations
- Generate a stable key per logical operation. For example, when retrying the "monthly upgrade for service 500" request, use the same key to avoid double billing.
- Generate a new key for a new operation.
- Keys are stored for 24 hours; after that, the same key can be reused.