# REST API status codes

> Choose the right HTTP status code for each API outcome: 200, 201, 204, 400 vs 422, 401 vs 403, 404, 409, 429 and 5xx, with the headers each code needs.

Canonical: https://scaplet.com/errors/http/rest-api-status-codes

Guide Error · HTTP status codes

Choose the right HTTP status code for each API outcome: 200, 201, 204, 400 vs 422, 401 vs 403, 404, 409, 429 and 5xx, with the headers each code needs.

5 min

read

5

sources

Oct 24, 2026

updated

Scaplet Editorial Team

author

In one line

Return the status code that says what happened, and put the detail in the body. Use 200 for a successful read, 201 with a Location header for a create, 204 when there's nothing to return, 400 or 422 for bad input, 401 or 403 for access problems, 404 for a missing resource, 409 for a state conflict, 429 for rate limits and 5xx for server faults.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2Frest-api-status-codes%20(%22REST%20API%20status%20codes%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2Frest-api-status-codes%20(%22REST%20API%20status%20codes%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2Frest-api-status-codes%20(%22REST%20API%20status%20codes%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2Frest-api-status-codes%20(%22REST%20API%20status%20codes%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 6 parts, 5 minutes.

1. [The codes an API needs, by outcome 01](#the-codes-an-api-needs-by-outcome)
2. [The pairs people get wrong 02](#the-pairs-people-get-wrong)
3. [Headers some codes require 03](#headers-some-codes-require)
4. [One error body for every error 04](#one-error-body-for-every-error)
5. [Retry rules clients can rely on 05](#retry-rules-clients-can-rely-on)
6. [What it does to SEO 06](#what-it-does-to-seo)

_01_Explained

## The codes an API needs, by outcome

RFC 9110 defines the codes and the headers some of them require. This table maps the outcomes most APIs produce to a code, using the RFC's own definitions. Each code links to its full page.

Outcome to status code
| Outcome | Code | What RFC 9110 says |
| Read or action succeeded | [200](/errors/http/200) | The request has succeeded; the content depends on the method |
| Resource created | [201](/errors/http/201) | One or more new resources were created; the primary one is identified by Location or the target URI |
| Accepted for later processing | 202 | Accepted for processing, but processing has not been completed |
| Succeeded, nothing to return | [204](/errors/http/204) | Fulfilled successfully with no additional content to send |
| Malformed request | [400](/errors/http/400) | Cannot or will not process due to a perceived client error such as malformed syntax |
| Not signed in or bad credentials | [401](/errors/http/401) | Lacks valid authentication credentials; the response must carry a WWW-Authenticate header |
| Signed in but not allowed | [403](/errors/http/403) | Understood the request but refuses to fulfill it |
| Resource doesn't exist | [404](/errors/http/404) | No current representation found, or not willing to disclose that one exists |
| Wrong method for this URL | [405](/errors/http/405) | Method known but not supported by the resource; must send an Allow header |
| Conflicts with current state | [409](/errors/http/409) | Conflict with the current state of the target resource, which the user might be able to resolve |
| Unsupported request body format | [415](/errors/http/415) | The content is in a format not supported by this method on the target resource |
| Valid syntax, invalid meaning | [422](/errors/http/422) | Syntax correct but unable to process the contained instructions |
| [Rate limit](/glossary/rate-limiting) hit | [429](/errors/http/429) | Too many requests in a given amount of time (RFC 6585) |
| Server failed | [500](/errors/http/500) | Unexpected condition prevented fulfilling the request |
| Upstream failed or slow | [502](/errors/http/502), [504](/errors/http/504) | A gateway got an invalid response, or no timely one |
| Temporarily unavailable | [503](/errors/http/503) | Temporary overload or maintenance; may include Retry-After |

_02_Picking between neighbors

## The pairs people get wrong

Pair

### 400 vs 422

Rule

400 when the request can't be parsed or is malformed. 422 when it parses fine but the instructions can't be processed, such as a well-formed body whose values fail validation. RFC 9110's example is well-formed but semantically erroneous XML. Pick one rule for validation errors and keep it.

Pair

### 401 vs 403

Rule

401 means no valid credentials: the client may retry with new ones. 403 means the server understood the request and refuses; RFC 9110 says the client should not automatically repeat it with the same credentials.

Pair

### 403 vs 404

Rule

RFC 9110 lets a server that wants to hide a forbidden resource's existence answer 404 instead. Use it when the existence of the resource is itself private.

Pair

### 200 vs 201 vs 204

Rule

201 for a create, with Location pointing at the new resource. 204 when there is nothing to send back, such as a successful delete. 200 when you return a body.

Pair

### 404 vs 410

Rule

RFC 9110 says 410 means the condition is likely to be permanent. If the server doesn't know whether it is permanent, 404 ought to be used instead.

**Don't return 200 with an error body**Clients, caches and monitors read the status line first. A failure that arrives as 200 with `{"error": ...}` hides the failure from every tool that works on status codes.

_03_Code and companion header

## Headers some codes require

Code

### 201

Header

Location

Rule

Identifies the primary resource created, if present; otherwise the target URI does

Code

### 401

Header

WWW-Authenticate

Rule

The server must send at least one challenge

Code

### 405

Header

Allow

Rule

The server must list the target resource's currently supported methods

Code

### 429

Header

Retry-After

Rule

RFC 6585 says it may be included to say how long to wait

Code

### 503

Header

Retry-After

Rule

RFC 9110 says the server may send it to suggest how long to wait

A create that returns the new resource's location

```
POST /orders HTTP/1.1 Content-Type: application/json HTTP/1.1 201 Created Location: /orders/8421 Content-Type: application/json
```

_04_Check it

## One error body for every error

The [status code](/glossary/http-status-codes) says what class of [thing](/glossary/entity) happened. The body says what to do. RFC 9457 defines "problem details", a machine-readable error format for HTTP APIs, so you don't invent your own. It uses the media type `application/problem+json`, with members `type`, `title`, `status`, `detail` and `instance`. RFC 9457's own example is a 403 with a title, a detail and extension members.

Keep the codes you return consistent. Document each one on the endpoint that returns it, so client authors know which to retry. For the full set of codes and fix pages, see the [HTTP status code list](/errors/http/http-status-code-list).

A problem details response, adapted from RFC 9457

```
HTTP/1.1 403 Forbidden Content-Type: application/problem+json Content-Language: en { "type": "https://example.com/probs/out-of-credit", "title": "You do not have enough credit.", "detail": "Your current balance is 30, but that costs 50.", "instance": "/account/12345/msgs/abc" }
```

_05_Good to know

## Retry rules clients can rely on

RFC 9110 says a 4xx means the client seems to have erred, so fix the request before resending it. It describes 5xx as server-side faults, and says 503 may carry a Retry-After to suggest how long to wait. RFC 6585 says 429 responses should include details and may include Retry-After.

Redirects in APIs

If an endpoint moves, use a method-preserving code so a POST stays a POST. See [HTTP redirect codes](/errors/http/http-redirect-codes).

_06_Explained

## What it does to SEO

API status codes are mostly invisible to search unless the same endpoint serves pages crawlers fetch. If it does, Google documents how each code affects crawling, and its 4xx and 5xx handling is covered on the audit pages for [4xx errors](/seo-issues/4xx-errors) and [server errors](/seo-issues/server-errors-5xx). The [glossary entry on status codes](/glossary/http-status-codes) gives the short version.

Sources · 5

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- rfc-editor.org
- iana.org
- mozilla.org

1. 01 [RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110) rfc-editor.org · checked 2026-10-25
2. 02 [RFC 6585: Additional HTTP Status Codes](https://www.rfc-editor.org/rfc/rfc6585) rfc-editor.org · checked 2026-10-25
3. 03 [RFC 9457: Problem Details for HTTP APIs](https://www.rfc-editor.org/rfc/rfc9457) rfc-editor.org · checked 2026-10-25
4. 04 [IANA: HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) iana.org · checked 2026-10-25
5. 05 [MDN: HTTP response status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status) developer.mozilla.org · checked 2026-10-25

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ What are the 2xx, 3xx, 4xx and 5xx status codes in an API?

2xx means success, 3xx redirection, 4xx a client error and 5xx a server error. RFC 9110 says a 4xx means the client seems to have erred and a 5xx means the server did.

_02_ When should I use 400 vs 422?

Use 400 for a request that is malformed or can't be parsed. Use 422 when the syntax is correct but the server can't process the instructions, such as values that fail validation.

_03_ What is the difference between 401 and 403?

401 means the request lacks valid credentials, and the response must include WWW-Authenticate. 403 means the server understood the request and refuses it, even if credentials were provided.

_04_ Should a successful DELETE return 200 or 204?

204 fits when there's no content to return. RFC 9110 says 200 fits when the response includes a representation describing the status, and 202 when the action will likely succeed but isn't done yet.

## Keep learning

[All errors](/errors)

[Learn HTTP 201 Created HTTP status codes](/errors/http/201) [Related 403 Forbidden HTTP status codes](/errors/http/403) [Read next HTTP 400 Bad Request HTTP status codes](/errors/http/400) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in errors
[Cross-Origin Request Blocked](/errors/misc/cross-origin-request-blocked) [Module not found: Can't resolve](/errors/misc/module-not-found-can-t-resolve)

More in HTTP status codes
[HTTP 401 Unauthorized](/errors/http/401) [HTTP 405 Method Not Allowed](/errors/http/405) [HTTP 407 Proxy Authentication Required](/errors/http/407) [HTTP 408 Request Timeout](/errors/http/408) [HTTP 409 Conflict](/errors/http/409) [HTTP 412 Precondition Failed](/errors/http/412) [HTTP 431 Request Header Fields Too Large](/errors/http/431) [HTTP 499 Client Closed Request](/errors/http/499) [HTTP 500 Internal Server Error](/errors/http/500) [HTTP 501 Not Implemented](/errors/http/501) [HTTP redirect codes](/errors/http/http-redirect-codes) [HTTP status code list](/errors/http/http-status-code-list) [REST API status codes](/errors/http/rest-api-status-codes) [100 Continue](/errors/http/100) [101 Switching Protocols](/errors/http/101) [402 Payment Required](/errors/http/402) [403 Forbidden](/errors/http/403) [404 Not Found](/errors/http/404) [406 Not Acceptable](/errors/http/406) [411 Length Required](/errors/http/411) [413 Request Entity Too Large](/errors/http/413) [414 URI Too Long](/errors/http/414) [415 Unsupported Media Type](/errors/http/415) [416 Range Not Satisfiable](/errors/http/416)

Terms on this page
[Rate limiting](/glossary/rate-limiting) [HTTP status codes](/glossary/http-status-codes) [Entity](/glossary/entity)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
