Send an Idempotency Key
Add anIdempotency-Key header to POST /api/v1/embedded/payment-requests. Use a unique value (a UUID v4 is ideal) for each logical payment attempt: 1 to 255 printable ASCII characters, with no spaces, double quotes or backslashes.
"3f9a2c10-7b6e-4a1c-9d2f-8e5b1c4a6f3d" and 3f9a2c10-7b6e-4a1c-9d2f-8e5b1c4a6f3d are the same key.
The header is optional. Without it, every request creates a new payment request.
See Create a Payment Request for the full request body.
How Replay Works
Quidkey keeps each key for at least 7 days. When a request arrives with a key it already holds, it compares the request body with the one the key first came with.
A replay returns the payment request’s
payment_request_id only, with an Idempotent-Replayed: true header so you can tell it from a new create; the first request’s response has no such header. The checkout values (payment_token, expires_in and hosted_url) are issued once, on the create, so keep them with the order when the create answers. If the create’s response was lost and you never got them, create a new payment request under a new Idempotency-Key: the earlier one is never shown to the customer, so it is never paid. Follow the payment by its payment_request_id through webhooks.
Two bodies match when they hold the same values, whatever the order of their fields. Leaving out merchant_id matches a body that names the merchant your credentials act for.
Idempotency keys are scoped to the partner or merchant account your credentials belong to and to the endpoint: the same key sent to another endpoint is a separate request. Scoping by account means a retry with a new token or after rotating your client secret still replays. The same key value sent by another partner or merchant is an independent request. Keys are accepted from a partner’s or merchant’s API credentials only; a request made with a user’s sign-in that sends one is refused with
400 IDEMPOTENCY_KEY_NOT_SUPPORTED.Concurrent Requests
If two requests carrying the same key arrive before the first finishes, the second returns409 IDEMPOTENCY_IN_PROGRESS. The first request is still being processed, so retry with the same key and the same body to pick up its result. Keep retrying with exponential backoff for at least 5 minutes: if the first request was interrupted before it finished, its key is held for up to 5 minutes before a retry can create the payment request.
Reusing a Key for Another Request
A key belongs to the request it first came with. Sending it with a different body (another amount, another merchant) returns422 IDEMPOTENCY_KEY_REUSED and creates nothing. Don’t retry: use a new key for the new request.
Best Practices
One key per logical attempt
One key per logical attempt
Generate a fresh key when you start a new payment attempt. Persist it alongside your order so retries of that same attempt reuse it.
Reuse the key when retrying
Reuse the key when retrying
On a timeout or transient error, retry with the same key and the same body. A new key on retry defeats the protection and can create a duplicate.
Use a fresh key for a genuinely new attempt
Use a fresh key for a genuinely new attempt
If the customer deliberately starts over (e.g. a new checkout for a new basket), mint a new key, since it is a different logical attempt.
Next Steps
Errors
Status codes including 409 and 422
Create a Payment Request
Create an embedded payment request
Authentication
Obtain and refresh access tokens
Webhooks
Receive payment results reliably