TechnicalEasy HTTP & REST APIs

What do the common HTTP status codes mean?

Asked for Frontend Developer, Backend Developer, Full-Stack Developer, Mobile Developer

Why they ask this: Correct status codes make APIs predictable for frontend and mobile developers.

Answer

  • 2xx success: 200 OK, 201 Created (after a POST that creates something), 204 No Content (success with no body).
  • 3xx redirect: 301 Moved Permanently, 302 Found, 304 Not Modified (use the cached copy).
  • 4xx client error:
    • 400 Bad Request: malformed request.
    • 401 Unauthorized: not authenticated (no token or a bad token).
    • 403 Forbidden: authenticated but not allowed.
    • 404 Not Found.
    • 409 Conflict: for example a duplicate email.
    • 422 Unprocessable Content: validation errors (Laravel's default).
    • 429 Too Many Requests: rate limited.
  • 5xx server error: 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable.

A frequent interview trap is the difference between 401 and 403.

Can you explain this in your own words?

Back to question bank