Idempotency-Key: <idempotency-key-value> header.
An idempotency key is a unique value that your client generates. Fintoc uses this key to recognize retries of the same request. Use UUID version 4 values or random strings with enough entropy to avoid collisions. Idempotency keys can contain up to 255 characters.
Fintoc saves the status code and response body from the first request for each idempotency key, whether the request succeeds or fails. Subsequent requests with the same key return the saved result, including 4xx and 5xx errors. Replayed responses include the Idempotent-Replayed: true header.
Authentication neededFintoc does not save an idempotent result when authentication fails because the request does not reach the API endpoint.
400 Bad Request error with the code invalid_idempotent_request.
If you send a request while an earlier request with the same key is still in progress, Fintoc does not process it a second time. Fintoc waits up to about 1 second for the first result and returns it. If the first request has not finished by then, Fintoc returns a 503 Service Unavailable error with the code idempotency_unavailable. Fintoc does not save this 503 response. Retry later with the same key to get the result of the first request.
Retry a transfer safely
A5xx response or a timeout can still mean Fintoc created the transfer. Because Fintoc replays a saved 5xx response, retrying with the same key returns the same error and does not tell you whether the transfer exists.
To avoid sending a payment twice:
- Store your own identifier for each payment in the transfer’s
metadata, and send oneIdempotency-Keyper payment. - If the request times out or the connection drops before you get a response, retry with the same key. You get either the saved result or the result of a new attempt.
- If you get a
5xxresponse, list transfers withaccount_id,direction=outbound, andsinceset to just before your request. Look for a transfer with yourmetadataidentifier. - If you find the transfer, track it through its status and webhooks. If you don’t, create the transfer with a new
Idempotency-Key.
POST requests accept idempotency keys. Sending idempotency keys in GET and DELETE requests has no effect because GET and DELETE requests are idempotent by definition.
The following examples create a charge with an idempotency key. You can retry the request without creating a duplicate charge.