Click Airtime

Error Codes

Complete reference of V2 API error codes and their meanings.

Error Codes

All V2 API errors follow a consistent format with machine-readable error codes.

Error Response Format

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description of the error.",
    "details": {}
  },
  "meta": {
    "request_id": "req_a1b2c3d4e5f6",
    "timestamp": "2024-01-15T10:30:00.000Z"
  }
}

Authentication Errors

CodeHTTP StatusDescription
INVALID_API_KEY401API key is missing, malformed, or not recognized
EXPIRED_API_KEY401API key has passed its expiration date
REVOKED_API_KEY401API key has been revoked from the Enterprise Portal
IP_NOT_ALLOWED403Request originated from an IP not in the key's allowlist
INSUFFICIENT_PERMISSIONS403API key lacks the required permission for this endpoint

Validation Errors

CodeHTTP StatusDescription
INVALID_PHONE_NUMBER400Phone number format is invalid or unrecognizable
MISSING_REQUIRED_FIELD400A required field is missing from the request body
INVALID_AMOUNT400Amount is outside the allowed range for this network

Network Errors

CodeHTTP StatusDescription
NETWORK_NOT_FOUND404The specified network ID does not exist
UNSUPPORTED_NETWORK400This network is not currently available for top-ups
HLR_LOOKUP_FAILED400Network auto-detection failed. Try specifying network_id manually

Transaction Errors

CodeHTTP StatusDescription
TRANSACTION_NOT_FOUND404No transaction found with the given ID
INSUFFICIENT_BALANCE400Wallet balance is too low for this transaction
DELIVERY_FAILED500Airtime delivery to the provider failed
DUPLICATE_TRANSACTION409A duplicate transaction was detected

Rate Limiting

CodeHTTP StatusDescription
RATE_LIMIT_EXCEEDED429Too many requests. Wait and retry.

System Errors

CodeHTTP StatusDescription
INTERNAL_ERROR500Unexpected server error. Contact support if it persists.

Always check the error.code field programmatically rather than parsing the message string, as messages may change.

Handling Errors

const response = await fetch('https://api.clickairtime.com/v2/topups', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ce_live_xxx',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ /* ... */ }),
});

const result = await response.json();

if (!result.success) {
  switch (result.error.code) {
    case 'INSUFFICIENT_BALANCE':
      // Prompt user to fund wallet
      break;
    case 'INVALID_PHONE_NUMBER':
      // Ask user to re-enter phone number
      break;
    case 'RATE_LIMIT_EXCEEDED':
      // Implement exponential backoff
      break;
    default:
      // Log error for debugging
      console.error('API Error:', result.error);
  }
}