Skip to main content
A network timeout tells you nothing about what happened on the server: the order may have been placed, or not. Retrying blind risks a duplicate trade. An idempotency key removes the risk: re-sending the same key returns the original result instead of creating a second one, so you can retry fearlessly.

Where it applies

Send an Idempotency-Key header on every POST /v1/orders. This is the money-moving write where a duplicate matters most.
Re-send the exact same request with the same key and you get the original order back, not a new one. The key is echoed on the response Idempotency-Key header so you can confirm it was honoured.
The official SDKs attach an Idempotency-Key automatically on order placement (a fresh UUID per call), and let you pass your own when you want to control it. If you build the request yourself, set the header yourself.

How to choose a key

  • One key per logical order. Derive it from something stable in your own system, a UUID you persist with the order row, or a natural key like sell:{scrip_no}:{attempt-group}. The same intent must always produce the same key.
  • Never reuse a key for a different order. The key identifies this order; a new order needs a new key.
  • Keep it opaque and bounded. A UUID is ideal. Do not encode secrets or PII into it.

What it protects against

Pattern: retry loop

The SDKs already retry 429 and transient 5xx for you with backoff, reusing the key you pass, so most integrations never write this loop. It is shown here to make the guarantee explicit: even across process restarts, the same key can never place a second order. The rule is simple: generate the key once, before the first attempt, and reuse it on every retry of the same order. Generating a new key per attempt defeats the protection.