Update an existing category.
Authentication
This endpoint requires authentication with the admin role.
Authorization: Bearer <admin_token>
Path Parameters
The unique identifier of the category to update.
Request Body
The new name for the category. Cannot be empty. Maximum length: 60 characters.
Response
The unique identifier of the updated category.
The updated name of the category.
Example Request
curl -X PATCH https://api.example.com/categories/1 \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Hot Beverages"
}'
Example Response
{
"id": 1,
"name": "Hot Beverages"
}
Error Responses
400 Bad Request
Returned when the request body is invalid or the ID parameter is invalid.
{
"statusCode": 400,
"message": [
"El nombre de la categoría no puede estar vacío"
],
"error": "Bad Request"
}
401 Unauthorized
Returned when authentication credentials are missing or invalid.
{
"statusCode": 401,
"message": "Unauthorized"
}
403 Forbidden
Returned when the user does not have admin role.
{
"statusCode": 403,
"message": "Forbidden resource",
"error": "Forbidden"
}
404 Not Found
Returned when the category with the specified ID does not exist.
{
"statusCode": 404,
"message": "Category not found",
"error": "Not Found"
}