Backend
Guide
gurjotsingh.code
21/8/2026
2 min read
The Complete Guide to HTTP Status Codes
When building scalable APIs, communicating the exact result of a client's request is critical. You shouldn't just rely on JSON error messages; you must use the standard HTTP status codes correctly. This guide breaks down the core codes every backend developer needs to memorize.
The Status Code Matrix
Here is a quick reference table for the most common responses you will implement in your REST or GraphQL APIs:
| Code | Status Text | When to Use It |
|---|---|---|
| 200 | OK | The request succeeded and data is being returned. |
| 201 | Created | A new resource was successfully inserted into the database. |
| 400 | Bad Request | The client sent invalid data (e.g., missing a required email field). |
| 401 | Unauthorized | The user is not logged in or the JWT token has expired. |
| 403 | Forbidden | The user is logged in, but lacks the admin permissions to do this. |
| 404 | Not Found | The requested resource (like an article ID) does not exist. |
| 500 | Internal Error | Your server crashed or the database query failed unexpectedly. |
Implementation Advice
Always default to a 200 series code for success. If you are catching errors in a try/catch block, ensure you are returning a 400 series for user mistakes and a 500 series only when your own code completely fails.