Skip to content

Error Codes

When a REST API request fails, the response body contains a JSON error object with a machine-readable code and a human-readable message.

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{ "field": "to", "message": "At least one recipient is required" }
]
}
}

The details array is only present for VALIDATION_ERROR responses and contains field-level error information.

HTTP StatusError CodeDescription
400VALIDATION_ERRORRequest body or query params failed validation
400DOMAIN_NOT_VERIFIEDFrom address uses an unverified domain
400RECIPIENTS_SUPPRESSEDOne or more recipients are on the suppression list
401AUTH_MISSINGNo Authorization header provided
401AUTH_INVALIDAPI key is invalid or revoked
403TENANT_SUSPENDEDOrganization account is suspended
404NOT_FOUNDResource does not exist or is not accessible
405METHOD_NOT_ALLOWEDHTTP method not supported for this endpoint
429RATE_LIMITEDAPI key rate limit exceeded
429LIMIT_EXCEEDEDOrganization email sending limit exceeded
500INTERNAL_ERRORUnexpected server error
{
"error": {
"code": "AUTH_MISSING",
"message": "No Authorization header provided"
}
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{ "field": "from", "message": "From email is required" },
{ "field": "subject", "message": "Subject is required" }
]
}
}
{
"error": {
"code": "RATE_LIMITED",
"message": "API key rate limit exceeded"
}
}

When rate limited, the response includes a Retry-After header with the number of seconds to wait.

{
"error": {
"code": "NOT_FOUND",
"message": "Resource not found"
}
}

Best practices for handling REST API errors:

  • Check the HTTP status code first to determine the error category
  • Use the code field for programmatic error handling (e.g. switch on VALIDATION_ERROR vs AUTH_INVALID)
  • Use the message field for user-facing error display
  • For VALIDATION_ERROR responses, iterate over the details array to show field-specific messages
  • Implement retry logic with exponential backoff for 429 and 500 responses
  • Use the Retry-After header when present to determine wait time
  • Log errors for debugging but don’t expose internal details to end users