Errors and retries
Retry safely without creating conflicting payment attempts
The API returns JSON errors in a consistent shape:
Idempotency keys
Send an idempotency-key header when creating an onramp or offramp. Generate the value once per logical
customer transaction and never reuse it for a different payment.
If the client loses the initial response:
- Retain the original idempotency key.
- Check transaction status using that transaction ID before creating another payment.
- Retry transient network failures with exponential backoff and jitter.
- Stop retrying automatically when the API returns a validation or business-rule error.
Never generate a fresh idempotency key merely because a client timeout occurred. The original request may already have reached Clixpesa or the payment provider.
