HeoLab
ToolsBlogAboutContact
HeoLab

Free developer tools with AI enhancement. Built for developers who ship.

Tools

  • JSON Formatter
  • JWT Decoder
  • Base64 Encoder
  • Timestamp Converter
  • Regex Tester
  • All Tools →

Resources

  • Blog
  • What is JSON?
  • JWT Deep Dive
  • Base64 Explained

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 HeoLab. All rights reserved.

Tools work in your browser. Zero data retention.

HomeBlogHTTP Status Codes: A Developer's Complete Reference
Table of Contents▾
  • The Five Classes of HTTP Status Codes
  • 2xx Success Codes
  • 200 OK
  • 201 Created
  • 204 No Content
  • 206 Partial Content
  • 3xx Redirect Codes
  • 301 Moved Permanently
  • 302 Found (Temporary Redirect)
  • 307 Temporary Redirect
  • 308 Permanent Redirect
  • 304 Not Modified
  • 4xx Client Error Codes
  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • 409 Conflict
  • 422 Unprocessable Content
  • 429 Too Many Requests
  • 5xx Server Error Codes
  • 500 Internal Server Error
  • 502 Bad Gateway
  • 503 Service Unavailable
  • 504 Gateway Timeout
  • API Design Patterns
  • The 404 vs 403 Decision
  • Idempotent Operations
  • REST vs GraphQL Status Codes
  • Quick Reference
  • Conclusion
api#http#api#rest

HTTP Status Codes: A Developer's Complete Reference

Master all 5xx, 4xx, 3xx, 2xx, and 1xx HTTP status codes with real-world examples and when to use each in your API design.

Trong Ngo
February 22, 2026
5 min read

The Five Classes of HTTP Status Codes

HTTP status codes are three-digit numbers that tell clients what happened to their request. They are grouped into five classes by their first digit:

ClassRangeMeaning
1xx100–199Informational — request received, process continuing
2xx200–299Success — request was understood and accepted
3xx300–399Redirection — further action must be taken
4xx400–499Client Error — request contains bad syntax or cannot be fulfilled
5xx500–599Server Error — server failed to fulfill a valid request

2xx Success Codes

200 OK

The request succeeded. The most common status code. Use it for successful GET and POST (non-creating) responses.

201 Created

A new resource was created as a result of the request. Always include a Location header pointing to the new resource:

HTTP/1.1 201 Created
Location: /users/123
Content-Type: application/json

{"id": 123, "name": "Alice"}

204 No Content

The request succeeded but there is no content to return. Use for DELETE and PUT operations where you don't need to return data:

DELETE /users/123 HTTP/1.1

HTTP/1.1 204 No Content

206 Partial Content

Used for range requests (video streaming, file downloads with resume support).

3xx Redirect Codes

301 Moved Permanently

The resource has permanently moved to a new URL. Browsers and search engines will update their caches. Use when you rename URLs permanently.

302 Found (Temporary Redirect)

Temporary redirect. The method may change from POST to GET. Use for login redirects.

307 Temporary Redirect

Like 302, but guarantees the method won't change. Use when you need to redirect a POST request temporarily.

308 Permanent Redirect

Like 301, but the method is preserved. Use when permanently redirecting POST endpoints.

304 Not Modified

The cached version is still valid. Used with ETag and If-None-Match or Last-Modified and If-Modified-Since headers for efficient caching.

4xx Client Error Codes

400 Bad Request

The request is malformed. Include error details in the response body:

{
  "error": "VALIDATION_ERROR",
  "message": "Invalid email format",
  "field": "email"
}

401 Unauthorized

Authentication is required and has failed or not been provided. Despite the name, this is about authentication, not authorization. Include a WWW-Authenticate header.

403 Forbidden

The client is authenticated but not authorized to perform this action. The user exists and is identified, but lacks permission.

401 → "Who are you?"
403 → "I know who you are, but you can't do that."

404 Not Found

The resource doesn't exist. Also use when you want to hide the existence of a resource from unauthorized users (instead of 403).

409 Conflict

The request conflicts with the current state. Common for duplicate creation attempts:

{"error": "EMAIL_ALREADY_EXISTS"}

422 Unprocessable Content

The request is well-formed but has semantic errors. Preferred over 400 for validation failures in REST APIs.

429 Too Many Requests

Rate limiting. Always include Retry-After and X-RateLimit-* headers:

HTTP/1.1 429 Too Many Requests
Retry-After: 60
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1706745600

5xx Server Error Codes

500 Internal Server Error

Something went wrong on the server. Log the actual error internally but never expose it to the client.

502 Bad Gateway

The gateway or proxy received an invalid response from an upstream service. Common when a microservice goes down.

503 Service Unavailable

The server is temporarily unable to handle requests (overload or maintenance). Include Retry-After.

504 Gateway Timeout

The upstream service didn't respond in time. Different from 503 — the downstream service is up but the upstream isn't responding.

API Design Patterns

The 404 vs 403 Decision

For sensitive resources (admin panels, private data), returning 404 instead of 403 prevents information disclosure. Attackers don't know whether the resource exists or whether they just lack permission.

Idempotent Operations

  • GET, HEAD, DELETE, PUT — idempotent (same result if called multiple times)
  • POST — not idempotent (creates new resource each time)
  • Use 409 Conflict or idempotency keys for safe retries

REST vs GraphQL Status Codes

GraphQL APIs typically return 200 even for errors, with error details in the response body. This is by design — the HTTP layer is the transport, not the business logic layer.

Quick Reference

Browse all HTTP status codes with descriptions in HeoLab's HTTP Status Codes reference. Search by code number, name, or description.

Conclusion

Choosing the right status code communicates intent to clients and keeps your API predictable. The key rules: 2xx for success with appropriate granularity (200 vs 201 vs 204), 4xx for client mistakes with helpful error messages, and 5xx for server-side failures that you log and fix.

Try These Tools

HTTP Status Codes

Complete reference for all HTTP status codes with descriptions, use cases, and RFC links.

cURL Converter

Convert curl commands to fetch, axios, HTTPie, and other HTTP client formats.

URL Parser & Builder

Parse any URL into its components and rebuild it. Edit parts individually.

Related Articles

QR Codes for Developers: How They Work and How to Generate Them

4 min read

URL Slugs and SEO: Best Practices for Developers

4 min read

ISO 8601 Date Format: The Standard Every Developer Should Know

1 min read

Back to Blog

Table of Contents

  • The Five Classes of HTTP Status Codes
  • 2xx Success Codes
  • 200 OK
  • 201 Created
  • 204 No Content
  • 206 Partial Content
  • 3xx Redirect Codes
  • 301 Moved Permanently
  • 302 Found (Temporary Redirect)
  • 307 Temporary Redirect
  • 308 Permanent Redirect
  • 304 Not Modified
  • 4xx Client Error Codes
  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • 409 Conflict
  • 422 Unprocessable Content
  • 429 Too Many Requests
  • 5xx Server Error Codes
  • 500 Internal Server Error
  • 502 Bad Gateway
  • 503 Service Unavailable
  • 504 Gateway Timeout
  • API Design Patterns
  • The 404 vs 403 Decision
  • Idempotent Operations
  • REST vs GraphQL Status Codes
  • Quick Reference
  • Conclusion

Related Articles

QR Codes for Developers: How They Work and How to Generate Them

4 min read

URL Slugs and SEO: Best Practices for Developers

4 min read

ISO 8601 Date Format: The Standard Every Developer Should Know

1 min read