Skip to main content

Command Palette

Search for a command to run...

Activity 30: HTTP Status Codes

Published
•3 min read•View as Markdown
Activity 30: HTTP Status Codes

1xx (Informational)

These codes indicate that the request was received and is being processed, but there is no final response yet.

  • 100 Continue: The server has received the request headers, and the client should proceed to send the request body.

  • 101 Switching Protocols: The server is switching protocols as requested by the client.

  • 102 Processing: The server has received and is processing the request, but no response is available yet.

2xx (Success)

These codes indicate that the request was successfully received, understood, and accepted.

  • 200 OK: The request was successful, and the server returned the requested data.

        {
          "status": 200,
          "message": "OK",
          "data": {
            "id": 123,
            "name": "Rodel Decio"
          }
        }
    
  • 201 Created: The request was successful, and a new resource was created as a result.

        {
          "status": 201,
          "message": "Created",
          "data": {
            "id": 123,
            "name": "Rodel Decio"
          }
        }
    
  • 204 No Content: The request was successful, but there is no content to send in the response.

        {
          "status": 204,
          "message": "No Content"
        }
    

3xx (Redirection)

These codes indicate that the client must take additional actions to complete the request.

  • 301 Moved Permanently: The requested resource has been permanently moved to a new URL.

  • 302 Found: The requested resource is temporarily available at a different URL.

  • 304 Not Modified: The resource has not been modified since the last request.

4xx (Client Error)

These codes indicate that the client made an error in the request.

  • 400 Bad Request: The request was invalid or cannot be understood by the server.

        {
          "status": 400,
          "message": "Bad Request",
          "error": "Invalid input data"
        }
    
  • 401 Unauthorized: Authentication is required for the requested resource.

        {
          "status": 401,
          "message": "Unauthorized",
          "error": "Authentication required"
        }
    
  • 403 Forbidden: The client does not have permission to access the resource.

        {
          "status": 403,
          "message": "Forbidden",
          "error": "Access denied"
        }
    
  • 404 Not Found: The requested resource could not be found.

        {
          "status": 404,
          "message": "Not Found",
          "error": "Resource not found"
        }
    

5xx (Server Error)

These codes indicate that the server encountered an error and could not complete the request.

  • 500 Internal Server Error: The server encountered an error and could not complete the request.

        {
          "status": 500,
          "message": "Internal Server Error",
          "error": "An unexpected error occurred"
        }
    
  • 503 Service Unavailable: The server is temporarily unavailable, often due to maintenance or overload.

        {
          "status": 503,
          "message": "Service Unavailable",
          "error": "The server is currently unavailable"
        }
    

Summary Table

CategoryStatus CodeDescriptionUse Case

1xx

100

Continue

Acknowledge large requests before sending body

2xx

200

OK

Successful GET, PATCH requests

201

Created

Successful POST creating a resource

204

No Content

DELETE or successful update with no content

3xx

301

Moved Permanently

Redirect to a new URL

302

Found

Temporary redirection

4xx

400

Bad Request

Invalid request syntax

401

Unauthorized

Missing or invalid authentication

403

Forbidden

Client lacks access rights

404

Not Found

Resource does not exist

5xx

500

Internal Server Error

Unhandled server error

503

Service Unavailable

Server down for maintenance or overload

References:

https://restfulapi.net/http-status-codes/

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

https://dzone.com/articles/http-status-codes-101-a-guide-implementing-status