Skip to navigation

Idempotency

Retry any write without performing it twice.

Every POST except /access-token requires an Idempotency-Key header. Without it the request returns 400 IDEMPOTENCY_KEY_REQUIRED.

curl -X POST "https://$API_HOST/api/v2/cards/$CARD_ID/freeze" \
-H "Authorization: Bearer $TOKEN" \
-H "Account-Holder: $ACCOUNT_HOLDER_ID" \
-H "Idempotency-Key: 5f1c7a8e-2b0d-4f43-9e36-1a7c2d9b4e10" \
-H "Content-Type: application/json" \
-d '{}'

Choosing a key

  • Use a new UUID v4 for each operation.
  • A key is 1 to 255 visible ASCII characters. A value in double quotes is accepted and the quotes are removed.
  • Generate the key before the first attempt and store it with your own record of the operation, so every retry sends the same key.

How retries behave

You sendYou get
The same key and the same requestThe first response, with Idempotent-Replayed: true. Its status and body are the same, including any problem’s requestId. The X-Request-Id header is new.
The same key while the first request is still running409 IDEMPOTENCY_IN_PROGRESS. Retry later with the same key.
The same key with a different request409 IDEMPOTENCY_KEY_REUSED. The request is refused.
A new keyA new operation.

A key can be used again 30 days after its operation completes.

Unknown outcomes

Some operations ask an external party to act. When no definite answer comes back, the API returns 502 OPERATION_OUTCOME_UNKNOWN. Retry later with the same key. Retries return this response until the outcome is known, then the final response. Never switch to a new key for the same operation.