How It Works
When an idempotency key is provided with a request:- The server caches the initial response body and its status code.
- If a duplicate request with the same idempotency key and response code is received, the API will return the cached result instead of re-executing the operation, especially if an error occurs within the operation. This mechanism helps prevent unintended duplicate processing by returning consistent results even in error scenarios.
Generating Unique Idempotency Keys
Clients are responsible for creating and refreshing their idempotency keys. To ensure uniqueness:- We strongly recommend using V4 UUIDs, which can be generated with libraries such as these: https://github.com/uuidjs/uuid
- As a best practice, idempotency keys should expire after some time to avoid reuse and ensure the uniqueness of requests. Fluz expires each unique idempotency keys after 10 minutes.
Clients will need:
- An operation to generate and store a new idempotency key
- An operation to remove an old key according to the client’s expiration policy
Required Operations
Not all API operations require idempotency keys. Fluz requires idempotency for certain critical operations to ensure data consistency for the following operations: For these operations, anidempotencyKey input variable is required.
Example Input
Fluz requires an idempotency key for this operation.
Next steps
Purchase Gift Card
See the idempotency key in action on the most common money-moving mutation.
Address formatting
The other common cause of rejected requests — how to format addresses so they validate the first time.