When an API request cannot be completed, our API returns an error response. Handling errors well is what separates a reliable integration from one that confuses customers and creates support tickets. This article explains how errors are structured, the main groups of errors and how your code should respond to each.
How an error response looks
HTTP/1.1 422 Unprocessable Entity
{
"status": "error",
"error": {
"code": "INVALID_AMOUNT",
"message": "The amount is not valid for this operator.",
"field": "amount"
},
"request_id": "rq_8d21f0"
}
Your code should rely on the HTTP status and the error code, not on the wording of the message, which may be improved over time. Always log the request_id; it lets our support team find the exact request.
Groups of errors by HTTP status
| Status | Meaning | Retry? |
|---|---|---|
| 400 / 422 | Request is invalid: missing field, wrong format, value not allowed | No. Fix the input first. |
| 401 | API key missing, wrong or revoked | No. Fix the key. |
| 403 | Not allowed: IP not whitelisted, service not enabled, account restricted | No. Fix the setting. |
| 404 | Endpoint or record not found | No. Check the path or ID. |
| 409 | Conflict, such as a reference ID that has already been used | No. Check the existing transaction. |
| 429 | Too many requests in a short time | Yes, after waiting. |
| 500 / 502 / 503 / 504 | Temporary problem on our side or with a provider | Check status first, then retry carefully. |
Common error codes
The full list is in the documentation. Codes you are likely to meet include:
- INSUFFICIENT_BALANCE: your wallet cannot cover the transaction. Top up and alert your team.
- DUPLICATE_REFERENCE: the reference ID was already used. Check that transaction's status instead of sending a new one.
- INVALID_OPERATOR or INVALID_BILLER: the code is wrong or no longer supported. Refresh your lists.
- SERVICE_UNAVAILABLE: an operator, biller or bank is temporarily down. Show a friendly message and suggest trying later.
- IP_NOT_WHITELISTED: the request came from an address not on your list.
- VALIDATION_ERROR: one or more fields are invalid. The
fieldvalue tells you which.
The golden rule for money-moving requests
For recharges, bill payments and payouts, a network timeout or a 5xx error does not prove the transaction failed. The request may have reached us and be processing. Before retrying:
- Check the transaction status using your reference ID.
- If it is not found, send a new request with a new reference ID.
- If it exists, follow its status. Never send a second payment for the same order while the first is pending.
Showing errors to customers
Translate error codes into short, helpful messages. For example, instead of "VALIDATION_ERROR: number", show "Please enter a valid 10-digit mobile number". For errors the customer cannot fix, such as insufficient balance on your platform's wallet, show a general message like "This service is temporarily unavailable" and alert your own team instead.
Logging and monitoring
- Log the endpoint, your reference ID, the HTTP status, the error code and the request ID.
- Mask sensitive values, such as full account numbers.
- Alert your team when errors of one type suddenly increase.
The examples in this article are simplified to show the flow. Field names, endpoint paths, error codes and response formats can differ by service, so always follow the current reference in our API documentation.
Still stuck?
If an error does not make sense, open a ticket with the request ID, time and endpoint. For authentication errors in particular, see our troubleshooting article on 401 and 403 responses.