Skip to main content
PATCH
/
categories
/
{id}
Update Category
curl --request PATCH \
  --url https://api.example.com/categories/{id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>"
}
'
{
  "id": 123,
  "name": "<string>"
}
Update an existing category.

Authentication

This endpoint requires authentication with the admin role.
Authorization: Bearer <admin_token>

Path Parameters

id
integer
required
The unique identifier of the category to update.

Request Body

name
string
required
The new name for the category. Cannot be empty. Maximum length: 60 characters.

Response

id
number
The unique identifier of the updated category.
name
string
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"
}

Build docs developers (and LLMs) love