Troubleshooting

Fix 422 validation errors

Short answer

A 422 means the request body is not right, and nothing was sent. The error has a type (validation_error, missing_required_field or invalid_attachment), a message that says what to change, and usually a field that points at the input. In a batch, the field starts with the email's position, such as 3.to. Fix that input and send again; it is safe to retry with the same Idempotency-Key once the body is fixed.

Last checked 16 November 2026

Every error has the same shape:

{ "error": { "type": "validation_error", "message": "to is not a valid email address: sam@", "field": "to" } }

Show message to your developers as it is: it says what to change. field says which input.

Common errors and fixes

field Message Fix
from, to, subject “Add from.” (type missing_required_field) These three are required.
from, to, cc, bcc, reply_to ”… is not a valid email address: …” Use name@domain.com or Name <name@domain.com>. Check for spaces and missing parts.
to ”… must be an email address or a list of them.” Send a string or an array of strings, not objects.
to “Send to at most 50 recipients per email, across to, cc and bcc.” Split into several emails, or use a batch.
html “Add html, text, or both.” Include at least one body.
scheduled_at “scheduled_at is an ISO 8601 date or text like “in 1 hour”.” Use 2026-11-20T09:00:00Z or in 2 hours.
scheduled_at “scheduled_at can be at most 30 days ahead.” Pick a nearer time.
template “Send template or html/text, not both.” Use one or the other.
template.variables.NAME “Template … needs the variable NAME.” Give every variable that has no fallback.
template.id “No template with this id on your team.” Check the id with GET /v1/templates.

Attachment errors (invalid_attachment)

Message Fix
“attachments must be a list.” Send an array of objects.
“Each attachment needs a filename without slashes, up to 255 characters.” Use a plain file name like invoice.pdf.
“Add the file for … as base64 in content.” Put the file’s bytes, base64-encoded, in content.
“Send the file as base64 in content. Fetching files by URL is not supported yet.” You sent path. Download the file yourself and base64 it.
“The content of … is not valid base64.” Encode with standard base64, no data URL prefix.
“Attachments add up to more than 40 MB (as base64).” Link to large files instead.
import { readFileSync } from 'node:fs';
const attachments = [{ filename: 'invoice.pdf', content: readFileSync('invoice.pdf').toString('base64') }];

Batch errors

POST /v1/emails/batch takes a JSON array of 1 to 100 emails.

Message Fix
“Send a JSON array of 1 to 100 emails.” The body must be an array, not an object.
“Send at most 100 emails per batch.” Split into more calls.
“Batch sends cannot be scheduled.” Send scheduled emails one at a time.
“Batch sends cannot carry attachments.” Send emails with attachments one at a time.
“Email 3: …” with field 3.to The fourth email in the array has the problem.

Other 422s you may meet

  • Lists: “limit is a whole number from 1 to 100.”, “Use after or before, not both.”, “That cursor is not an item in this list.”
  • Webhooks: “Use an https:// URL.”, “Pick at least one event.”, “Unknown events: …”.
  • Suppressions: “Add up to 1000 addresses at a time.”
  • API keys: “Name the key in 1 to 50 characters.”, “Only sending keys can be limited to one domain.”

Retrying safely

A 422 sends nothing, so fix the body and send again. If you use an Idempotency-Key, a failed request does not use up the key, so you can send the corrected body with the same key. Only a successful request is remembered: after that, the same key with a different body within 24 hours answers 409 invalid_idempotent_request.

Compatible endpoints

  • SendGrid (POST /v3/mail/send): validation errors come back as 400 with {"errors": [{"message", "field"}]}. A template_id is refused: send rendered HTML.
  • Postmark (POST /email): errors come back in Postmark’s shape with ErrorCode: 300 and the message. Templates are refused.

If it does not work

  • The message names a field you did send. Check the JSON is valid and sent with Content-Type: application/json.
  • Only some emails fail. Log field; it points to the exact input.

Full field rules are in the API reference.

Questions

Was anything sent when I got a 422?

No. Every email is validated before anything is stored. In a batch, one bad email stops the whole batch.

What does the field 2.from mean?

In a batch, the number is the position of the email in your array, starting at 0. So 2.from is the from address of the third email.

Do I need both html and text?

No. Send html, text or both. With only html, a plain-text part is made for you.

Why does the SendGrid endpoint return 400 instead?

The SendGrid-compatible endpoint uses SendGrid's error shape and returns 400 for validation errors, as SendGrid does.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.