Where is an Idempotency-Key required?
A missing key is
400 idempotency_key_required.
How does idempotency behave?
- Keys are scoped to your API client. Another client sending the same string never collides with yours, so a key only has to be unique within your own integration.
- A
POST /paymentskey covers the whole body (the order ofmetadatakeys doesn’t matter). It is separate fromPOST /orderskeys. To replace a payment that can no longer be paid, use a new key: there is no route that changes a payment’s price. - A pay key is bound to the order and the phone number. Sending the same
key for a different order or a different
msisdnis422. - Use a different key for create and for pay. They are two logical actions.
On the two event routes, a retry with the same key replays the stored result,
even when that request used up the last draft or ticket-type place and even
when the response failed to build after the event was written. A new key at a
cap still gets
draft_limit_reached or ticket_type_limit_reached. In the
rare case that a Laces server died before recording what it wrote, the key
stays “in progress” and is taken over after 2 minutes, which can create
the event twice. The API cannot find a lost draft in v1 (list never
returns drafts and has no partner_reference filter), so check your
organization’s drafts in the Laces app before retrying after a long timeout. See Create and publish events.Doing it right
- Generate a key (a UUID is ideal) when the buyer starts the action, not when you send the request.
- Store it with your cart before calling Laces.
- On a timeout, a network error or a
5xx, retry with the same key. Except pay: read the order (it can still be running: wait 3 minutes), because a retry can send a new prompt (details).