Error Handling
All Wava API errors return a consistent JSON structure:Error fields
| Field | Description |
|---|---|
code | Numeric error code |
api_code | Machine-readable error identifier |
message | Short human-readable message |
description | Detailed explanation |
error | Always true for error responses |
gateway_name | Present for gateway-specific errors (6000+) |
validation_errors | Array of field-level errors (for validation failures) |
Validation error example
When validation fails (code2000 or 4005), the response includes an array of field-specific errors:
Gateway error example
When a payment gateway returns an error, the response includes the gateway name:HTTP status codes
| Status | Meaning |
|---|---|
200 | Success |
202 | Accepted (refund processing) |
400 | Bad request / Validation error |
401 | Unauthorized (invalid or missing credentials) |
404 | Resource not found |
422 | Unprocessable (e.g., refund window expired) |
429 | Rate limit exceeded |
500 | Server error |
503 | Service temporarily unavailable |
Best practices
- Always check the HTTP status code first.
- Use
api_codefor programmatic error handling (notmessage, which may change or be localized). - For
400errors, check thevalidation_errorsarray for field-specific issues. - For
500and503errors, retry with exponential backoff. - For gateway errors (6000+), check
gateway_nameto determine which gateway returned the error and handle accordingly.