# Implementation and Details

### **4.2.2 Implementation and Details**

To perform an idempotent request, provide an additional <mark style="color:red;">`Idempotency-Key: <key>`</mark> header to the redemption request.

```bash
# Example of a v4 uuid idempotency key
-H "Idempotency-Key: af9be4e3-685d-4384-99c7-11774722d930"
```

<figure><img src="/files/c4FuOBP3Z4BWorem2vXN" alt=""><figcaption></figcaption></figure>

RedeemSG’s idempotency key works by saving 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. This applies to <mark style="color:red;">`2xx`</mark> and <mark style="color:red;">`4xx`</mark> responses.

An idempotency key is a unique value generated by the client (on your side) which 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, nanoID, 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 are 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.

If the request conflicted (same request body & idempotency key) with another request that was executing concurrently, no idempotent result is saved. It is safe to retry these requests.

<figure><img src="/files/aVb510aT2sVlUaqWsh0R" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://integration-guide.redeem.gov.sg/phase2-integration/api-documentation/redeeming-a-qr-code-voucher/making-idempotent-redemption-requests/implementation-and-details.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
