The API supports idempotency for safely retrying requests without accidentally performing the same operation twice. When creating or updating an object, use an idempotency key. Then, if a connection error occurs, you can safely repeat the request without the risk of creating a second object or performing the update twice.

To perform an idempotent request, provide an additional Idempotency-Key: header to the request.

Kosmo idempotency saves the resulting status code and body of the first request made for any given idempotency key, regardless of whether it succeeded or failed. Subsequent requests with the same key return the same result, including 500 errors.

An idempotency key is a unique value generated by the client that the server uses to recognize subsequent retries of the same request. How you create unique keys is up to you, but we suggest using V4 UUIDs or another random string with enough entropy to avoid collisions. Idempotency keys can be up to 255 characters long.

Keys are eligible to be removed from the system automatically after they're at least 24 hours old, and a new request is generated if a key is reused after the original has been pruned. The idempotency layer compares incoming parameters to those of the original request and errors unless they're the same to prevent accidental misuse.

All POST requests accept idempotency keys. Sending idempotency keys in GET and DELETE requests has no effect and should be avoided, as these requests are idempotent by definition.

If the first request is still in progress, then the second request with the same idempotency key will wait for the first request to finish and return its result to you. If the first request is still in progress for a while, then the subsequent request will return 409 Conflict - Request is in progress.

If you use the same idempotency key, but your request data has changed, we will return the error 409 Conflict - Request is changed. This will help you to prevent creating the order by the first request, not by the second one.