<
Trevor Hatfield | November 30th, 2026

422 Error: What It Means and How to Fix It

Share

A 422 error is an HTTP status code that means the server read your request correctly but refused to act on it because the data inside is invalid, such as a missing field or a badly formatted email address. Sending the same request again returns the same error, so you fix the data first.

Most people hit a 422 while connecting an app to an API, and email sending APIs produce more of them than most. A single message request carries a sender, recipients, a subject, a body, and sometimes attachments and template variables. Any one of those can be wrong. This guide explains what a 422 means, how it differs from a 400, and how to fix each cause you'll see from an email API. It stays on HTTP and API responses. If the error you're chasing is an SMTP reply code from a mail server, our SMTP server guide covers those.

What does a 422 error mean?

A 422 error means the server understood the content type of your request, found no syntax problems, and still could not carry out the instructions inside it. Its current name is 422 Unprocessable Content, and older tools and docs still call it 422 Unprocessable Entity. The fault sits in the values you sent, so the server has nothing to retry.

What does "unprocessable entity" mean?

Picture a parcel clerk who reads your label, understands every word, and still can't ship the box because the address has no street number. The label is readable, but it's incomplete. In HTTP terms, the "entity" is the body of your request, and "unprocessable" means the server can't act on it as written.

Under MDN's definition of 422, a client that receives one should expect that repeating the request without changes will fail with the same error. That's the most useful sentence to remember, because it tells you the fix is always a change to the request.

What do 1xx, 2xx, 3xx, 4xx and 5xx status codes mean?

HTTP groups status codes into five classes by their first digit. A 1xx code is informational, 2xx means success, 3xx means redirection, 4xx means a client error, and 5xx means a server error. A 422 sits in the 4xx class, which tells you the request has to change before it can succeed.

The class is your first triage step. With a 4xx, look at what you sent. With a 5xx, the server failed even though your request may be fine, so waiting and retrying is reasonable. Email APIs add one wrinkle on the success side. A 202 Accepted means the request was received but not yet acted upon, so an accepted message hasn't necessarily been delivered. MDN's status code reference lists every code in each class.

How is a 422 different from 400, 415 and 429?

A 400 means the request itself is malformed, a 415 means the server doesn't accept its format, a 422 means the format is fine but the values can't be processed, and a 429 means you sent too many requests too quickly. Only a 429 is worth repeating unchanged, and only after waiting. The other three fail the same way until you change the request.

Status

What the server is telling you

Typical cause

Example payload

Retry unchanged?

400 Bad Request

The request is malformed

Broken JSON, bad framing

