What are common HTTP status codes and their meanings

· Category: API & REST

Short answer

HTTP status codes communicate the outcome of a request through standardized three-digit numbers organized into five classes.

How it works

The first digit defines the class: 1xx for informational responses, 2xx for success, 3xx for redirection, 4xx for client errors, and 5xx for server errors. Within each class, specific codes convey precise meanings. A 200 OK indicates successful retrieval, 201 Created confirms resource creation, 400 Bad Request signals malformed syntax, 401 Unauthorized indicates missing authentication, 403 Forbidden denies access despite authentication, 404 Not Found means the resource does not exist, and 500 Internal Server Error indicates an unexpected server failure.

Example

When a client sends a GET request to /users/123 and the user exists, the server replies with 200 OK and a JSON body. If the client omits a required field in a POST request, the server returns 400 Bad Request with details about the validation failure.

Why it matters

Correct status codes enable clients to handle responses automatically, improve debugging, and support monitoring tools that track error rates and API health.

Example

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

{"id": 123, "status": "confirmed"}

This response shows a 201 Created status with a Location header and a JSON body representing the newly created resource.