HTTP status codes are more than numbers.
They communicate what happened during an HTTP request.
Using them consistently makes APIs easier to consume and debug.
2xx: Success
A common example:
200 OK
means the request succeeded.
Another important status is:
201 Created
which is useful when a resource has been created.
For example:
POST /users
might return:
201 Created
4xx: Client Problems
These usually indicate that something about the request isn't acceptable.
Examples:
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
409 Conflict
429 Too Many Requests
For example, an unauthenticated request might receive:
401 Unauthorized
while an authenticated user lacking permission may receive:
403 Forbidden
5xx: Server Problems
These indicate that the server encountered an error.
The classic example:
500 Internal Server Error
Another useful code is:
503 Service Unavailable
which can indicate temporary service unavailability.
Why Consistency Matters
Imagine an API that returns:
200
for every request, even when something fails.
The client now has to inspect custom fields to determine whether the operation succeeded.
Standard HTTP semantics make APIs much easier to understand.
Don't Overcomplicate It
You don't need to memorize every status code.
Start with:
200
201
204
400
401
403
404
409
429
500
503
These cover a large portion of everyday API development.
Final Thoughts
Good API design isn't only about endpoints and JSON.
The status codes are part of the API contract too.
Top comments (0)