What are the most important HTTP status codes for APIs?

Beginner

Answer

2xx Success:

  • 200 OK: Successful GET, PUT, PATCH
  • 201 Created: Successful POST
  • 204 No Content: Successful DELETE or PUT with no response body

4xx Client Error:

  • 400 Bad Request: Invalid request syntax
  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Access denied
  • 404 Not Found: Resource doesn't exist
  • 409 Conflict: Resource conflict
  • 422 Unprocessable Entity: Validation errors

5xx Server Error:

  • 500 Internal Server Error: Generic server error
  • 503 Service Unavailable: Server temporarily unavailable