Status Code Categories
HTTP status codes are grouped into five categories based on the first digit:
The following sections list all standard HTTP status codes organized by category. Each table provides a quick reference, while the most commonly encountered codes include detailed explanations with example request/response pairs to illustrate their practical usage.
100 Continue
Tells the client to continue sending the request body. Used when client sends Expect: 100-continue header to check if server will accept a large request before sending it.
Use case: Large file uploads where you want server validation before transmitting
101 Switching Protocols
Server agrees to switch protocols as requested via the Upgrade header. Commonly used for WebSocket connections.
Use case: Upgrading HTTP connection to WebSocket
200 OK
The most common success status. For GET, the resource is in the body. For POST, the result of the action is in the body.
Use case: Successful GET requests, form submissions, API calls
201 Created
A new resource has been created. The Location header should contain the URI of the new resource.
Use case: POST request that creates a new record/resource
204 No Content
Request succeeded but there's nothing to return. The response must not include a body.
Use case: DELETE requests, PUT/PATCH that don't need to return data
301 Moved Permanently
The resource has permanently moved to a new URL. Clients should update their links. Search engines will transfer SEO value to the new URL.
Use case: Site migrations, URL restructuring, enforcing canonical URLs
304 Not Modified
Used for caching. Client's cached version is still valid, no need to transfer the body again.
Use case: Conditional GET with If-None-Match or If-Modified-Since
307 Temporary Redirect
Like 302, but guarantees the HTTP method won't change. A POST remains a POST after redirect.
Use case: Temporary maintenance redirects, preserving POST data
400 Bad Request
The server cannot process the request due to malformed syntax, invalid parameters, or bad framing. The response body should explain the problem.
Use case: Invalid JSON, missing required fields, malformed query strings
401 Unauthorized
Authentication is required. Must include a WWW-Authenticate header indicating how to authenticate.
Use case: Missing or expired credentials, invalid API key
403 Forbidden
Server understood the request but refuses to authorize it. Authentication won't help—the user doesn't have permission.
Use case: Accessing admin resources as regular user, IP blocked
404 Not Found
The requested resource could not be found. May be temporary or permanent (consider 410 for permanently gone).
Use case: Invalid URL, deleted resource, typo in path
422 Unprocessable Content
Request syntax is correct, but the server can't process the contained instructions. Common for validation errors.
Use case: Email already exists, password too weak, business rule violation
429 Too Many Requests
Rate limit exceeded. Should include Retry-After header indicating when to retry.
Use case: API rate limiting, brute force protection
500 Internal Server Error
Generic error when the server encounters an unexpected condition. Avoid exposing internal details in production.
Use case: Unhandled exceptions, database errors, configuration issues
502 Bad Gateway
Server acting as gateway/proxy received an invalid response from upstream. Common with reverse proxies.
Use case: Backend server crashed, upstream returned malformed response
503 Service Unavailable
Server is temporarily unable to handle requests. Should include Retry-After header when possible.
Use case: Planned maintenance, server overloaded, dependency down
Which Status Code Should I Use?
Choosing the right status code helps clients understand what happened and how to respond. This guide covers common scenarios for REST APIs.
General Scenarios
REST API: CRUD Operations
REST APIs map HTTP methods to Create, Read, Update, and Delete operations.
GET (Read)
POST (Create)
PUT/PATCH (Update)
DELETE