FOMDocs

Safe retries with Idempotency-Key

Send the same write twice without creating two orders.

Networks fail. If a request to create an order times out, you can't tell whether FOM made the order. Send an Idempotency-Key with every POST and PATCH, and a retry with the same key is safe:

curl -X POST https://api.getfom.com/public/v1/orders \
  -H "Authorization: Bearer $FOM_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: pos-sale-20261125-0042" \
  -d '{ "customer_id": "…", "items": [{ "variant_id": "…", "qty": 1 }] }'

How it works

  • The first response for a key is kept for 24 hours. Sending the same key with the same request again returns that response, with meta.idempotent_replay: true, and does nothing new.
  • The same key with a different request gets 422.
  • A retry while the first request is still running gets 409; wait a moment and try again.
  • A request that failed keeps nothing, so you can fix it and retry with the same key.

Keys are yours to choose: up to 255 letters, digits and - _ . :. Use something tied to the action, like your own sale id, or a new random UUID per action. Keys are separate per API key.

The TypeScript SDK sends a key with every write for you.

On this page