Skip to main content

Errors

When errors occur, the mail2many API returns an HTTP status code, an error code, and a readable message. This helps you diagnose and fix issues quickly.

HTTP status codes

CodeMeaning
200OK — Request successful
201Created — Resource created
204No Content — Successful, no content returned
400Bad Request — Invalid request
401Unauthorized — Authentication failed
404Not Found — Resource not found
409Conflict — Resource already exists
422Unprocessable Entity — Validation failed
429Too Many Requests — Rate limit exceeded
500Internal Server Error — Server-side error

Error codes

CodeTitleDescription
401Invalid credentialsThe API key is invalid or missing
1000Unknown errorAn unexpected error occurred
1001Internal errorAn internal API error occurred
1002Validation failedThe provided data is invalid
1020Error fetching resourceThe resource could not be found
1021Error creating resourceThe resource could not be created
1022Error updating resourceThe resource could not be updated
1023Error deleting resourceThe resource could not be deleted
1024Resource already existsThe resource already exists
1025Resource is lockedThe resource is locked and cannot be modified
1100Too many failed authenticationsThe API key failed authentication too many times

Error response format

Error responses follow this format:

{
"status": "error",
"code": 1002,
"message": "The given data was invalid.",
"errors": {
"email": [
"The email must be a valid email address."
],
"firstname": [
"The firstname must be a string."
]
},
"statusCode": 422
}

The errors field contains all invalid fields and their specific reasons.

Error handling flow

How to handle different types of errors:

API Request

├─→ 200/201 ✓ Success
│ └─→ Continue with next request

├─→ 400/422 ✗ Validation error
│ └─→ Check errors field
│ └─→ Correct data
│ └─→ Retry request

├─→ 401 ✗ Authentication failed
│ └─→ Check API key
│ └─→ Use correct API key
│ └─→ Retry request

├─→ 404 ✗ Resource not found
│ └─→ Check ID/parameters
│ └─→ Use correct resource

├─→ 429 ✗ Rate limit exceeded
│ └─→ Check Retry-After header
│ └─→ Wait X seconds
│ └─→ Retry request

└─→ 500 ✗ Server error
└─→ Exponential backoff
├─→ Attempt 1: after 1 second
├─→ Attempt 2: after 2 seconds
├─→ Attempt 3: after 4 seconds
└─→ Maximum 3 attempts, then abort

Handling errors

  • Check the response statusCode
  • Read the message for a human-readable explanation
  • For 1002 (validation): inspect errors to identify invalid fields
  • For 401: verify your API key
  • For 429: check Rate Limiting and reduce request rate or parallel requests
  • Correct the data and retry the request

For endpoint-specific errors, refer to the documentation of the respective endpoint.