Skip to content

Idempotency

A network can lose an answer after the order was already placed. The Idempotency-Key header makes a retry safe: the same request sent again with the same key is answered once, never carried out twice.

  • Every write (POST, PUT, PATCH, DELETE) carries an Idempotency-Key header: 1 to 64 printable ASCII characters. Without it: 400 VALIDATION_ERROR, nothing done.
  • The same key with the same body gives the stored answer again, with "replayed": true, and does nothing more.
  • The same key with another body is 422 IDEMPOTENCY_KEY_REUSED, and nothing is done.
  • Use a new key for each new request: a UUID, or your own unique id.

For POST /accounts/{id}/orders, the key is also the order’s client_order_id (and its order_id in every answer and list). You may leave client_order_id out of the body; if you send it, it must be the key itself (400 otherwise). Since an order’s key is a client_order_id, keep it to letters, digits and . _ : -.

An account’s order keys are the account’s, whoever sent them: the terminal or any of your API keys. A key already used on that account names that request: with the same body its answer is replayed, with another body it is a 422.

  1. Send the same request with the same key: you get the first answer (replayed: true) if it went through, or the request is carried out now if it never arrived.

  2. Or look the order up by its key:

    Terminal window
    curl "$API/accounts/$ACCOUNT/orders?client_order_id=$KEY" -H "Authorization: Bearer $PP_KEY"

A 503 with OVERLOADED or STORAGE_UNAVAILABLE says nothing was done, unless the command had already started: in both cases, retry with the same key.

The MCP server makes a key for every write call and returns it as idempotency_key; an assistant retries with that value.