Skip to main content
Networks fail. A request can reach us and place an order, and the response can still be lost on the way back. The Trading API is built so that you can always retry, and never place an order twice by accident.

The rule

Retry with the same client_order_id and the same body. Choose a new client_order_id only for a new order.
  • If the first request placed the order, the retry returns that order with 200 and the header Idempotent-Replayed: true. Nothing new is placed.
  • If the first request placed nothing, the retry places the order now, with 201.
Either way, you end up with exactly one order.
Never retry with a new client_order_id. If the first request did place an order, you now have two.

When to retry

An error response always means that nothing was recorded. The one exception is 503 and 500, where the order may have been recorded before the failure, which is exactly the case a retry with the same client_order_id handles.

A retrying client

Create the client_order_id once, before the first attempt, and reuse it for every retry of that order. If your program can restart mid-order, save the ID before sending, so the restarted program retries the same order instead of placing a new one.

Looking an order up

To check whether a request was recorded without retrying it, look the order up by its client_order_id:
A 404 order_not_found means no order was recorded under that ID, so nothing traded. Retrying the original request is still the simplest way to finish: it covers both outcomes in one call.

Reusing an ID for a different order

A client_order_id belongs to one order forever. Sending it with a different body returns 409 client_order_id_reused. The error names the existing order and lists the fields that differ:
A rejected order keeps its client_order_id too. To try again after a rejection, use a new one.

Pending orders

A pending order is recorded and may already be at the exchange. Don’t place it again. Read it until it is final:
Most orders are final within a second. An order still pending after a minute is waiting for the exchange to confirm what happened. It becomes final on its own, and we never guess the outcome.