# Idempotent Requests

The Senmo API supports idempotent requests, preventing accidental duplication of the same API call. This feature is particularly useful when handling operations such as moving funds, creating entities, or modifying resources. For example, if you're creating a Payment Order and the request fails due to a network issue, you can retry the request using the same idempotency key, ensuring the payment order is created only once.

To enable idempotency, include an `Idempotency-Key: <your-key>` header in your request. This key should be unique, ideally something like an internal database UUID.

Once a request with an idempotency key is successfully processed, we store the result for 24 hours. If another request is made with the same key and credentials within that time frame, we will return the original response (including status code and body).

Key points to consider:

* Results are only cached if the request is successfully executed.
* If the original request fails due to connection issues or other errors, the subsequent request will be executed and its result cached.
* Idempotency keys are not route-specific. For instance, if you use the same key to create a payment order and later create a counterparty with that key within 24 hours, you'll receive the cached result of the payment order.
* All POST requests accept idempotency keys.
* GET, PATCH, and DELETE requests are inherently idempotent, so idempotency keys for these requests will be ignored.
* If a request is being processed with a given idempotency key and another request with the same key is received, the newer request will receive a 409 status code.

{% hint style="warning" %}

### Idempotency keys are scoped by your API key

Idempotency keys are tied to the specific API key that initiated the request. If you use different API keys with the same idempotency key, each request will be processed independently, potentially leading to multiple updates.
{% endhint %}

{% code title="Idempotent Request" %}

```
curl --request POST \
  -u x-api-key:API_KEY \
  -H "Idempotency-Key: <your-key>" \
  --url {Sanbox_URL}/api/<endpoint>
```

{% endcode %}


---

# 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://docs.senmo.io/topics/idempotent-requests.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.
