Skip to main content
Networks fail in the worst place: after Laces has created your order or sent the payment prompt, but before the response reaches you. Idempotency keys make the retry safe.

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 /payments key covers the whole body (the order of metadata keys doesn’t matter). It is separate from POST /orders keys. 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 msisdn is 422.
  • 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

  1. Generate a key (a UUID is ideal) when the buyer starts the action, not when you send the request.
  2. Store it with your cart before calling Laces.
  3. 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).
Generating a fresh key on every retry turns the protection off. Two different keys are two different orders.
Last modified on November 26, 2026