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:

CodeStatus TextWhen to Use It
200OKThe request succeeded and data is being returned.
201CreatedA new resource was successfully inserted into the database.
400Bad RequestThe client sent invalid data (e.g., missing a required email field).
401UnauthorizedThe user is not logged in or the JWT token has expired.
403ForbiddenThe user is logged in, but lacks the admin permissions to do this.
404Not FoundThe requested resource (like an article ID) does not exist.
500Internal ErrorYour 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.