HTTP Status Codes
Evolution API implements the following HTTP status codes (src/api/routes/index.router.ts:28-36):
| Status Code | Name | Description |
|---|---|---|
200 | OK | Request succeeded |
201 | CREATED | Resource created successfully |
400 | BAD_REQUEST | Invalid request parameters or body |
401 | UNAUTHORIZED | Missing or invalid authentication |
403 | FORBIDDEN | Valid authentication but insufficient permissions |
404 | NOT_FOUND | Requested resource does not exist |
500 | INTERNAL_SERVER_ERROR | Server encountered an unexpected error |
All error responses include a consistent JSON structure for easy parsing and error handling.
Error Response Format
Evolution API error responses follow this standard format:The HTTP status code (400, 401, 403, 404, or 500)
A human-readable error name matching the HTTP status
Detailed error description. Can be a string or array of error messages
Error Types and Exceptions
Evolution API defines custom exception classes insrc/exceptions/:
400 Bad Request
Implementation:src/exceptions/400.exception.ts
Thrown when the request contains invalid parameters, missing required fields, or fails validation.
- Missing required fields in request body
- Invalid data types (string instead of number)
- JSONSchema validation failures
- Malformed JSON in request body
- Invalid phone number formats
- File upload errors
Missing Required Field
Missing Required Field
Request:Response (400):
Invalid Data Type
Invalid Data Type
Request:Response (400):
Group JID Format Error
Group JID Format Error
Request:Response (400):The validation logic is in
src/api/abstract/abstract.router.ts:96-144.401 Unauthorized
Implementation:src/exceptions/401.exception.ts
Thrown when authentication is missing or invalid.
- Missing
apikeyheader - Invalid global API key
- Invalid instance token
- Using instance token for another instance
- Expired or revoked credentials
Missing API Key Header
Missing API Key Header
Request:Response (401):Validated in
src/api/guards/auth.guard.ts:15-17.Invalid API Key
Invalid API Key
Request:Response (401):The key is validated against both the global key and instance tokens in
src/api/guards/auth.guard.ts:19-50.Wrong Instance Token
Wrong Instance Token
Request:Response (401):
403 Forbidden
Implementation:src/exceptions/403.exception.ts
Thrown when authentication is valid but the operation is not permitted.
- Using instance token to create instances (requires global key)
- Attempting to access protected administrative endpoints
- IP address not in metrics allowlist
- Invalid metrics authentication
Instance Token Used for Creation
Instance Token Used for Creation
Request:Response (403):Instance creation requires the global API key (
src/api/guards/auth.guard.ts:23-25).Metrics IP Not Allowed
Metrics IP Not Allowed
Request:Response (403):IP validation is in
src/api/routes/index.router.ts:48-63.Asset Path Traversal Blocked
Asset Path Traversal Blocked
Request:Response (403):Path traversal protection is in
src/api/routes/index.router.ts:169-183.404 Not Found
Implementation:src/exceptions/404.exception.ts
Thrown when the requested resource does not exist.
- Instance name does not exist
- Chat or message ID not found
- Group JID does not exist
- Contact not in WhatsApp database
- File or media not found
Instance Not Found
Instance Not Found
Request:Response (404):
Chat Not Found
Chat Not Found
Request:Response (404):
Media File Not Found
Media File Not Found
Request:Response (404):File existence check is in
src/api/routes/index.router.ts:185-190.500 Internal Server Error
Implementation:src/exceptions/500.exception.ts
Thrown when the server encounters an unexpected error.
- Database connection failures
- WhatsApp connection errors
- Unhandled exceptions in business logic
- External service timeouts
- File system errors
- Memory or resource exhaustion
Database Connection Error
Database Connection Error
Response (500):Database errors are logged and caught by the error handling middleware.
WhatsApp Connection Timeout
WhatsApp Connection Timeout
Response (500):
Metrics Configuration Error
Metrics Configuration Error
Request:Response (500):Returned when metrics auth is required but not configured (
src/api/routes/index.router.ts:71-73).Validation Errors
Evolution API uses JSONSchema7 for request validation (src/api/abstract/abstract.router.ts:46-60). Validation errors return detailed information:
Single Validation Error
Multiple Validation Errors
Schema Description Override
If the JSONSchema includes adescription field, it’s used as the error message:
Error Handling Best Practices
Client-Side Error Handling
Implement comprehensive error handling in your client code:Retry Logic for 500 Errors
Implement exponential backoff for transient server errors:Logging and Monitoring
Log errors for debugging and monitoring:Troubleshooting Common Errors
”Unauthorized” on Valid Requests
Symptoms:- Receiving 401 errors despite using correct API key
- Authentication works in some environments but not others
-
Check header name: Ensure you’re using
apikey(lowercase) -
Verify no extra whitespace: Trim API keys before sending
-
Check instance exists: Verify the instance name is correct
-
Database check: Ensure instance token matches database record
”Bad Request” with Unclear Messages
Symptoms:- Receiving 400 errors with generic validation messages
- Not sure which field is causing the error
-
Enable debug logging: Check server logs for detailed validation errors
-
Test with minimal payload: Start with required fields only
- Validate JSON syntax: Use a JSON validator to ensure proper formatting
-
Check data types: Ensure strings are quoted, numbers are not
”Instance not found” Immediately After Creation
Symptoms:- Instance creation succeeds (201 response)
- Immediate subsequent requests return 404
-
Check instance name: Ensure you’re using the exact name from creation
-
Wait for initialization: Add a small delay after creation
-
Check database: Verify instance was persisted
”Internal Server Error” on Message Send
Symptoms:- Message endpoint returns 500 error
- Other endpoints work fine
-
Check instance connection: Ensure instance is connected to WhatsApp
-
Verify phone number format: Use international format without ’+’
-
Check server logs: Look for specific error messages
-
Test WhatsApp connection: Try reconnecting the instance
Error Logging
Evolution API logs errors using the Logger service (src/config/logger.config.ts):
Error logs include timestamps, context, and stack traces for debugging. Monitor logs in production to identify patterns and fix issues proactively.
Next Steps
Authentication
Learn about API authentication and tokens
API Overview
Return to API overview
Instance Management
Create and manage instances
Send Messages
Start sending WhatsApp messages