Backend & Node.js · APIs, data and failure

Which HTTP status codes should a backend engineer know?

Easyhttpstatus codesapi designUpdated Oct 2026
Quiz this track

Short answer

Know the families and the common members: 200, 201, 204, 400, 401, 403, 404, 409, 422, 429, 500, 502 and 503. Use them to describe the outcome precisely instead of returning 200 for every response.

Status codes are part of the contract. Clients, proxies, retry logic and monitoring all read them. A correct code lets a client decide whether to retry, re-authenticate or show a validation message without parsing the body.

The codes that matter most

  • 200 OK for a successful read or update with a body
  • 201 Created with a Location header for a new resource
  • 204 No Content for a successful action with no body
  • 400 Bad Request for malformed syntax or invalid parameters
  • 401 Unauthorized when authentication is missing or invalid
  • 403 Forbidden when the identity is known but not allowed
  • 404 Not Found when the resource does not exist or is hidden
  • 409 Conflict for a state conflict such as a duplicate or version mismatch
  • 422 Unprocessable Content when the body is well-formed but semantically invalid
  • 429 Too Many Requests with Retry-After for rate limiting
  • 500 Internal Server Error for an unexpected server fault
  • 502 Bad Gateway and 503 Service Unavailable for upstream and availability failures
js
app.post("/users", async (req, res, next) => {
  try {
    const user = await users.create(req.body);
    res.status(201).location("/users/" + user.id).json(user);
  } catch (error) {
    if (error.code === "DUPLICATE_EMAIL") {
      return res.status(409).json({ error: "email_exists" });
    }
    next(error);
  }
});
201 communicates creation, and 409 distinguishes a conflict from a generic validation error.

401 and 403 are commonly confused. 401 means the request lacks valid credentials, so the client may authenticate and retry. 403 means the credentials are valid but the action is not permitted, so retrying with the same identity will not help. 404 can intentionally hide a resource from a user who is not allowed to know it exists.

Do not invent codes or return 200 with an error flag. If a proxy or client library sees 200, it may cache or retry the response incorrectly.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What is the difference between 401 and 403?
  2. 2When should you return 409 instead of 422?
  3. 3Which codes are safe to retry?
  4. 4Why is returning 200 for errors a problem?

Say it in the interview

I use status codes to describe the result precisely: 201 for creation, 204 for no content, 400 for malformed input, 401 for missing or invalid credentials, 403 for a permissions failure, 409 for a conflict, 422 for semantic validation and 429 for rate limits. Server faults are 500 unless an upstream or availability problem makes 502 or 503 more accurate. Correct codes let clients and infrastructure make the right retry and caching decisions.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Backend & Node.js mock interview and get scored feedback on depth, clarity and confidence.