Free auditStart free
GuideError · HTTP status codes

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.

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 withChatGPTClaudePerplexityGoogleAI Mode
01Explained

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
OutcomeCodeWhat RFC 9110 says
Read or action succeeded200The request has succeeded; the content depends on the method
Resource created201One or more new resources were created; the primary one is identified by Location or the target URI
Accepted for later processing202Accepted for processing, but processing has not been completed
Succeeded, nothing to return204Fulfilled successfully with no additional content to send
Malformed request400Cannot or will not process due to a perceived client error such as malformed syntax
Not signed in or bad credentials401Lacks valid authentication credentials; the response must carry a WWW-Authenticate header
Signed in but not allowed403Understood the request but refuses to fulfill it
Resource doesn't exist404No current representation found, or not willing to disclose that one exists
Wrong method for this URL405Method known but not supported by the resource; must send an Allow header
Conflicts with current state409Conflict with the current state of the target resource, which the user might be able to resolve
Unsupported request body format415The content is in a format not supported by this method on the target resource
Valid syntax, invalid meaning422Syntax correct but unable to process the contained instructions
Rate limit hit429Too many requests in a given amount of time (RFC 6585)
Server failed500Unexpected condition prevented fulfilling the request
Upstream failed or slow502, 504A gateway got an invalid response, or no timely one
Temporarily unavailable503Temporary overload or maintenance; may include Retry-After
03Code 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
04Check it

One error body for every error

The status code says what class of thing 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.

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"
}
05Good 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.
06Explained

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 and server errors. The glossary entry on 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. 01RFC 9110: HTTP Semanticsrfc-editor.org · checked 2026-10-25
  2. 02RFC 6585: Additional HTTP Status Codesrfc-editor.org · checked 2026-10-25
  3. 03RFC 9457: Problem Details for HTTP APIsrfc-editor.org · checked 2026-10-25
  4. 04IANA: HTTP Status Code Registryiana.org · checked 2026-10-25
  5. 05MDN: HTTP response status codesdeveloper.mozilla.org · checked 2026-10-25
Questions

Asked a lot.

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

01What 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.

02When 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.

03What 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.

04Should 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.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

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

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane