Error Handling
Zentra uses conventional HTTP response codes and returns detailed error information to help you debug issues quickly.Error Response Format
All errors follow this structure:Error Object
| Field | Type | Description |
|---|---|---|
code | string | Machine-readable error code |
message | string | Human-readable error message |
field | string | Field that caused the error (if applicable) |
status | number | HTTP status code |
details | object | Additional error details (optional) |
HTTP Status Codes
2xx Success
| Code | Name | Description |
|---|---|---|
200 | OK | Request successful |
201 | Created | Resource created successfully |
204 | No Content | Request successful, no content returned |
4xx Client Errors
| Code | Name | Description |
|---|---|---|
400 | Bad Request | Invalid request format or parameters |
401 | Unauthorized | Missing or invalid API key |
403 | Forbidden | API key lacks required permissions |
404 | Not Found | Resource doesn’t exist |
409 | Conflict | Request conflicts with current state |
422 | Unprocessable Entity | Validation failed |
429 | Too Many Requests | Rate limit exceeded |
5xx Server Errors
| Code | Name | Description |
|---|---|---|
500 | Internal Server Error | Something went wrong on our end |
502 | Bad Gateway | Upstream service error |
503 | Service Unavailable | API temporarily offline |
504 | Gateway Timeout | Request took too long |
Error Codes
Authentication Errors
| Code | HTTP Status | Description |
|---|---|---|
unauthorized | 401 | Missing or invalid API key |
invalid_api_key | 401 | API key format is incorrect |
expired_api_key | 401 | API key has been revoked |
insufficient_permissions | 403 | API key lacks required permissions |
wrong_environment | 401 | Using sandbox key on live endpoint or vice versa |
Validation Errors
| Code | HTTP Status | Description |
|---|---|---|
validation_error | 422 | Request validation failed |
missing_required_field | 422 | Required field is missing |
invalid_format | 422 | Field format is incorrect |
invalid_value | 422 | Field value is not allowed |
Resource Errors
| Code | HTTP Status | Description |
|---|---|---|
resource_not_found | 404 | Resource doesn’t exist |
resource_already_exists | 409 | Resource already exists |
resource_deleted | 410 | Resource has been deleted |
resource_locked | 423 | Resource is locked for processing |
Transaction Errors
| Code | HTTP Status | Description |
|---|---|---|
insufficient_balance | 422 | Wallet balance is too low |
invalid_amount | 422 | Amount is invalid or out of range |
duplicate_transaction | 409 | Transaction with same reference exists |
transaction_failed | 422 | Transaction processing failed |
account_inactive | 422 | Account is not active |
daily_limit_exceeded | 422 | Daily transaction limit exceeded |
invalid_bank_code | 422 | Bank code is not supported |
Rate Limiting Errors
| Code | HTTP Status | Description |
|---|---|---|
rate_limit_exceeded | 429 | Too many requests |
Server Errors
| Code | HTTP Status | Description |
|---|---|---|
internal_error | 500 | Unexpected server error |
service_unavailable | 503 | API temporarily offline |
gateway_timeout | 504 | Request timeout |
Handling Errors
JavaScript/Node.js
Python
PHP
Best Practices
Always Handle Errors
Always Handle Errors
Wrap all API calls in try-catch blocks and handle different error types appropriately.
Use Error Codes, Not Messages
Use Error Codes, Not Messages
Error messages may change. Always check the
code field for programmatic error handling.Log Request IDs
Log Request IDs
Include the
request_id from error responses when contacting support.Implement Retry Logic
Implement Retry Logic
For
5xx errors and rate_limit_exceeded, implement exponential backoff retry logic.Show User-Friendly Messages
Show User-Friendly Messages
Don’t expose raw error messages to users. Map errors to friendly messages.
Monitor Error Rates
Monitor Error Rates
Track error rates in your application to catch issues early.
Retry Logic
For transient errors (network issues, timeouts, server errors), implement retry logic:Error Monitoring
Integrate error tracking tools like Sentry:Getting Help
If you encounter errors you don’t understand:- Check this error reference
- Search our FAQ
- Contact support with the
request_idfrom the error response - Review Support and escalation paths
Next Steps
Rate Limits
Learn about rate limiting
Webhooks
Handle events asynchronously
Testing
Test error scenarios in sandbox
FAQ
Common questions and answers