# 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.
    
    ```json
      {
        "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.
    
    ```json
      {
        "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.
    
    ```json
      {
        "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.
    
    ```typescript
      {
        "status": 400,
        "message": "Bad Request",
        "error": "Invalid input data"
      }
    ```
    
* **401 Unauthorized**: Authentication is required for the requested resource.
    
    ```json
      {
        "status": 401,
        "message": "Unauthorized",
        "error": "Authentication required"
      }
      
    ```
    
* **403 Forbidden**: The client does not have permission to access the resource.
    
    ```json
      {
        "status": 403,
        "message": "Forbidden",
        "error": "Access denied"
      }
    ```
    
* **404 Not Found**: The requested resource could not be found.
    
    ```json
      {
        "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.
    
    ```json
      {
        "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.
    
    ```json
      {
        "status": 503,
        "message": "Service Unavailable",
        "error": "The server is currently unavailable"
      }
    ```
    

**Summary Table**

| **Category** | **Status Code** | **Description** | **Use Case** |
| --- | --- | --- | --- |

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>1xx</strong></p></td><td colspan="1" rowspan="1"><p>100</p></td><td colspan="1" rowspan="1"><p>Continue</p></td><td colspan="1" rowspan="1"><p>Acknowledge large requests before sending body</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>2xx</strong></p></td><td colspan="1" rowspan="1"><p>200</p></td><td colspan="1" rowspan="1"><p>OK</p></td><td colspan="1" rowspan="1"><p>Successful <code>GET</code>, <code>PATCH</code> requests</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>201</p></td><td colspan="1" rowspan="1"><p>Created</p></td><td colspan="1" rowspan="1"><p>Successful <code>POST</code> creating a resource</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>204</p></td><td colspan="1" rowspan="1"><p>No Content</p></td><td colspan="1" rowspan="1"><p><code>DELETE</code> or successful update with no content</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>3xx</strong></p></td><td colspan="1" rowspan="1"><p>301</p></td><td colspan="1" rowspan="1"><p>Moved Permanently</p></td><td colspan="1" rowspan="1"><p>Redirect to a new URL</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>302</p></td><td colspan="1" rowspan="1"><p>Found</p></td><td colspan="1" rowspan="1"><p>Temporary redirection</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>4xx</strong></p></td><td colspan="1" rowspan="1"><p>400</p></td><td colspan="1" rowspan="1"><p>Bad Request</p></td><td colspan="1" rowspan="1"><p>Invalid request syntax</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>401</p></td><td colspan="1" rowspan="1"><p>Unauthorized</p></td><td colspan="1" rowspan="1"><p>Missing or invalid authentication</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>403</p></td><td colspan="1" rowspan="1"><p>Forbidden</p></td><td colspan="1" rowspan="1"><p>Client lacks access rights</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>404</p></td><td colspan="1" rowspan="1"><p>Not Found</p></td><td colspan="1" rowspan="1"><p>Resource does not exist</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>5xx</strong></p></td><td colspan="1" rowspan="1"><p>500</p></td><td colspan="1" rowspan="1"><p>Internal Server Error</p></td><td colspan="1" rowspan="1"><p>Unhandled server error</p></td></tr></tbody></table>

<table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>503</p></td><td colspan="1" rowspan="1"><p>Service Unavailable</p></td><td colspan="1" rowspan="1"><p>Server down for maintenance or overload</p></td></tr></tbody></table>

**References:**

[https://restfulapi.net/http-status-codes/](https://restfulapi.net/http-status-codes/)

[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)

[https://dzone.com/articles/http-status-codes-101-a-guide-implementing-status](https://dzone.com/articles/http-status-codes-101-a-guide-implementing-status)
