Skip to main content

Error Response Structure

When an API request fails, the response will have success set to "false" (string) and include an error object with details.

Error Object

object
Contains error information

Example Error Response

Common Error Codes

Authentication Errors

Cause: Invalid or missing API keySolution:
  • Verify your API key is correct
  • Ensure the API-KEY header is included in the request
  • Check you’re using the right key for the environment (sandbox vs production)

Transaction Errors

Cause: Merchant account doesn’t have enough balance for the transactionSolution:
  • Check your balance using the /api/agent_balance endpoint
  • Add funds to your merchant account
  • Reduce the transfer amount
Cause: Phone number format is incorrectSolution:
  • Use E.164 format without the + sign
  • Format: [country code][subscriber number]
  • Example: 16175551212 for a US number
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
Cause: Recipient account is not KYC verified and cannot receive the transfer amountSolution:
  • Check KYC status using /api/kyc/:account endpoint
  • Direct user to complete KYC verification via the kyc_url provided
  • Reduce transfer amount to within the unverified limit

Server Errors

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
Cause: The API service is temporarily unavailableSolution:
  • Implement retry logic with exponential backoff
  • Wait and retry the request
  • Contact support if the issue persists

Validation Errors

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
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 like internal_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:

Error Handling Checklist

Before deploying to production, ensure you have:
  • Checked the success field 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.