API Create District Documentation

Create District Request

This is a POST request to create a new district. To create a new district, make a request to the following endpoint:

POST /api/districts

Request Body:


{
    "name": "New District",
    "code": "ND1",
    "status": 1
}
                

Successful Response (Status Code: 201):


{
    "status": "success",
    "code": 201,
    "message": "District created successfully",
    "data": {
        "data": {
            "id": 3,
            "name": "New District",
            "code": "ND1",
            "status": 1,
            "created_at": "2025-07-08 07:10:14",
            "updated_at": "2025-07-08 07:10:14"
        }
    }
}
                

Response Explanation:

  • status: Indicates the success or failure of the request. In this case, "success" indicates a successful creation.
  • code: The HTTP status code. Here it is `201`, indicating that the district was successfully created.
  • message: A human-readable message, confirming that the district was created successfully.
  • data: An object containing the created district information:
    • id: The unique ID assigned to the newly created district.
    • name: The name of the new district.
    • code: The code assigned to the new 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 name, code, and status fields are required to create a district.
  • If the request is successful, a district object is returned with the details of the newly created district, including its `id`.
  • In case of an error, an appropriate error message will be returned with a corresponding error code.