Endpoint
PUT
/api/category/
This endpoint requires authentication. Include a valid authorization token in the request.
Authentication
This endpoint is protected by theapi.auth middleware. You must include a valid authorization token in the request headers.
Path Parameters
The ID of the category to update
Request Body
The request body must contain ajson parameter with a JSON string containing the category data to update.
JSON string containing category data
The updated name of the category (required)
Validation Rules
name: Required field
The following fields are automatically excluded from the update and cannot be modified:
id, created_atResponse
Returns a JSON object containing the update status and the updated data.Success Response
HTTP status code (200 for success)
Response status (‘success’)
The updated category data (as submitted, not the full database record)
Updated category name
Error Response
HTTP status code (400 for validation error)
Response status (‘error’)
Error message describing what went wrong
Example Request
cURL
Example Responses
Success Response (200)
Empty Request Error (400)
Implementation Details
This endpoint is defined inCategoryController.php:90. It:
- Receives data as a JSON string in the
jsonparameter - Validates that the
namefield is present (defined at line 99-101) - Automatically removes
idandcreated_atfields from the update data (lines 104-105) - Updates the category using Laravel’s
where()->update()method - Returns the submitted parameters, not the full updated record from the database
The request expects data to be sent as a form parameter named
json containing a JSON string, not as direct JSON in the request body. This is the same format used by the create endpoint.The response returns the parameters that were submitted for update, not the complete category object from the database. To get the full updated category, make a subsequent GET request to
/api/category/{id}.