An HTTP status code summarises the result of a request. Test the code together with the response body, headers and actual system state.

On this cheat sheet

2xx success

CodeMeaningVerify
200OKCorrect body, headers and data.
201CreatedResource exists and its location or ID is returned.
202AcceptedProcessing is asynchronous and status can be tracked.
204No ContentAction succeeded and no response body is returned.

3xx redirection

301Permanent redirectClients and search engines should use the new URL.
302Temporary redirectOriginal URL remains valid.
304Not ModifiedCached content is reused correctly.
307 / 308Temporary / permanent redirectMethod and body are preserved.

4xx client errors

400Bad RequestInvalid input gets a safe, useful error.
401UnauthenticatedMissing or invalid credentials are rejected.
403ForbiddenAuthenticated user lacks permission.
404Not FoundUnknown resources do not leak details.
405Method Not AllowedUnsupported methods are rejected.
409ConflictDuplicate or state conflict is explained.
415Unsupported Media TypeWrong Content-Type is rejected.
422Unprocessable ContentWell-formed but invalid data reports field errors.
429Too Many RequestsRate limit and retry information are correct.

5xx server errors

500Internal Server ErrorNo stack trace, secret or internal detail is exposed.
502Bad GatewayUpstream failure is handled and retry is safe.
503Service UnavailableMaintenance or overload response is clear.
504Gateway TimeoutSlow dependency produces a controlled response.

What to verify

  • Expected code for both valid and invalid requests.
  • Response schema, values and error format.
  • Content-Type, caching, CORS and security headers.
  • No sensitive information in errors.
  • Database or system state matches the result.
  • Redirect target, number of hops and preserved method.
  • Retry behaviour is safe and does not create duplicates.
Common mistake: a 200 response can still contain the wrong data. A 500 may hide a partial write. Always verify the outcome.

Useful links