API Update District Documentation

Update District Request

This is a PUT request to update an existing district. To update a district, make a request to the following endpoint:

PUT /api/districts/{id}

Request Example:

The request requires the district ID in the URL path and the new district data in the request body.

For example, to update the district with ID 2:

PUT /api/districts/2

Request Body:


{
    "name": "Updated District 1",
    "code": "UD1",
    "status": 1
}
                

Successful Response (Status Code: 200):


{
    "status": "success",
    "code": "200",
    "message": "District updated successfully",
    "data": {
        "id": 2,
        "name": "Updated District 1",
        "code": "UD1",
        "status": 1,
        "created_at": "2025-06-24 11:11:27",
        "updated_at": "2025-07-08 07:15:33"
    }
}
                

Response Explanation:

  • status: Indicates the success or failure of the request. "success" indicates the district was successfully updated.
  • code: The HTTP status code. Here it’s `200`, indicating a successful update.
  • message: A human-readable message, confirming that the district was updated successfully.
  • data: Contains the updated district's information:
    • id: The unique ID of the district.
    • name: The name of the district.
    • code: The code assigned to the district.
    • status: The status of the district (e.g., active or inactive).
    • created_at: Timestamp when the district was created.
    • updated_at: Timestamp when the district was last updated.

Notes:

  • The id in the URL is required to specify which district to update.
  • The request body must contain the updated information for the district (e.g., `name`, `code`, `status`).
  • If the district with the given ID does not exist, an error response will be returned.
  • In case of a successful update, the district's `updated_at` timestamp will reflect the most recent update time.