Idempotency

View as Markdown

Networks fail. Send an Idempotency-Key header with a write, and you can retry it without doing anything twice.

The header

Any unique string, for example a UUID. Sending the same request again with the same key within 24 hours returns the first response without doing anything twice. Reusing a key with a different body is refused with idempotency_key_reused. A refused request (4xx) frees the key so you can correct and resend it; a server error (5xx) is kept and returned again, because the write may already have happened: check the resource before retrying with a new key.

Shell
curl -X POST "$DAPI_API_URL/v2/orders/ord_123/cancel" \
  -H "x-api-key: $DAPI_API_KEY" \
  -H "Idempotency-Key: 8e7c6c1e-2f0a-4f7b-9d3e-5b1f0c2a9e41"

Endpoints that accept it