Here's a clean and concise list of HTTP status codes, their meaning, and when to use them:
✅ 200 OK
-
Meaning: Request succeeded.
-
Use When: Data is successfully retrieved or updated.
✅ 201 Created
-
Meaning: Resource created successfully.
-
Use When: After a successful
POST
(create) request.
✅ 204 No Content
-
Meaning: Request succeeded, no content to return.
-
Use When: After a successful
DELETE
orPUT
when there's nothing to return.
⚠️ 400 Bad Request
-
Meaning: Invalid request from the client.
-
Use When: Required data is missing or malformed in the request.
🔒 401 Unauthorized
-
Meaning: Authentication required.
-
Use When: User must log in or provide a valid token.
⛔ 403 Forbidden
-
Meaning: Access denied.
-
Use When: User is authenticated but not allowed to access the resource.
❓ 404 Not Found
-
Meaning: Resource not found.
-
Use When: The requested URL or resource does not exist.
💥 500 Internal Server Error
-
Meaning: Server encountered an error.
-
Use When: Something unexpected breaks on the server.
⚠️ 422 Unprocessable Entity
-
Meaning: Valid request format, but semantic error.
-
Use When: The server understands the data, but something is logically wrong (e.g. invalid email format, missing required fields).
🔁 405 Method Not Allowed
-
Meaning: Method not supported for this route.
-
Use When: For example, using
POST
on a route that only allowsGET
.