Skip to main content

Error Handling

AWDPay uses standard HTTP codes combined with internal error codes to help you quickly diagnose and resolve issues.

Error response format​

{
"error": {
"code": 40010,
"message": "Invalid amount",
"details": "Amount must be greater than 0"
}
}
FieldTypeDescription
codeIntegerAWDPay error code (see table below)
messageStringHuman-readable message describing the error
detailsStringAdditional details (optional)

Error codes by category​

πŸ” Authentication & Authorization​

CodeNameHTTPDescriptionRecommended Action
401InvalidRole401Invalid or insufficient roleCheck your account permissions
30001KEYCLOAK_ERROR500Authentication server errorRetry, contact support if persistent
40001INVALID_ACCESS403Unauthorized access to this resourceCheck your access rights
40002UNAUTHORIZE_REQUEST401Unauthorized requestCheck your Bearer token

πŸ” Resources not found​

CodeNameHTTPDescriptionRecommended Action
40004RESSOURCE_NOT_FOUND404Resource not foundCheck the resource identifier
40005PHONE_NUMBER_NOT_FOUND404Phone number not foundVerify the format and existence of the number
40006TRX_NOT_FOUND404Transaction not foundCheck the transaction reference
40007OTP_NOT_FOUND404OTP not found or expiredRequest a new OTP
40008CUSTOMER_NOT_FOUND404Customer not foundCheck customer information
40017WALLET_NOT_FOUND404Wallet not foundVerify that the account exists

⚠️ Validation errors​

CodeNameHTTPDescriptionRecommended Action
40010INVALID_AMOUNT400Invalid amountAmount must be > 0
40011INVALID_COUNTRY400Invalid country codeUse a valid ISO 3166-1 alpha-2 code
40012INVALID_GATEWAY400Invalid gatewayCheck the gateway name
40014INVALID_NUMBER400Invalid numberUse international format (+XXX...)
40015INVALID_CURRENCY400Invalid currencyUse an ISO 4217 code (XOF, EUR...)
40016INVALID_JSON_BODY400Invalid JSON bodyCheck JSON syntax
40017INVALID_METHOD400Invalid methodUse a supported HTTP method
40018INVALID_CLIENT400Invalid clientCheck your API credentials
40019INVALID_OTP400Invalid OTP codeCheck the entered code
40020INVALID_OPERATION400Invalid operationThis operation is not allowed
40021INVALID_CALLBACK_URL400Invalid callback URLUse a valid HTTPS URL
40022INVALID_SECRET_CODE400Invalid secret codeCheck your secret code
40023INVALID_REQUEST400Invalid requestCheck request parameters

πŸ’° Balance errors​

CodeNameHTTPDescriptionRecommended Action
40013INSUFFICIENT_BALANCE422Insufficient balanceTop up your merchant account

Standard HTTP codes​

HTTP CodeMeaningDescription
200OKRequest successful
201CreatedResource created successfully
400Bad RequestInvalid parameters
401UnauthorizedMissing or invalid token
403ForbiddenAccess denied
404Not FoundResource not found
422Unprocessable EntityBusiness validation failed
429Too Many RequestsRate limit reached
500Internal Server ErrorServer error
502Bad GatewayExternal gateway error
503Service UnavailableService temporarily unavailable

Error handling by type​

4xx errors (Client)​

These errors are caused by invalid data. Do not retry without correcting the request.

async function handleClientError(response) {
const error = await response.json();

switch (error.code) {
case 40010: // INVALID_AMOUNT
throw new Error('Invalid amount: must be greater than 0');

case 40013: // INSUFFICIENT_BALANCE
throw new Error('Insufficient balance for this operation');

case 40014: // INVALID_NUMBER
throw new Error('Invalid number format');

default:
throw new Error(error.message);
}
}

5xx errors (Server)​

These errors are temporary. Retry with exponential backoff.

async function retryWithBackoff(fn, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error) {
if (error.status >= 500 && attempt < maxRetries - 1) {
const delay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
throw error;
}
}
}

Idempotence and retry​

Using the Idempotency-Key header​

To avoid duplicates during retries, use an idempotency key:

curl -X POST "https://app.awdpay.com/api/deposits/initiate" \
-H "Authorization: Bearer $AWDPAY_TOKEN" \
-H "Idempotency-Key: order-1234-attempt-1" \
-H "Content-Type: application/json" \
-d '{...}'
AttemptDelayAction
1ImmediateFirst attempt
21 secondIf 5xx error or timeout
32 secondsIf 5xx error or timeout
44 secondsIf 5xx error or timeout
5+AbandonAlert technical team
Never retry
  • 4xx errors (except 429 Too Many Requests)
  • INSUFFICIENT_BALANCE errors
  • INVALID_* errors

Best practices​

βœ… Do​

  • Log all errors with code, message and timestamp
  • Use idempotency keys for creation operations
  • Implement a circuit breaker for recurring errors
  • Display clear user messages (not technical codes)

❌ Don't​

  • Expose internal codes to end users
  • Retry blindly without analyzing the error
  • Ignore errors β€” log them even if non-blocking

Support​

If you encounter persistent errors:

  1. Note the error code, message and timestamp
  2. Retrieve the transaction reference if available
  3. Contact support via the AWDPay dashboard
  4. Provide request/response logs (without sensitive data)

Next steps​

  1. Authentication β†’ Configure your token
  2. Collections β†’ Accept payments
  3. Disbursements β†’ Send funds