What Are API Errors?
An API error is a response telling the caller that its request did not succeed. The response carries an HTTP status code, usually with a message naming what went wrong.
Most APIs signal failure through that status code alone. Anything in the 400s puts the problem in the request you sent, and anything in the 500s puts it on the server you sent it to.
That first digit carries more weight than the whole message body, which is why API monitoring breaks error counts out by code. It tells you whose problem you're looking at before you read a word.
Client Errors vs Server Errors
The class split decides whether retrying is pointless or the correct move.
Class | What it means | Who fixes it | Retry unchanged? |
4xx | The server understood the request and refused it | The caller | No, something has to change first |
5xx | The request looked valid and the server failed anyway | The API owner | Yes, with backoff |
Retry a 4xx unchanged and you'll burn calls for nothing. On a busy integration you'll also trip a rate limit on top of the problem you started with.
Retrying a 5xx usually works, as long as the retry waits first.
Codes in the 200s and 300s aren't errors at all. A 304 Not Modified means the cached copy still holds, and it catches out any client written to fail on every non-200 response (a surprisingly common bug).
Which API Error Codes Show Up Most Often
The codes below cover what an integration actually meets, with the first cause to check.
Code | What it means | Usual cause | What fixes it |
400 Bad Request | The server could not parse the request | Malformed JSON, a missing required field, a wrong data type | Validate the payload against the schema before sending |
401 Unauthorized | No valid credentials were presented | A missing, expired or mistyped token | Refresh the token, then check the auth header name against the WWW-Authenticate scheme the server asked for |
403 Forbidden | Credentials were valid and access was still denied | The key lacks the scope, or the resource belongs to another account | Check which scopes the key actually carries |
404 Not Found | The endpoint or resource does not exist | A typo in the path, a deleted record, or the wrong API version | Confirm the path and the version prefix |
409 Conflict | The request clashes with current state | Duplicate creation, or a stale version on an update | Re-read the resource and resubmit |
422 Unprocessable Entity | The syntax parsed and the values failed validation (RFC 9110 lists it as Unprocessable Content, though most APIs still say Entity) | A date out of range, or a field breaking a business rule | Read the error body, which usually names the field |
429 Too Many Requests | The caller went over a rate limit | Bursts, runaway retry loops, too many parallel workers | Back off using the Retry-After header |
500 Internal Server Error | The server hit a fault it did not handle | A bug or an unhandled edge case on the API side | Retry once, then report it with the request ID |
502 and 504 | A gateway could not get a usable response upstream | An upstream service down, or too slow to answer | Investigate upstream of the gateway |
The 403 and the 422 get misread constantly. A 403 looks like an authentication problem and nearly always turns out to involve permissions, which explains why swapping the token never helps (the token worked fine; the account behind it didn't).
A 422 looks like a 400 until you notice the request parsed perfectly well. The server simply didn't like what was inside it.
Why Rate Limit Errors Need Their Own Handling
A 429 stands out on that list. A perfectly correct caller can cause one just by working. Volume produces it on its own.
The response usually carries a Retry-After header, which gives either a wait in seconds or an absolute date. Respecting whichever form arrives fixes the problem outright.
Retry loops without a wait turn one 429 into a sustained block. Every failed attempt still counts against the limit it already blew through, so an impatient client keeps itself locked out.
Exponential backoff with jitter spreads the retries apart. Fixed-interval retries from several workers re-converge on the same second and rebuild the original burst (which is why the jitter matters more than the backoff).
What Makes 502 and 504 Gateway Errors Hard to Trace
Neither code comes from the API itself. A load balancer, a reverse proxy or an API gateway returns them when it can't get a usable answer out of whatever sits behind it.
A 502 and a 504 differ by less than people assume. The 502 means the upstream replied with something unusable, and the 504 means it never replied before the clock ran out.
Neither one names the service that actually broke, and that omission causes most of the trouble. A gateway only reports its own view, so you learn where the request stopped and nothing about why.
Distributed tracing closes that gap. A trace follows one request through every service it touched, so the failing span shows up on its own instead of getting narrowed down by elimination.
API Failures That Never Return a Status Code
Some failures never produce a response at all, so there's no code to read. They walk straight past error handling built only around status codes.
Connection timeouts, where the request never reaches the API.
TLS handshake failures, usually an expired or untrusted certificate.
DNS resolution failures for the API hostname.
A 200 response carrying an error inside the body, which plenty of older APIs still do.
Schema drift, where the response parses cleanly and a field has quietly changed type.
The 200-with-an-error and the schema drift do the most damage. A success code wrapped around a failure passes every check that only reads the status, so the bad payload moves on and breaks something downstream that had no reason to doubt it.
What Does a Useful API Error Response Contain?
A status code on its own rarely tells the caller enough to act on. The response body does the explaining on a well-designed API.
The table below covers what a developer needs to fix the call themselves.
Element | Why it matters |
A stable machine-readable code | Lets client code branch on the error without parsing prose that might get reworded later |
A human-readable message | Tells whoever reads the log what happened, without a trip to the API reference |
The offending field or parameter | Removes the guesswork on validation failures, where the payload has many candidates |
A request or correlation ID | Lets the API owner find that exact call in their own logs |
The request ID earns its keep during an incident. Quoting one turns a support conversation from a description of symptoms into a lookup.
RFC 9457 standardizes this shape under the name problem details for HTTP APIs, and it replaced the older RFC 7807. Adopting it means callers can handle errors from several different APIs the same way.
HTML or a bare string in the error body breaks every caller expecting JSON. That usually happens when a gateway answers on the application's behalf, which is one more reason those errors deserve their own alert.
How Do You Monitor API Errors?
Error rate is the headline number, measured as the share of requests that fail because of errors or exceptions. It belongs beside response time, because neither one means much alone.
Split that rate by status code before you read anything into it. A climbing 429 and a climbing 500 send you to different teams.
Motadata ObserveOps traces each request end to end and breaks it into spans, with API calls appearing as one span type alongside database calls and internal processing. That names the failing call instead of leaving you to guess at it.
API endpoint monitoring watches individual endpoints for availability and response behavior. That catches the failures returning no status code at all, while error and exception tracking covers the faults raised inside the application behind those endpoints.
Alert on the ratio and on the code class. Raw counts climb with traffic and tell you almost nothing on their own, so pair them with exception monitoring to see which failures started inside your own code.
Explore More IT Terms
Browse our comprehensive IT glossary to learn more about technology terminology.