Skip to main content
Idempotency ensures that repeating the same API request produces the same result without creating duplicate resources or triggering duplicate operations. This is especially important for financial transactions, where network issues or timeouts could cause your application to retry a request that already succeeded.

How it works

Include an Idempotency-Key header on the POST and PATCH requests that accept it: the API reference lists the header on each of them. Any string works as a key, but a UUID v4 is recommended. The API stores the response for that key, per project, and returns the cached result if the same key is sent again.
Request with idempotency key

Behavior

Successful and failed responses are cached, so retrying a failed request with the same key returns the same error. The exception is a 400 with code VALIDATION_ERROR: it isn’t cached, so you can fix the body and retry with the same key.

Key expiration

Idempotency keys expire after 24 hours. After expiration, the same key can be reused for a new request.

Best practices

  • Generate a new UUID v4 for each unique operation. Do not reuse keys across different operations.
  • Store the key before sending the request. If your application crashes mid-request, you can safely retry with the same key.
  • Use idempotency keys on every request that accepts them, especially transactions and customer creation.