error.details is included only for some errors (for example WALLET_TYPE_UNAVAILABLE) and may be omitted.
Authentication Errors
Code
HTTP Status
Description
INVALID_API_KEY
401
API key is missing, malformed, or not recognized
EXPIRED_API_KEY
401
API key has passed the expiry date set when it was created in the Enterprise Portal
REVOKED_API_KEY
401
API key has been revoked from the Enterprise Portal
IP_NOT_ALLOWED
403
Request originated from an IP not in the key's allowlist
INSUFFICIENT_PERMISSIONS
403
API key lacks the required permission for this endpoint
Validation Errors
Code
HTTP Status
Description
INVALID_REQUEST
400
The request is malformed: a header or query parameter is invalid (e.g. Idempotency-Key is empty or longer than 255 characters; page/per_page is not a positive integer; status is not pending, processing, completed, or failed; from/to is not a valid ISO 8601 date), or a top-up sent bothamount and product_id
INVALID_PHONE_NUMBER
400
Phone number is missing or not in E.164 format (+ followed by digits)
MISSING_REQUIRED_FIELD
400
A required field is missing — e.g. a top-up sent neither amount nor product_id, or a catalog lookup sent neither phone_number nor network_id
INVALID_AMOUNT
400
The custom amount cannot be sent: amount.value is not a positive number or is outside the network's custom_airtime.min_amount_local..max_amount_local; amount.currency is not the network's custom_airtime.local_currency; or the network does not offer custom amounts (custom_airtime.available: false — send a product_id instead)
INVALID_PRODUCT
400
product_id is not an integer id from fixed_bundles for this network — e.g. a string, an unknown or inactive id, a bundle from another network, or an open-range product
Network Errors
Code
HTTP Status
Description
NETWORK_NOT_FOUND
404
The specified network ID does not exist
UNSUPPORTED_NETWORK
400
This network is not currently available for top-ups
GET /v2/balance/:wallet_id was called with a wallet ID that does not exist or does not belong to your company
WALLET_RESTRICTED
400
The selected wallet's geography rules forbid this destination (e.g. a ZMW wallet cannot pay for a Malawi top-up). Use your USD global wallet, or a wallet whose currency matches the destination country.
WALLET_TYPE_UNAVAILABLE
400
You requested wallet_mode: "global" but your company has no USD wallet, or wallet_mode: "local" and your company has no local-currency wallet for the destination country.
Transaction Errors
Code
HTTP Status
Description
TRANSACTION_NOT_FOUND
404
No transaction found with the given ID
INSUFFICIENT_BALANCE
400
Wallet balance is too low for this transaction
DUPLICATE_REQUEST
409
The same top-up is still being processed — a request with the same Idempotency-Key (or, without a key, the same body within 5 minutes) has not finished yet. Nothing is sent twice. Wait a few seconds and retry with the same key, or check GET /v2/topups?reference=....
DELIVERY_FAILED
500
The operator did not deliver the top-up. The transaction is recorded with status failed.
Duplicates are not an error. Repeating a POST /v2/topups with the same Idempotency-Key within 24 hours returns the original transaction (same id) instead of creating a new one, and your wallet is not charged again. See Send Airtime.
Rate Limiting
Code
HTTP Status
Description
RATE_LIMIT_EXCEEDED
429
Too many requests for this API key. Wait the number of seconds in the Retry-After response header, then retry. See Rate Limits.
System Errors
Code
HTTP Status
Description
INTERNAL_ERROR
500
Unexpected 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_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', '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': // Wait for the Retry-After header (seconds), then retry break; default: // Log error for debugging console.error('API Error:', result.error); }}