Important HTTP Status Code

Success

  • 200: Success
    • Can be used for any requests
  • 201: Created ^5842b1
    • Can be used for POST or PUT typically when using to upload a file.
  • 204: No content
    • No content sent back but header might be useful

Redirection

  • 301: Permanent redirect
  • 302: Temporary redirect
    • Browser will not cache the response
    • Good for analytics
    • Consider using
      • 307 if we want to keep the same method type (GET -> GET, POST -> POST)

Client error

  • 400: Bad request
    • Due to problem from client error: (malformed syntax, invalid request)
  • 401: Unauthorised
    • Require authentication to access
  • 403: Forbidden
    • Authenticated but doesn't have permission
  • 404: Not found
  • 405: METHOD not allowed
    • The URL is available but METHOD is not available.
    • For example we cannot DELETE a resource. Therefore we return 405
  • 415: Unsupported media type
  • 429: Too many requests

Server error

  • 500: Internal server error
  • 502: Bad gateway.
    • The server while calling other API has invalid response, hence return 502 to the current user saying that it's another party issue
  • 504: Gateway timeout
    • The server is timeout from the upstream server and return back to client