Skip to main content
PATCH
/
categories
/
:id
curl --request PATCH \
  --url https://api.example.com/categories/1 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Premium Teas",
    "isActive": true
  }'
{
  "id": 1,
  "name": "Premium Teas",
  "slug": "premium-teas",
  "isActive": true,
  "createdAt": "2024-03-10T12:00:00.000Z"
}
Updates an existing category. When updating the name, the slug is automatically regenerated.
This endpoint requires authentication with an ADMIN role.

Authentication

Requires a valid JWT token in the Authorization header:
Authorization: Bearer <token>

Path Parameters

id
number
required
Category ID (must be numeric)

Body Parameters

All fields are optional. Only provide the fields you want to update.
name
string
Category name. Must be between 2 and 50 characters.Validation:
  • Minimum length: 2 characters
  • Maximum length: 50 characters
  • Must be unique
When the name is updated, the slug is automatically regenerated.
isActive
boolean
Whether the category should be active

Response

data
Category
The updated category object
curl --request PATCH \
  --url https://api.example.com/categories/1 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Premium Teas",
    "isActive": true
  }'
{
  "id": 1,
  "name": "Premium Teas",
  "slug": "premium-teas",
  "isActive": true,
  "createdAt": "2024-03-10T12:00:00.000Z"
}

Build docs developers (and LLMs) love