Overview
This endpoint allows modification of an existing category entity within the Catalog domain. It follows Domain-Driven Design principles by ensuring that the category update operation maintains domain integrity and business rules.
The operation performs the following:
- Validates the incoming category update command against domain invariants
- Retrieves the existing category aggregate from the repository
- Updates the category properties while preserving aggregate consistency
- Persists changes through the repository pattern
Note that this endpoint enforces proper domain authorization and validation rules. The operation is transactional and will either succeed completely or fail without partial updates.
Authentication & Authorization
This endpoint requires authentication and admin-level authorization. The request must include a valid authentication token with admin privileges.
Architecture
PUT (/api/v1/categories/{id})
Parameters
- id (path) (required) - The unique identifier (GUID) of the category to update
Request Body
Example Usage
curl -X PUT "https://api.bookworm.com/api/v1/categories" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <admin-token>" \ -d '{ "id": "01961eb4-668d-7e7e-ae25-0fab379614f7", "name": "Updated Category Name" }'
Validation Rules
The following validation rules are applied to the request:
- Category ID must not be empty
- Category name must not be empty
- Category name must not exceed the maximum length (Medium)
Responses
400 Bad Request
Returned when the request body fails validation or contains invalid data.
404 Not Found
Returned when the specified category ID does not exist in the system.
401 Unauthorized
Returned when the request lacks valid authentication credentials.
403 Forbidden
Returned when the authenticated user does not have admin privileges.
204 No Content
Returned when the category is successfully updated.
Error Handling
The endpoint implements proper error handling for various scenarios:
- Invalid input data is rejected with appropriate validation messages
- Non-existent categories return a 404 error
- Unauthorized access attempts are rejected
- Database errors are handled gracefully
- All operations are wrapped in a transaction to ensure data consistency
Category name