{"to": "ana@example.com", (no closing brace)

No

415 Unsupported Media Type

The server doesn't accept this format

A Content-Type header that doesn't match the body

Valid JSON sent with Content-Type: text/plain

No

422 Unprocessable Content

The format is fine, the values can't be processed

Invalid address, missing field, failed rule

{"to": "ana.example.com"} (no @ sign)

No

429 Too Many Requests

You sent too many requests in a given time

Bursts above the API's rate limit

A valid request sent after the limit is used up

Yes, after waiting

Sources: MDN pages for 400 Bad Request, 415 Unsupported Media Type, 422 Unprocessable Content and 429 Too Many Requests. A 429 may carry a Retry-After header that says how long to wait.

Some APIs use a 400 for the same failures that others report as a 422. MDN describes a 400 as a response to anything the server considers a client error, so both are legitimate. Read the response body rather than trusting the number alone.

Why does an email API return a 422?

An email API returns a 422 when your request is valid JSON but one value fails a check before the message is queued. The usual suspects are the sender address, the sending domain, a required field, a recipient address, a template variable, or an attachment. Nothing is sent, so nothing can bounce. Fix the field named in the response body and send again.

Think of the API as a front desk that checks your paperwork before the mail room ever sees the package. It would rather turn you away at the door than let a package with a bad label into the building. That's good news for you, because a 422 is cheap to fix and costs your sender reputation nothing. Here are the six causes we see most.

A bad sender address

The From address has to be one valid mailbox, written the way the API expects. The usual slips are two addresses in one From field, a display name with an unescaped quote or comma, a trailing space, and a placeholder like noreply@yourcompany. To fix it, send the bare address on its own first, then add the display name. Check whether your provider wants the name and the address in separate fields.

An unverified sending domain

Many email APIs refuse to send from a domain you haven't proved you control. That makes sense from the mailbox provider's side. Gmail checks the SPF and DKIM records against the domain in your From address, and a message from a domain nobody authenticated looks like a forgery. Your API is refusing it before Gmail gets the chance to.

To fix it, add the domain in your sending account, publish the DNS records your provider gives you, wait for the domain to show as verified, and send again. Our guide to SPF, DKIM and DMARC setup walks through the records.

Missing or malformed required fields

Every email request needs a few fields, typically a sender, at least one recipient, a subject, and a body in text or HTML. A field can be absent, empty, spelled differently from the docs, or the wrong type. An empty subject counts as missing for many validators. So does a recipient sent as a single string when the API wants a list.

To fix it, compare your payload with the API reference field by field. Pay attention to naming style, because first_name and firstName are different keys. Most 422 responses list the failing fields, so start there.

A bad recipient format

A recipient with no @ sign, a trailing space, or a comma where the API expects separate entries will fail. So will a full "Name <address>" string in a field that wants the bare address. Some APIs reject the whole request when one recipient in a batch is invalid, so a single bad row can block hundreds of good ones.

To fix it, trim whitespace, split combined strings into a list, and run a syntax check on every address before the request leaves your app. Your signup forms and imports are where bad addresses come from, which is why email list cleaning pays off here as well as for bounces.

Template variables that don't match

When you send with a saved template, every variable the template uses has to arrive in your request with the right name and type. A template that expects first_name fails if your code sends firstName. It can also fail when the value is null, because many validators treat null as missing.

To fix it, list the variables inside the template, send every one of them on every request, and give optional ones a default value. Test again whenever someone edits the template, since a harmless-looking rename in the editor breaks the code that fills it. If transactional messages are your use case, our explainer on transactional email covers how they differ from marketing sends.

Attachment limits

Providers cap the size of the whole request and of each attachment, and some restrict file types. Attachments are usually sent Base64-encoded, which makes the payload bigger than the file on your disk. A request that is simply too large may come back as a 413 Content Too Large instead of a 422.

To fix it, look up the limits in your provider's docs, compress the file or host it and link to it, and count the encoded size, not the original size, when you check.

How do you fix a 422 error, step by step?

To fix a 422 error, read the response body, find the field it names, compare that field with the API reference, change the value, and resend once. Most email API responses list every failing field in one reply, so you can fix them together. If the same 422 returns, change one thing at a time until it clears.

Here is a worked example. The host and field names below are placeholders, not a real API, and every provider formats its errors differently. This request is valid JSON, but it breaks three rules.

POST /v1/messages HTTP/1.1
Host: api.example.com
Content-Type: application/json

{
  "from": "Acme Support <help@example.com>",
  "to": "ana.example.com",
  "subject": "",
  "template": "order-confirmation",
  "variables": { "first_name": null, "order_id": "A-1042" }
}

The API replies with a 422 and names each problem.

HTTP/1.1 422 Unprocessable Content
Content-Type: application/json

{
  "errors": [
    { "field": "to", "message": "must be a valid email address" },
    { "field": "subject", "message": "must not be empty" },
    { "field": "variables.first_name", "message": "is required" }
  ]
}

Here is the fixed request. The address now has its @ sign and sits in a list, which this example API requires. The subject has text, and the template variable has a value.

{
  "from": "Acme Support <help@example.com>",
  "to": ["ana@example.com"],
  "subject": "Your order A-1042 is confirmed",
  "template": "order-confirmation",
  "variables": { "first_name": "Ana", "order_id": "A-1042" }
}

The API now accepts the request, typically with a 200 or 202 status. Follow the same routine every time you debug one of these.

  1. Read the whole response body before you touch your code.

  2. Log the exact request and response, with API keys and personal data removed.

  3. Match each named field against the API reference for its name, type and format.

  4. Fix every listed problem, then resend once.

  5. If the error comes back unchanged, change one value at a time so you know which one mattered.

If the docs say your request is correct and the 422 keeps coming, the validation rules or the docs may be out of date. Send the provider the request and the response body. Both are what their support team will ask for first.

How do you prevent 422 errors?

Validate every request in your own code before you call the API, test your sending path with both good and bad payloads, and keep your integration in step with the provider's current docs. These three habits stop most 422s before they reach production, because the checks an API runs on your request are checks you can run first.

Validate before you send

Put a schema check in front of the API call. It should confirm that required fields exist, types are right, strings are trimmed, and every address passes a syntax check. Run the same check against your template variables, so a missing value fails in your app, where you can log it and tell the user, instead of at the API.

Check the sender domain at deploy time too. If someone removes a DNS record or changes the From domain in a config file, you'd rather find out from a failing deploy than from a morning of rejected requests.

Test the failure paths

Most teams test that a good request succeeds. Fewer test what happens on a bad one. Add tests that send an invalid address, an empty subject, and a missing template variable, and check that your code logs the response body and doesn't retry. A stubbed 422 response is enough to prove your handler behaves.

Keep a small set of known-good example payloads in your repo and run them in your build. When a payload that passed last week fails today, you've caught a change in the API or in your own data before a customer does.

Keep your code and the docs in sync

Most 422s after launch come from drift. The provider adds a required field, a template gets edited, or one team renames a key without telling the team that sends the mail. Subscribe to your provider's changelog, pin the API version where one is offered, and store templates next to the code that fills their variables so they change together.

What if 422 errors keep happening across many requests?

Repeated 422s point to a pattern. Group the failures by field name and message. If one field dominates, the cause sits upstream in a signup form, an import, or the data feeding a template. If every request started failing at the same minute, a deploy, a template edit, or a sender change broke the whole path. Stop automatic retries while you investigate.

Look for the pattern

Three questions narrow it down quickly. Which field fails most often? When did the failures start, and what shipped at that time? Do the failing recipients share a source, such as one signup form or one imported file? A single field failing for a handful of recipients usually means bad data from one source. Every request failing at once usually means a code, template or configuration change.

Stop retrying and set the bad rows aside

Retries make sense for a 429 or a 5xx, where waiting can help. They make no sense for a 422, because the same request fails the same way. Move failed messages to a separate queue, record the field that failed, and fix or drop them. A retry loop on a 422 only hammers the API and, with a rate limit in place, can turn one error into a stream of 429s.

Fix the source, then watch the rate

If the bad values come from a signup form or an import, validate there as well, so bad addresses never enter your list. A 422 stops at the API door. An address that passes validation but doesn't exist is accepted and then fails later, which is a bounce. Our guide to what an email bounce means covers that second stage. Alert on the share of requests that return a 422 instead of on single failures, so a sudden jump gets noticed within minutes.

How does SendX help with email API errors?

SendX is managed sending infrastructure with an email API and an SMTP relay, built for senders who run several brands, clients or publications. A 422 tells you a request was refused before sending. SendX also covers the rest of the path: webhooks for opens, clicks, bounces and complaints, event logs, and mailbox provider responses, so a message that passes validation stays traceable.

Fixing 422s is the first half of reliable sending. The second half starts once the API says yes, because an accepted request still has to reach Gmail, Yahoo and Outlook. If you're choosing where your app should send from, the question worth asking is what you can see after the 2xx. When your validation, your API errors and your delivery data live in separate tools, every incident turns into a hunt across all three.

SendX's email API comes with official SDKs in 6 languages, and the API documentation has a Try it button on every endpoint that runs the real request and shows the real response, errors included. You can send a bad payload on purpose, see how the response reads, and build your handling around it before any production traffic exists. Behind the API, SendX's managed sending infrastructure shows what mailbox providers did with each message, per brand and per mailbox provider, down to the SMTP code.

If you run more than one brand or client, you can prove the setup on one of them first while your current provider keeps sending for the rest. Our first response comes within three hours on a work day, and an engineer joins the first call.

Start a free trial

FAQs

Is a 422 error my fault or the API provider's?

It's almost always the request. The server read it fine and rejected the data, so check the response body for the field and the reason. If the provider's docs say your request is valid and the 422 persists, their validation or their docs may be out of date. Send their support team the exact request and response body, with keys removed.

Does a 422 mean my API key or account has a problem?

Usually not. A missing or invalid key normally gets a 401, which means the client hasn't authenticated. A key without permission for the action gets a 403. A 422 is about the content of the request, so look at your payload first, and check your key and permissions only if the response body points there.

What is the difference between a 422 and a bounce?

A 422 happens at the API door, before the message is queued, so nothing is sent and nothing bounces. A bounce happens after the API accepted the message and a receiving mail server refused it. You fix a 422 in your request. You fix a bounce in your list or your sending setup. Our guide to email bounces covers the second kind.

How do I test my 422 handling without sending real email?

Stub the API in your tests. Make the stub return a 422 with an error body shaped like your provider's, then assert that your code logs the body, skips the retry, and moves the message to a review queue. Keep a few invalid payloads in your test suite as well, so a change in validation shows up in your build.

I'm building an API. Should I return a 400 or a 422 for bad values?

Either works, as long as you pick one and document it. A 400 covers anything the server considers a client error. A 422 lets you reserve the 400 for malformed requests and use the 422 for well-formed requests with bad values. Whichever you choose, return a body that names the field and the reason, because that's what the person calling your API reads first.

What should I do if I see a 422 in my browser instead of in code?

You didn't build the request, so the fix usually belongs to the site's owner. Reload the page, re-enter the form with plain text and without unusual characters, and try once more. If the error returns, tell the site's support team what you submitted and when. A site owner should check the validation rules behind that form.

Notes on email that works.

From the team that delivers 4.4 billion emails a year.

The most useful thing from our weekly email strategy call, plus the best of what we have written.

See it before you switch

We'll connect SendPost alongside your current setup and show you delivery data, routing insights, and AI-powered recommendations — all before you move a single email.

Start a free Proof of Concept
No commitment
No code changes
No risk to your sending reputation

Most teams are live in under a day