Return to site

🛰️📡 HTTP STATUS CODES — THE MAP OF YOUR API RESPONSES

November 3, 2025

🔸 TLDR

▪️ HTTP codes are grouped by first digit: 1xx info, 2xx success, 3xx redirection, 4xx client error, 5xx server error.

▪️ Pick the most specific code to make your API predictable and debuggable. ✅

🔸 WHAT THEY MEAN

▪️ 1XX — INFORMATIONAL 🤝

100 Continue, 101 Switching Protocols, 103 Early Hints

Rare in REST; mostly transport/handshake signals.

▪️ 2XX — SUCCESS 🟢

200 OK (generic success)

201 Created (resource created; return Location)

202 Accepted (async processing)

204 No Content (success, empty body)

▪️ 3XX — REDIRECTION 🔀

301 Moved Permanently, 302 Found

307/308 keep HTTP method on redirect (safer for APIs).

▪️ 4XX — CLIENT ERROR 🧭

400 Bad Request (validation/parsing)

401 Unauthorized (no/invalid auth) vs 403 Forbidden (auth ok, no rights)

404 Not Found, 405 Method Not Allowed

409 Conflict (state clash), 422 Unprocessable Entity (semantic validation)

429 Too Many Requests (rate limiting)

▪️ 5XX — SERVER ERROR 🔧

500 Internal Server Error (unexpected)

502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout

Log + alert; don’t leak internals.

🔸 TAKEAWAYS

▪️ Be precise: 201 vs 200, 422 vs 400, 307/308 vs 302.

▪️ Document error models (code, message, details, trace id).

▪️ Consistency beats cleverness: same actions → same codes.

▪️ Security: avoid revealing stack traces in 4xx/5xx bodies.

▪️ Observability: tag metrics/logs by status class (2xx/4xx/5xx).

#http #rest #api #webdev #backend #microservices #spring #java #kubernetes #devops #bestpractices

Go further with Java certification:

Java👇

Spring👇

SpringBook👇