Overview
Proper error handling is essential for building reliable applications on Monei infrastructure. This guide covers all error types, response formats, recovery strategies, and best practices. What you’ll learn:- Error response structure
- Common error types and codes
- Error handling patterns
- Retry strategies
- Debugging techniques
Error Response Structure
All Monei API errors follow a consistent format:Response Fields
| Field | Type | Description |
|---|---|---|
statusCode | number | HTTP status code (400, 401, 403, 404, 429, 500) |
message | string | Human-readable error description |
error | string | Error category |
details | object | Additional error context (optional) |
HTTP Status Codes
- Client Errors (4xx)
- Server Errors (5xx)
400 Bad Request
- Invalid request parameters
- Malformed JSON
- Missing required fields
- Invalid API key
- Expired token
- Missing authentication
- Insufficient permissions
- KYC tier limit exceeded
- Operation not allowed
- Resource doesn’t exist
- Invalid endpoint
- Transaction not found
- Rate limit exceeded
- Too many requests per minute
- Retry after specified time
Common Error Types
Authentication Errors
UNAUTHORIZED
Common Messages:
- “Invalid API key”
- “API key expired”
- “Missing authentication header”
- Verify API key is correct
- Check environment variable
- Regenerate API key if compromised
- Ensure proper header format:
x-api-key: YOUR_KEY
Insufficient Balance
INSUFFICIENT_BALANCE
Common Causes:
- Not enough token balance
- Insufficient native token for gas
- Reserved balance from pending transactions
- Check available balance vs. required amount
- Ensure enough native token for gas fees
- Wait for pending transactions to complete
- Fund wallet before retrying
Invalid Recipient
INVALID_RECIPIENT
Common Causes:
- Malformed address format
- Wrong network for address
- Contract address without ABI
- Checksum mismatch
- Validate address format before sending
- Verify network matches recipient
- Use address validation endpoint
- Double-check copy/paste
KYC Limit Exceeded
KYC_LIMIT_EXCEEDED
Limits by Tier:
- Tier 1: ₦200,000/day
- Tier 2: ₦500,000/day
- Tier 3: ₦2,000,000/day
- Check remaining daily limit
- Split transaction across multiple days
- Upgrade KYC tier
- Use smaller amounts
Rate Limit Exceeded
RATE_LIMIT_EXCEEDED
Rate Limits:
- Free tier: 100 requests/minute
- Paid plans: 1,000 requests/minute
- Burst allowance: 2x limit for 10 seconds
- Implement exponential backoff
- Cache frequently accessed data
- Use webhooks instead of polling
- Upgrade plan for higher limits
Network Errors
NETWORK_ERROR
Common Causes:
- RPC endpoint timeout
- Network congestion
- Gas price estimation failure
- Blockchain node issues
- Implement retry with exponential backoff
- Increase gas price
- Try different RPC endpoint
- Wait for network congestion to clear
Error Handling Patterns
Try-Catch Pattern
Retry with Exponential Backoff
Circuit Breaker Pattern
Validation Before Requests
Validate inputs before making API calls to catch errors early:Debugging Tips
Enable Debug Logging
Enable Debug Logging
Node.js:Python:
Inspect API Responses
Inspect API Responses
Log full error objects:Check response headers:
Test in Sandbox
Test in Sandbox
Always test error scenarios in sandbox:
Contact Support
Contact Support
When contacting support, provide:
- Request ID (from error headers)
- Timestamp of error
- Full error message
- Request parameters (sanitized)
- Expected vs. actual behavior
Best Practices
Validate Early
Validate all inputs before making API calls to catch errors early
Handle Gracefully
Show user-friendly error messages, not raw API errors
Implement Retries
Use exponential backoff for transient errors
Log Everything
Log errors with full context for debugging
Next Steps
Testing
Test error scenarios in sandbox environment
Webhooks
Get real-time error notifications
Support
Contact support for help with errors
FAQ
Common questions and solutions

