Error Response Structure
When an API request fails, the response will havesuccess set to "false" (string) and include an error object with details.
Error Object
Contains error information
Example Error Response
Common Error Codes
Authentication Errors
authentication_error
authentication_error
Cause: Invalid or missing API keySolution:
- Verify your API key is correct
- Ensure the
API-KEYheader is included in the request - Check you’re using the right key for the environment (sandbox vs production)
Transaction Errors
insufficient_funds
insufficient_funds
Cause: Merchant account doesn’t have enough balance for the transactionSolution:
- Check your balance using the
/api/agent_balanceendpoint - Add funds to your merchant account
- Reduce the transfer amount
invalid_phone_number
invalid_phone_number
Cause: Phone number format is incorrectSolution:
- Use E.164 format without the
+sign - Format:
[country code][subscriber number] - Example:
16175551212for a US number
transfer_not_found
transfer_not_found
Cause: The specified transfer ID doesn’t existSolution:
- Verify the transfer ID is correct
- Check if the transfer was created in the same environment
- Ensure you’re using the ID returned from the transfer creation
kyc_not_verified
kyc_not_verified
Cause: Recipient account is not KYC verified and cannot receive the transfer amountSolution:
- Check KYC status using
/api/kyc/:accountendpoint - Direct user to complete KYC verification via the
kyc_urlprovided - Reduce transfer amount to within the unverified limit
Server Errors
internal_server_error
internal_server_error
Cause: An unexpected error occurred on the serverSolution:
- Retry the request after a brief delay
- If the error persists, contact support
- Check the CashQ status page for any ongoing issues
service_unavailable
service_unavailable
Validation Errors
invalid_request
invalid_request
Cause: Request parameters are missing or invalidSolution:
- Review the endpoint documentation
- Verify all required parameters are included
- Check parameter types and formats
- Ensure JSON is properly formatted
invalid_amount
invalid_amount
Cause: Transfer amount is invalid (negative, zero, or exceeds limits)Solution:
- Ensure amount is a positive number
- Check minimum and maximum transfer limits
- Verify amount format (string with decimal)
Error Handling Best Practices
1. Always Check Success Field
2. Implement Retry Logic
For transient errors likeinternal_server_error, implement retry with exponential backoff:
3. Use Error Codes for Logic
4. Log Errors for Debugging
5. Provide User-Friendly Messages
Don’t show raw error messages to users. Translate error codes into user-friendly messages:HTTP Status Codes
In addition to the error object in the response body, check HTTP status codes:| Status Code | Meaning | Action |
|---|---|---|
| 200 | OK | Check success field in response body |
| 400 | Bad Request | Fix request parameters |
| 401 | Unauthorized | Check API key |
| 404 | Not Found | Verify endpoint URL |
| 429 | Too Many Requests | Implement rate limiting |
| 500 | Internal Server Error | Retry with backoff |
| 503 | Service Unavailable | Retry later |
Error Handling Checklist
Before deploying to production, ensure you have:- Checked the
successfield in all API responses - Implemented retry logic for transient errors
- Used error codes for programmatic handling
- Logged errors for debugging and monitoring
- Provided user-friendly error messages
- Handled authentication errors appropriately
- Tested error scenarios in sandbox
- Set up monitoring and alerting for errors
Need Help?
Contact Support
Encountering persistent errors? Our support team is here to help.
