Understand HTTP Status Codes

HTTP status codes indicate the result of an HTTP request.

They are grouped into five categories:

1xx - Informational

The request has been received and processing continues.

2xx - Success

The request was successfully received and processed.

3xx - Redirection

Additional action is needed to complete the request.

4xx - Client Errors

The request contains an issue that prevents processing.

5xx - Server Errors

The server failed to process an otherwise valid request.

In REST API development, choosing appropriate status codes makes APIs easier to understand and integrate.

Important HTTP Status Codes

200

OK

The request completed successfully.

201

Created

A new resource was successfully created.

204

No Content

The operation succeeded without a response body.

400

Bad Request

The request contains invalid data.

401

Unauthorized

Authentication is missing or invalid.

403

Forbidden

The authenticated user does not have permission.

404

Not Found

The requested resource does not exist.

409

Conflict

The request conflicts with the current resource state.

422

Unprocessable Content

The request is syntactically valid but fails semantic validation.

429

Too Many Requests

The client exceeded a rate limit.

500

Internal Server Error

An unexpected server-side error occurred.

503

Service Unavailable

The server cannot currently handle the request.

Key Takeaways
  • Use 2xx status codes for successful operations.

  • Use 4xx status codes for client-side request problems.

  • Use 5xx status codes for server-side failures.

  • Choose status codes that accurately describe the result.