Skip to main content

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


HTTP Status Codes

400 Bad Request
  • Invalid request parameters
  • Malformed JSON
  • Missing required fields
401 Unauthorized
  • Invalid API key
  • Expired token
  • Missing authentication
403 Forbidden
  • Insufficient permissions
  • KYC tier limit exceeded
  • Operation not allowed
404 Not Found
  • Resource doesn’t exist
  • Invalid endpoint
  • Transaction not found
429 Too Many Requests
  • Rate limit exceeded
  • Too many requests per minute
  • Retry after specified time

Common Error Types

Authentication Errors

Error Code: UNAUTHORIZED Common Messages:
  • “Invalid API key”
  • “API key expired”
  • “Missing authentication header”
Solutions:
  • Verify API key is correct
  • Check environment variable
  • Regenerate API key if compromised
  • Ensure proper header format: x-api-key: YOUR_KEY

Insufficient Balance

Error Code: INSUFFICIENT_BALANCE Common Causes:
  • Not enough token balance
  • Insufficient native token for gas
  • Reserved balance from pending transactions
Solutions:
  • 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

Error Code: INVALID_RECIPIENT Common Causes:
  • Malformed address format
  • Wrong network for address
  • Contract address without ABI
  • Checksum mismatch
Solutions:
  • Validate address format before sending
  • Verify network matches recipient
  • Use address validation endpoint
  • Double-check copy/paste

KYC Limit Exceeded

Error Code: KYC_LIMIT_EXCEEDED Limits by Tier:
  • Tier 1: ₦200,000/day
  • Tier 2: ₦500,000/day
  • Tier 3: ₦2,000,000/day
Solutions:
  • Check remaining daily limit
  • Split transaction across multiple days
  • Upgrade KYC tier
  • Use smaller amounts

Rate Limit Exceeded

Error Code: RATE_LIMIT_EXCEEDED Rate Limits:
  • Free tier: 100 requests/minute
  • Paid plans: 1,000 requests/minute
  • Burst allowance: 2x limit for 10 seconds
Solutions:
  • Implement exponential backoff
  • Cache frequently accessed data
  • Use webhooks instead of polling
  • Upgrade plan for higher limits

Network Errors

Error Code: NETWORK_ERROR Common Causes:
  • RPC endpoint timeout
  • Network congestion
  • Gas price estimation failure
  • Blockchain node issues
Solutions:
  • 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

Node.js:
Python:
Log full error objects:
Check response headers:
Always test error scenarios in sandbox:
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