Skip to main content

HTTP Status Codes & Headers Cheat Sheet for API Testers

A practical decision matrix and cheat sheet for validating REST API status codes, error boundaries, and response security headers.


1. Status Codes Decision Tree​


2. Status Codes Reference Matrix​

CategoryCodeMeaningCommon QA Assertion Scenario
2xx Success200 OKStandard successGET /users/102, PUT /profile
201 CreatedNew resource createdPOST /orders (returns Location header or created object)
202 AcceptedAsync processing startedPOST /export-report (job queued for worker)
204 No ContentSuccess, no body returnedDELETE /items/45
3xx Redirect301 Moved PermanentlyPermanent URL changehttp:// redirecting to https://
304 Not ModifiedCached payload still freshClient sends If-None-Match (ETag validation)
4xx Client Error400 Bad RequestSchema/syntax errorMissing required field, malformed JSON
401 UnauthorizedMissing/invalid authenticationBearer token expired, missing Authorization header
403 ForbiddenAuthenticated, but no permissionRegular customer trying to access admin endpoint (BFLA/BOLA)
404 Not FoundResource does not existGET /products/non-existent-uuid
409 ConflictState conflict / DuplicateRegistering an email that already exists in DB
422 Unprocessable EntitySemantic validation failedQuantity is negative, birthdate is in the future
429 Too Many RequestsRate limit exceededSending > 5 OTP requests per minute
5xx Server Error500 Internal Server ErrorUnhandled exceptionUncaught NullPointerException, DB down
502 Bad GatewayUpstream service failedNginx reverse proxy cannot reach Node/Java backend
503 Service UnavailableServer overloaded/maintenanceHealth-check endpoint during deployment
504 Gateway TimeoutUpstream timeoutMicroservice query took > 30s

3. Key Response Security Headers to Assert​

// Postman / JavaScript header validation snippet
pm.test("Security headers are present", function () {
// 1. Prevent MIME-type sniffing
pm.expect(pm.response.headers.get("X-Content-Type-Options")).to.eql("nosniff");

// 2. Clickjacking protection
pm.expect(pm.response.headers.get("X-Frame-Options")).to.be.oneOf(["DENY", "SAMEORIGIN"]);

// 3. Strict HTTPS enforcement
pm.expect(pm.response.headers.get("Strict-Transport-Security")).to.include("max-age=");

// 4. Ensure no server banner leakage
pm.expect(pm.response.headers.has("Server")).to.be.false;
});