Capstone topics from the end of the program: how to set up a full-stack backend project, work with npm and Git, test APIs with Postman or curl, apply layering and REST habits, and prepare for deployment and the mock interview. These patterns tie Express, SQL, and deployment lessons into day-to-day engineering practice.

HTTP status codes

Which status code to return for each REST operation. Use this reference when writing controllers, testing in Postman, or debugging failing Qualified tests.

1 topic(s) on this page.

HTTP status codes — when to use each — Reference

Quick reference for common API response codes used in the backend program: what each code means and which HTTP verb / situation it pairs with.
Learn: Status codes tell the client what happened without reading the body. In this program you most often use: 200 for successful reads/updates that return JSON, 201 when POST creates a row, 204 when DELETE succeeds with no body, 400 when validation fails, 404 when the id or route does not exist, and 500 when an unexpected error reaches errorHandler. Match the code to the HTTP verb and outcome—not every success is 200.

Supplementary examples

2xx — success responses

// 200 — GET /users, GET /users/3, PUT /users/3 (with JSON body)
res.status(200).json({ data: users });

// 201 — POST /users (resource created)
res.status(201).json({ data: newUser });

// 204 — DELETE /users/3 (nothing to return)
res.status(204).end();

4xx — client / request problems

// 400 — validation middleware or controller check
return res.status(400).json({ error: "username is required" });

// 404 — service found no row, or notFound middleware
const err = new Error("User not found");
err.status = 404;
throw err;

5xx — server failures

// 500 — default in errorHandler when err.status is missing
// Avoid sending 500 for validation (use 400) or missing rows (use 404)

function errorHandler(err, req, res, next) {
  const status = err.status || err.statusCode || 500;
  res.status(status).json({ error: err.message });
}

Verb → status cheat sheet (typical REST API)

GET    /resources      200  (list)
GET    /resources/:id  200  (found)  | 404 (missing)
POST   /resources      201  (created)
PUT    /resources/:id  200  (updated) | 404 (missing)
DELETE /resources/:id  204  (deleted) | 404 (missing)

Common codes (program reference)

CodeNameWhen to use in your API
200OKGET success; PUT success when returning updated resource
201CreatedPOST created a new resource (include body or Location header)
204No ContentDELETE success; no response body (use .end())
400Bad RequestValidation failed, missing/invalid fields, bad JSON
404Not FoundUnknown route (notFound) or id not in database
500Internal Server ErrorUnhandled exception; default in errorHandler

Course example

# 2xx Success
200 OK           GET list/detail, PUT update (return body)
201 Created      POST created a new resource
204 No Content   DELETE succeeded (no response body)

# 4xx Client error (caller or request is wrong)
400 Bad Request  Validation failed, malformed JSON, missing field
404 Not Found    Resource id does not exist; unknown route (notFound)

# 5xx Server error (bug, database, unhandled exception)
500 Internal     Unhandled error; errorHandler default

Additional references & examples