Error Handling

Understand and handle API errors effectively.

Error Response Format

All errors return a consistent JSON structure with an appropriate HTTP status code.

Standard Error Response

{
  "error": "Detailed error message"
}

Authentication Error Response

{
  "message": "Authentication error message"
}

HTTP Status Codes

CodeNameDescription
200OKRequest succeeded
400Bad RequestInvalid request parameters or body
401UnauthorizedMissing or invalid authentication
403ForbiddenValid authentication but insufficient permissions
404Not FoundRequested resource not found
409ConflictRequest conflicts with current state (e.g., duplicate reference)
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error - retry with exponential backoff
503Service UnavailableService temporarily unavailable

Common Error Messages

Authentication Errors

Error MessageCauseSolution
Invalid tokenAPI key is malformed or incorrectCheck API key format and value
Expired tokenAPI key has expiredGenerate new API key in dashboard
Authorization header requiredMissing Authorization headerInclude Authorization header in request
Session not foundSession has expired or is invalidRe-authenticate with valid API key

Validation Errors

Error MessageCauseSolution
Invalid request bodyMalformed JSON in request bodyValidate JSON syntax
Amount must be greater than 0Zero or negative amountEnsure amount is positive
Reference is requiredMissing reference fieldInclude unique reference
Account number is requiredMissing account numberProvide account number
Bank slug is requiredMissing bank slugProvide valid bank slug
Duplicate referenceReference already existsUse unique reference

Resource Errors

Error MessageCauseSolution
Bank not foundInvalid bank slugUse valid bank slug from List Banks
Transfer not foundInvalid transfer referenceCheck reference is correct
Account not foundAccount doesn't existVerify account details

Error Handling Best Practices

1. Implement Retry Logic

For server errors (5xx status codes), implement exponential backoff retry logic.

2. Parse Error Responses

Always check response status and extract error messages from the response body.

3. User-Friendly Messages

Map technical error messages to user-friendly ones:

  • "Invalid token" → "Please log in again"
  • "Amount must be greater than 0" → "Please enter a valid amount"
  • "Bank not found" → "Please select a valid bank"

4. Logging

Log errors with context including:

  • Timestamp
  • Request details
  • Error message and status code

Rate Limiting

Headers

Rate limit information is included in response headers:

HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRemaining requests in current window
X-RateLimit-ResetUnix timestamp when limit resets
Retry-AfterSeconds to wait before retrying (429 responses)

Handling Rate Limits

When you receive a 429 status code:

  1. Check the Retry-After header for wait time
  2. Implement exponential backoff for subsequent requests
  3. Consider reducing request frequency

Webhook Errors

Webhook Retry Policy

Failed webhook deliveries are retried with exponential backoff:

  • Attempt 1: Immediate
  • Attempt 2: 1 minute
  • Attempt 3: 5 minutes
  • Attempt 4: 30 minutes
  • Attempt 5: 2 hours
  • Attempt 6: 12 hours

Webhook Error Response

Your webhook endpoint should return appropriate status codes:

  • 200 - Successfully processed
  • 401 - Invalid signature (won't retry)
  • 500 - Temporary error (will retry)

Testing Error Scenarios

Test Card Numbers

Use these test account numbers to simulate errors:

Account NumberBank SlugError Type
9999999999anyAccount not found
8888888888anyInvalid account
7777777777anyTransfer failure
6666666666anyNetwork timeout

Test References

Reference PatternBehavior
FAIL-*Always fails
TIMEOUT-*Times out after 30 seconds
DUPLICATE-001Always returns duplicate error

Error Recovery

Use unique references for transfers to ensure requests can be safely retried without creating duplicates.

Getting Help

If you encounter persistent errors:

  1. Check the API Status Page
  2. Review your implementation against this guide
  3. Contact support with:
    • Your merchant ID
    • Request ID from error response
    • Full error details
    • Steps to reproduce

Email: [email protected]


Did this page help you?