Idempotency

Guarantee that each POST request executes exactly once.

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.

Idempotency-Key: 123e4567-e89b-12d3-a456-426614174000


When is it required?

Endpoint typeIdempotency‑Key header
POST /… (create)Required
GET /…, PUT/PATCH /…, DELETE /…Do NOT include

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


Example

curl --request POST \
  --url "https://api.brale.xyz/accounts/${ACCOUNT_ID}/transfers" \
  --header "Authorization: Bearer ${AUTH_TOKEN}" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $(uuidgen)" \
  --data '{
    "amount": {"value": "10", "currency": "USD"},
    "source": {"value_type": "usd", "transfer_type": "wire"},
    "destination": {
      "address_id": "'"${ADDRESS_ID}"'",
      "value_type": "sbc",
      "transfer_type": "base"
    }
  }'

Tip: most HTTP clients let you generate a UUID at call time or set a default header.


Request responses

ScenarioStatusBody
First successful call201 CreatedNormal JSON response
Retry with same body201 CreatedSame JSON as first call
Retry with same key but different body422 Unprocessable Entity{ "This Idempotency-Key can't be reused with a different payload or URI"" }

Troubleshooting

ErrorLikely causeFix
400 Missing Idempotency‑KeyHeader omitted on POST/PUTAdd a unique key (UUID).
422 Unprocessable EntityRe‑used key with different request bodyGenerate a fresh key per logical action.

Best practices

  1. Generate a UUID per logical action. Store it with your job record so retries use the same value.
  2. Do not share keys across different endpoints. Keep one key scoped to one operation.