Idempotency
A network error or timeout can leave you unsure whether a request reached Paid. Send an Idempotency-Key header on POST and PATCH requests and you can retry them without creating a second customer, order or credit grant: Paid runs the request once and returns the same response to every retry.
Sending a key
Generate a unique key for each operation, such as a UUID, and send it in the Idempotency-Key header. Keep the key with the operation so a retry sends the same one.
A key is 1 to 255 printable ASCII characters with no spaces. Any other value returns 400 with the invalid_idempotency_key code.
The header is optional, and Paid ignores it on GET and DELETE, which are already safe to repeat.
Retrying a request
When a request arrives with a key Paid has already seen, the result depends on the first request:
A replay returns the original status code, body and Paid-Version, even if your account’s default version has changed since.
Validation errors are stored like any other response, so fixing the request body means sending a new key.
Reusing a key
A key belongs to one request. Sending it with a different method, path or body returns 409 with the idempotency_key_reused code, and the new request does not run.
Keys are scoped to your organization, so two organizations can use the same key without colliding.
Key expiry
Paid keeps a key and its response for 24 hours from the first request. After that the key is forgotten, and a request that sends it runs as new. Retry within that window.