Error response structure
Cashfree APIs typically return a response with a top-level status field and an error payload when the request can’t be completed successfully. A typical error response looks like this:
Use the sub-code as the main decision point in your integration. Error messages can change over time, but the sub-code is the stable signal for handling logic.
How to handle errors
Follow these steps for every API call:- Check the top-level
statusfield first. - If the response is
ERROR, inspect thesubCodeand map it to an action. - For client-side issues such as validation failures, update the request data and resubmit only after correcting the input.
- For temporary service issues such as rate limits or server errors, retry with backoff and jitter.
- If the operation is asynchronous or the transfer moves into a pending state, use the status APIs or webhooks to track the final outcome.
Example
The following example shows a simple pattern for handling a failed response:Common error categories
The exact sub-code can vary by endpoint, but the following categories are the most common in Payouts integrations.Retry and recovery guidance
Retrying isn’t always safe. Retry only when the failure is temporary and the operation can be repeated without creating duplicate outcomes. Treat errors as part of the integration design rather than as an afterthought.- Classify each failure as user-correctable, retryable, or terminal.
- Don’t retry validation errors, authentication failures, or permanent bank declines until the underlying issue is fixed.
- For
429and5XXerrors, retry with exponential backoff and brief jitter. - Preserve the same request reference across retries when possible to avoid duplicate payouts.
- For asynchronous payout flows, don’t assume a request is final until the status API or webhook confirms the terminal state.
When not to retry
Don’t retry automatically when the error is caused by:- Invalid beneficiary or transfer details
- Missing or invalid credentials
- Insufficient balance or account restrictions
- A manual approval step that must be completed first
- A permanent downstream decline or bank rejection
Recommended approach
Build your integration around three outcomes:- Success: Continue the workflow and update the merchant view.
- Retryable failure: Retry the request after a short delay.
- Permanent failure: Stop, surface the issue clearly, check the input accuracy or contact support if needed.