The 18 codes linked in orange have a page of their own, for the people who choose what their API returns. Each one says when to return the code, how eleven well-known public OpenAPI specs declare it, how to describe it in yours, and what an Octri SDK does when it gets one.
1xx informational
Interim answers sent before the final response. Most API clients never see them.
| Code | Name | What it means |
|---|---|---|
| 100 | Continue | The headers were fine, so the client can send the body it held back after Expect: 100-continue. |
| 101 | Switching Protocols | The server agrees to change protocol, as when an HTTP connection becomes a WebSocket. |
| 102 | Processing | A WebDAV server is still working on the request. Deprecated and rarely sent. |
| 103 | Early Hints | Headers like Link: rel=preload sent ahead of the final response, so a browser can start loading assets. |
2xx success
The request worked. The code says what kind of success it was.
| Code | Name | What it means |
|---|---|---|
| 200 | OK | The request worked, and the body holds the result. |
| 201 | Created | The request created a resource, usually named in the Location header. |
| 202 | Accepted | The request was queued and the work will finish later, with no promise about the outcome. |
| 203 | Non-Authoritative Information | A proxy changed the origin server’s successful response before passing it on. |
| 204 | No Content | The request worked and there is no body to send back. |
| 205 | Reset Content | The request worked, and the client should reset the form or view that sent it. |
| 206 | Partial Content | The body holds only the byte range the client asked for with a Range header. |
| 207 | Multi-Status | A WebDAV response with a separate status for each of several resources. |
| 208 | Already Reported | A WebDAV binding member already listed earlier in the same response. |
| 226 | IM Used | The body is the result of delta encoding applied to the current resource. |
3xx redirection
The client has to go somewhere else, or use the copy it already has.
| Code | Name | What it means |
|---|---|---|
| 300 | Multiple Choices | The resource has several representations, and the client should pick one. |
| 301 | Moved Permanently | The resource has a new URL for good. Clients may turn a POST into a GET when they follow it. |
| 302 | Found | The resource is at another URL for now. Clients may turn a POST into a GET when they follow it. |
| 303 | See Other | The result is at another URL, to be fetched with GET, often after a POST. |
| 304 | Not Modified | The client’s cached copy is still current, so the server sends no body. |
| 305 | Use Proxy | Deprecated for security reasons. Clients ignore it. |
| 306 | (Unused) | Used in an early draft and reserved since. No server should send it. |
| 307 | Temporary Redirect | The resource is at another URL for now, and the client must repeat the same method and body there. |
| 308 | Permanent Redirect | The resource has a new URL for good, and the client must repeat the same method and body there. |
4xx client errors
Something about the request is wrong, and sending it again unchanged will usually fail again.
| Code | Name | What it means |
|---|---|---|
| 400 | Bad Request | The request is malformed, like JSON that doesn’t parse or a missing required field. |
| 401 | Unauthorized | The request has no valid credentials, so the server doesn’t know who is calling. |
| 402 | Payment Required | Reserved for future use. Some APIs send it when an account needs to pay. |
| 403 | Forbidden | The server knows the caller and won’t let them do this. |
| 404 | Not Found | Nothing exists at this URL, or the server won’t say that it does. |
| 405 | Method Not Allowed | The URL exists and doesn’t accept this method. The Allow header lists the ones it does. |
| 406 | Not Acceptable | The server can’t produce a response in any format the Accept header asks for. |
| 407 | Proxy Authentication Required | Like a 401, for a proxy between the client and the server. |
| 408 | Request Timeout | The client took too long to send the request, so the server closed the connection. |
| 409 | Conflict | The request clashes with the resource’s current state, like a duplicate email. |
| 410 | Gone | The resource was removed for good and won’t come back. |
| 411 | Length Required | The server needs a Content-Length header and the request didn’t send one. |
| 412 | Precondition Failed | A condition the client sent, like If-Match, was false. |
| 413 | Content Too Large | The request body is bigger than the server will take. Formerly Payload Too Large. |
| 414 | URI Too Long | The URL is longer than the server will process, often from a huge query string. |
| 415 | Unsupported Media Type | The server won’t accept the body in the format named by Content-Type. |
| 416 | Range Not Satisfiable | The byte range in the Range header is outside the resource. |
| 417 | Expectation Failed | The server can’t meet the Expect header the client sent. |
| 418 | (Unused) | Reserved after the 1998 April Fools’ RFC that named it “I’m a teapot”. Some servers send it as a joke. |
| 421 | Misdirected Request | The request reached a server that can’t answer for that host, often over a reused HTTP/2 connection. |
| 422 | Unprocessable Content | The request parsed and the data breaks a rule. Formerly Unprocessable Entity. |
| 423 | Locked | A WebDAV resource is locked by someone else. |
| 424 | Failed Dependency | A WebDAV request failed because another action it depended on failed. |
| 425 | Too Early | The server won’t risk processing a request sent in TLS early data, which could be replayed. |
| 426 | Upgrade Required | The server won’t answer over this protocol. The Upgrade header names the one it wants. |
| 428 | Precondition Required | The server needs a conditional request, usually with If-Match, and this one had none. |
| 429 | Too Many Requests | The client went over a rate limit. Retry-After says how long to wait. |
| 431 | Request Header Fields Too Large | One header, or all of them together, is too big, often an oversized cookie. |
| 451 | Unavailable For Legal Reasons | The server can’t serve the resource because of a legal demand, like a court order. |
5xx server errors
The server failed on a request that may have been fine. Some of these are safe to retry.
| Code | Name | What it means |
|---|---|---|
| 500 | Internal Server Error | Something unexpected failed on the server. |
| 501 | Not Implemented | The server doesn’t support what the request needs, on any resource. |
| 502 | Bad Gateway | A proxy or gateway got an invalid response from the server behind it. |
| 503 | Service Unavailable | The server is overloaded or down for maintenance and expects to recover. |
| 504 | Gateway Timeout | A proxy or gateway gave up waiting for the server behind it. |
| 505 | HTTP Version Not Supported | The server won’t use the HTTP version the request came in. |
| 506 | Variant Also Negotiates | The server’s content negotiation is misconfigured and loops on itself. |
| 507 | Insufficient Storage | A WebDAV server has no room to store what the request needs. |
| 508 | Loop Detected | A WebDAV server found an infinite loop while processing the request. |
| 510 | Not Extended | The request needs an HTTP extension the server doesn’t have. Obsolete. |
| 511 | Network Authentication Required | A captive portal, like hotel Wi-Fi, wants the client to sign in first. |
Unofficial codes you will meet
No RFC defines these. Specific servers and CDNs send them, so they show up in logs.
| Code | Name | What it means |
|---|---|---|
| 499 | Client Closed Request | nginx logs this when the client hung up before the server answered. |
| 520 | Web Server Returned an Unknown Error | Cloudflare got an empty or unexpected response from the origin server. |
| 521 | Web Server Is Down | Cloudflare couldn’t connect to the origin server at all. |
| 522 | Connection Timed Out | Cloudflare’s connection to the origin server timed out. |
| 523 | Origin Is Unreachable | Cloudflare couldn’t find a route to the origin server. |
| 524 | A Timeout Occurred | Cloudflare connected to the origin server and it didn’t answer in time. |
HTTP status code questions
Does an API need every status code?
No. Most APIs get by with about a dozen: 200, 201, 202 and 204 for success, 400, 401, 403, 404, 409, 422 and 429 for client errors, and 500 and 503 for server errors. Add others where they say something those don’t.
Should an API return 200 with an error in the body?
No. Clients, proxies and monitoring read the status code first, so an error behind a 200 looks like a success to all of them. Slack does this, and a generated SDK has to be told which field holds the error.
Can an API invent its own status codes?
Partly. HTTP allows any three-digit code, and clients treat an unknown one like the x00 of its class. Nothing outside your own clients will know what it means, so a standard code with a precise error body is easier to work with.