Mailzeno LogomailzenoDocs

Error Codes

Mailzeno provides structured errors at every layer — the SDK, the REST API, and the core SMTP engine. All errors return a consistent JSON response.

Error response format

All error responses follow a consistent structure:

Error Response
{
"error": "Human readable error message",
"code": "error_code_string"
}
FieldTypeDescription
errorstringHuman-readable error description
codestringMachine-readable error code

API error codes

StatusCodeDescription
400missing_required_fieldssmtpId, from, or to is missing
400missing_email_contentNo subject/html and no template specified
401invalid_auth_headerMissing or malformed Authorization header
401invalid_api_keyAPI key is invalid or has been deactivated
429rate_limit_exceededToo many requests (check retry-after header)
500profile_not_foundUser profile could not be located
500email_send_failedSMTP sending failed
500internal_server_errorUnexpected server error

Core engine error codes

The @mailzeno/core SMTP engine provides specific error classes for SMTP-level failures:

CodeClassDescription
VALIDATION_ERRORValidationErrorInvalid input (missing from, to, or subject)
RENDER_ERRORRenderErrorReact email rendering failed
SMTP_CONNECTION_ERRORSMTPConnectionErrorCould not connect to SMTP server
SMTP_AUTH_ERRORSMTPAuthErrorSMTP authentication failed (wrong credentials)
SMTP_RESPONSE_ERRORSMTPResponseErrorSMTP server returned an error
SMTP_TIMEOUT_ERRORSMTPTimeoutErrorSMTP connection timed out
UNKNOWN_ERRORMailzenoErrorUnexpected error (base class)

SDK error handling

The SDK throws MailzenoError with HTTP status, error code, and request ID:

import { MailZeno } from "@mailzeno/client"

try {
await mz.emails.send(payload)
} catch (err) {
console.error("Message:", err.message)
console.error("Status:", err.status)       // e.g. 401, 429, 500
console.error("Code:", err.code)           // e.g. "invalid_api_key"
console.error("Request ID:", err.requestId) // x-request-id header
}

Error examples

Missing fields

400 Bad Request
{
"error": "Missing required fields: smtpId, from, to",
"code": "missing_required_fields"
}

Authentication error

401 Unauthorized
{
"error": "Invalid or missing API key",
"code": "invalid_api_key"
}

Rate limit error

429 Too Many Requests
{
"error": "Rate limit exceeded",
"code": "rate_limit_exceeded"
}

Server error

500 Internal Server Error
{
"error": "Email sending failed",
"code": "email_send_failed"
}