Emailens
REST API

Error Handling

HTTP status codes and error response format for the Emailens API.

Error response format

All errors return a JSON object with an error field:

{
  "error": "Description of what went wrong."
}

Some errors include additional fields for context.

Status codes

CodeMeaningWhen
200SuccessRequest processed successfully
400Bad RequestMissing or invalid html field, invalid clients array, empty content
413Payload Too LargeRequest body exceeds 1MB
422Unprocessable EntityJSX or MJML compilation failed
429Too Many RequestsRate limit or daily quota exceeded
500Internal Server ErrorUnexpected server error

Specific errors

Invalid input (400)

{ "error": "Missing or invalid 'html' field. Provide the email HTML, JSX, or MJML as a string." }
{ "error": "Content must not be empty." }
{ "error": "Content exceeds 500KB limit." }
{ "error": "'clients' must be an array of client ID strings." }

Compilation failure (422)

When format is "jsx" or "mjml" and compilation fails:

{
  "error": "Failed to compile React Email component.",
  "phase": "transform"
}

The phase field indicates where compilation failed (transform or render).

Rate limit (429)

See Rate Limiting for details.

Content too large (413)

The API enforces a 1MB hard limit on request body size and a 500KB limit on the html field content.

On this page