Skip to main content
A request can fail on the way back: a timeout, a dropped connection, a 502 from a proxy. You cannot tell whether the try-on was created, and sending it again could create and charge a second one. Send an Idempotency-Key header and the retry is safe. The first request with a key runs. A repeat of the same request with the same key returns the first response and creates nothing new.

Where it works

Other endpoints ignore the header. Reads, deletes, POST /products and cancelling a batch are already safe to repeat.

Rules

  • The key. Any unique string of 1 to 255 ASCII characters. A UUID works, so does your own ID for the job, such as order-1001-tryon.
  • Kept 24 hours. After that, the same key starts a new request.
  • Per account. Two accounts can use the same key.
  • A replayed response carries the header Idempotency-Replayed: true. It is the response of the first request: for POST /try-on, status is what it was at creation, so read the current one from Generation Status.
  • A failed request frees its key. If the first request returned an error, the retry runs again.

Errors

With the SDK

@genlook/api sends a fresh key with every tryOn.create, tryOn.createSync and batches.create, and reuses it on its own retries. Pass your own key to retry a call yourself later, from a queue or after a crash: