API & Web ArchitectureUpdated: 2026-11-04

Complete HTTP Status Codes, REST API Errors & Header Reference

Quick lookup guide for all 1xx, 2xx, 3xx, 4xx, and 5xx HTTP response codes with caching directives and RFC definitions.

HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Grouped into five distinct classes, understanding these codes is fundamental for API design, debugging client-side fetch requests, and configuring reverse proxies like Cloudflare or Nginx.

2xx Success Status Codes

Indicates that the client request was received, understood, and accepted by the server.

CodeNameRFC Specification & Practical Usage
200 OKStandard SuccessRequest succeeded. Standard response for GET and successful PUT requests returning payload.
201 CreatedResource CreatedRequest succeeded and a new resource was created. Typical response for POST requests.
202 AcceptedAsynchronous ProcessingRequest accepted for processing, but processing has not completed (e.g. background job queue).
204 No ContentSuccess with No BodyServer successfully processed request but returns no response body (common in DELETE and OPTIONS preflight).

3xx Redirection Status Codes

Indicates that the client must take additional action to complete the request.

CodeNameSEO & Caching Impact
301 Moved PermanentlyPermanent RedirectTransfers link equity (PageRank) to the target URL. Aggressively cached by browsers.
302 FoundTemporary RedirectTemporary location change. Does not pass permanent link equity; clients maintain original URL.
304 Not ModifiedConditional Cache HitTells the client that cached response is fresh (matching ETag or If-Modified-Since). Body is empty.
307 Temporary RedirectStrict Temporary RedirectGuarantees the HTTP method (e.g. POST) is not transformed into a GET when redirecting.
308 Permanent RedirectStrict Permanent RedirectPermanent redirect that preserves the original HTTP request method and body.

4xx Client Error Status Codes

Indicates that the request contains bad syntax or cannot be fulfilled due to client fault.

CodeNameCause & Best Practice Handling
400 Bad RequestMalformed SyntaxInvalid JSON body, missing required parameters, or invalid header formatting.
401 UnauthorizedAuthentication RequiredRequest lacks valid authentication credentials (e.g., missing or expired JWT Bearer token).
403 ForbiddenPermission DeniedUser is authenticated but lacks required role or scope to access the specified resource.
404 Not FoundResource MissingServer cannot find the requested URI. Most common error for dead links and missing assets.
409 ConflictState CollisionRequest conflicts with current server state (e.g. duplicate email during registration or git merge conflict).
422 Unprocessable EntitySemantic Validation ErrorSyntax is valid JSON, but semantic instructions fail validation (e.g. age must be positive number).
429 Too Many RequestsRate Limit ExceededClient sent too many requests in given timeframe. Usually paired with `Retry-After` header.

5xx Server Error Status Codes

Indicates that the server failed to fulfill an apparently valid request.

CodeNameInfrastructure Meaning
500 Internal Server ErrorGeneric Unhandled ExceptionServer encountered an unexpected condition that prevented it from fulfilling the request.
502 Bad GatewayUpstream Proxy FailureEdge reverse proxy (e.g. Nginx, Cloudflare) received an invalid response from upstream origin.
503 Service UnavailableServer Overload or MaintenanceServer is currently unable to handle the request due to maintenance or sudden traffic surge.
504 Gateway TimeoutUpstream TimeoutReverse proxy did not receive timely response from origin application server.

Essential HTTP Caching Headers

Key headers that govern browser and CDN caching policies.

Modern Immutable Static Asset Cache (1 Year)http
Cache-Control: public, max-age=31536000, immutable
Ideal for hashed assets (e.g. Next.js chunks, fonts, images) that never mutate.
No-Cache Directive (Validate with ETag on Every Request)http
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
Forces client to fetch fresh data for sensitive account views and transactional APIs.
Stale-While-Revalidate (Instant Speed + Background Freshness)http
Cache-Control: public, max-age=60, s-maxage=600, stale-while-revalidate=86400
Serves stale cached page instantly while edge CDN revalidates origin in background.

Frequently Asked Questions

What is the exact difference between 401 Unauthorized and 403 Forbidden?

401 Unauthorized means "You are not logged in; please authenticate yourself with credentials or a token." 403 Forbidden means "We know who you are, but you do not have permission to perform this action."

How does 304 Not Modified improve site speed?

A 304 response sends an empty HTTP body. The browser compares its local ETag or Last-Modified header with the server. If identical, the browser renders directly from local memory without re-downloading bytes.