BuildRestAPI — Modern REST API Engineering Animated Logo
BuildRestAPI
RFC 9110 & RFC 9457 Compliant Reference

HTTP Status Codes Reference Guide

Stop returning 200 OK with error messages inside the body. Here is the authoritative guide to choosing the correct HTTP status code for modern REST APIs.

Standards & Specification Reference

HTTP Status Codes & Method Matrix

Quick-lookup reference with RFC standards and prescriptive production guidelines for REST engineers.

200OK
RFC 9110 §15.3.1

The standard response for successful HTTP requests with an entity body.

Production Best Practice:

Return with payload on successful GET, PUT, or PATCH calls.

201Created
RFC 9110 §15.3.2

The request has succeeded and led to the creation of a new resource.

Production Best Practice:

Always include a 'Location' header pointing to the newly created URI on POST.

204No Content
RFC 9110 §15.3.5

The server has fulfilled the request and there is no additional content to send in the payload body.

Production Best Practice:

Standard for successful DELETE or PUT operations when no body is returned.

304Not Modified
RFC 9110 §15.4.5

Indicates that the resource has not been modified since the version specified by the conditional request headers (If-None-Match / ETag).

Production Best Practice:

Critical for client and CDN caching efficiency; must omit payload body.

400Bad Request
RFC 9110 §15.5.1

The server cannot or will not process the request due to perceived client syntax error (malformed JSON, invalid query param types).

Production Best Practice:

Use for structural/syntax parsing failures. For semantic validation, prefer 422.

401Unauthorized
RFC 9110 §15.5.2

Although the HTTP standard specifies 'unauthorized', semantically this means unauthenticated.

Production Best Practice:

The client must authenticate itself. Always provide a WWW-Authenticate header.

403Forbidden
RFC 9110 §15.5.4

The client's identity is known, but the client does not have access permissions for the requested resource.

Production Best Practice:

Authentication will not help. Use for Role-Based Access Control (RBAC) rejection.

404Not Found
RFC 9110 §15.5.5

The origin server did not find a current representation for the target resource.

Production Best Practice:

Return RFC 9457 Problem Details. Never return 200 OK with null.

409Conflict
RFC 9110 §15.5.10

The request could not be completed due to a conflict with the current state of the target resource.

Production Best Practice:

Ideal for optimistic locking failures or unique constraint collisions (e.g. email exists).

422Unprocessable Content
RFC 9110 §15.5.21

The server understands the content type and syntax, but was unable to process the contained instructions.

Production Best Practice:

Industry gold-standard for schema and business validation errors.

429Too Many Requests
RFC 6585 §4

The user has sent too many requests in a given amount of time ('rate limiting').

Production Best Practice:

Always include 'Retry-After' (in seconds) and rate-limit remaining headers.

500Internal Server Error
RFC 9110 §15.6.1

The server encountered an unexpected condition that prevented it from fulfilling the request.

Production Best Practice:

Log the stack trace internally, return an opaque correlation/trace ID to the client.

503Service Unavailable
RFC 9110 §15.6.4

The server is currently unable to handle the request due to a temporary overload or scheduled maintenance.

Production Best Practice:

Supply a 'Retry-After' header to guide automated client retry mechanisms.

HTTP Methods: Safety & Idempotency Matrix

Crucial for distributed retry logic and AI agent tool calling.

MethodSafe?Idempotent?Cacheable?Standard Semantics
GETYes (Read-only)YesYesRetrieve a resource representation
POSTNoNo (Requires Idempotency-Key)Only with explicit headersProcess entity / create subordinate resource
PUTNoYesNoComplete replacement of the target resource
PATCHNoDepends (Generally No)NoPartial modification (RFC 7396 Merge Patch)
DELETENoYesNoRelinquish resource representation
RFC 9457 Standard

Problem Details for HTTP APIs (RFC 9457)

RFC 9457 replaces RFC 7807 to define a standard JSON media type (application/problem+json) for carrying machine-readable details of errors in HTTP response bodies.

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

{
  "type": "https://api.buildrestapi.com/errors/invalid-credentials",
  "title": "Validation Error",
  "status": 422,
  "detail": "The password supplied does not meet entropy requirements.",
  "instance": "/v1/users/create",
  "invalid_params": [
    {
      "name": "password",
      "reason": "Must contain at least 12 characters and a symbol"
    }
  ]
}
Quick Jump:
↑ ↓ to navigate↵ to select
BuildRestAPI Search Engine