Skip to main content

What is an Idempotency Key?

When you POST a request (create a transfer, etc.) you include a unique Idempotency-Key header. Brale stores that key along with the request signature so if you retry—because the network dropped or timed out—Brale recognizes the duplicate and returns the original response instead of performing the operation twice. The primary goal is to prevent double spends. Without idempotency keys, a retry after a network failure could result in two transfers being created and two debits hitting your customer’s account. Keys are required on all POST requests and should be reused when retrying the exact same operation. Transient failures — like a server error, a timeout, or an insufficient_balance that the customer has since resolved — can all be retried with the same key. Generate a new key only when the request itself is intentionally changing (e.g. fixing a validation error or initiating a second distinct transfer).

When is it required?

If the header is missing on a POST request, Brale returns 400 Bad Request.

Example

Most HTTP clients let you generate a UUID at call time or set a default header.

Request Responses

When to reuse the same key vs. generate a new one

Reuse the same key when retrying the exact same operation: Generate a new key when the request itself is changing:

Insufficient balance

422 insufficient_balance is a special case. The request is valid — the account simply didn’t have enough funds at the time. Once the customer funds their account, they can retry with the same idempotency key and the transfer will be processed. This is different from permanent validation failures (e.g. invalid_account_number), which will always fail regardless of account state. For those, the request itself must change, which requires a new key.

Troubleshooting

Best Practices

  • Generate a UUID per logical action. Store it with your job record so retries use the same value.
  • Do not share keys across different endpoints. Keep one key scoped to one operation.
  • On insufficient_balance, do not generate a new key — store the original key and reuse it after the account is funded.