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.

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.

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

Last updated