Skip to main content

HTTP Status Code

An HTTP status code is the three-digit number a server returns with every response, indicating the general outcome of a request — 200 for success, 404 for not found, 500 for a server error. Verifying the correct status code for each scenario is one of the most basic, high-value assertions in API testing.

Status codes fall into five classes by their first digit: 1xx informational, 2xx success, 3xx redirection, 4xx client error (the request was wrong), and 5xx server error (the server failed to handle a valid request). Getting the class right matters as much as the exact code — a 400 (client sent bad data) and a 500 (server broke) mean very different things for who needs to fix what.

A surprisingly common bug class is returning a 200 with an error message in the response body, instead of an actual error status code — technically the request "succeeded" from an HTTP standpoint while the operation itself failed, which breaks tooling and clients that correctly rely on status codes to detect failure.

HTTP Status Code — Definition, Example & How It's Used | QA Bash Glossary | QA Bash