Portal

Ansa's APIs support idempotency to safely retry requests without accidentally performing the same operation twice. For example, this is helpful for avoiding accidentally charging a customer twice.

API calls can fail due to network errors or other transient problems. By using the same idempotency key, you can retry a request with the assurance that you won't unintentionally create a duplicate charge.

You can pass an idempotency key with each API request using the Ansa-Idempotency-Key header. All endpoints will accept the Ansa-Idempotency-Key header, but it will only affect endpoints that create financial transactions; the idempotency key will not affect any GET API endpoints.

🚧

Keys will have a lifetime of at least 24 hours

After this period, idempotency keys may be eligible for garbage collection. Please do not intentionally reuse an idempotency key after the 24-hour window. Ansa does not guarantee a timeline for when an individual key will be valid for reuse.


Usage

Please see the cURL request below for an example of using Ansa-Idempotency-Key.

curl  https://api.getansa.com/v1/{merchant_id}/customers/{customer-id}/add-balance
-H "Authorization: ansa_sk_sandbox_c06f7fee-5875-4fb0-81f2-ff29402e101d"
-H "Ansa-Idempotency-Key: 5529d106-a3cb-4452-8698-886995adb420"
-d amount=1000
-d currency=usd
-d payment_method_id="b000731e-0b43-43ac-be02-22a87947742a"

Client SDKs

When using an Ansa provided client SDK, you do not need to manage idempotency keys yourself. The Payment Session manages the idempotency key as part of the session for you.

If you do want to manage idempotency on your own, it is possible to override the idempotency key used in the request by providing it as a parameter in most calls.