Update Category
Update an existing category’s information. You can modify any field including the parent category relationship.
Endpoint
PUT /api/v1/categories/{id}
Path Parameters
The unique identifier of the category to update
Request Body
Detailed description of the category
ID of the parent category. Set to null to make it a main category
Whether the category should be active
Response
Returns the updated category object.
Unique identifier for the category
Detailed description of the category
ID of the parent category (null for main categories)
Whether the category is currently active
List of product IDs associated with this category
List of subcategory IDs that belong to this category
Status Codes
200 - Category successfully updated
404 - Category not found
400 - Invalid request body or validation error
Examples
Update Category Name and Description
curl -X PUT "https://api.example.com/api/v1/categories/1" \
-H "Content-Type: application/json" \
-d '{
"name": "Modern Living Room",
"description": "Contemporary furniture for modern living spaces",
"isActive": true
}'
Response
{
"id": 1,
"name": "Modern Living Room",
"description": "Contemporary furniture for modern living spaces",
"parentId": null,
"isActive": true,
"product_ids": [101, 102, 103],
"subcategory_ids": [10, 11]
}
Deactivate a Category
curl -X PUT "https://api.example.com/api/v1/categories/10" \
-H "Content-Type: application/json" \
-d '{
"name": "Sofas",
"description": "Comfortable seating furniture",
"parentId": 1,
"isActive": false
}'
Response
{
"id": 10,
"name": "Sofas",
"description": "Comfortable seating furniture",
"parentId": 1,
"isActive": false,
"product_ids": [201, 202],
"subcategory_ids": []
}
Change Parent Category
curl -X PUT "https://api.example.com/api/v1/categories/15" \
-H "Content-Type: application/json" \
-d '{
"name": "Office Chairs",
"description": "Ergonomic office seating",
"parentId": 2,
"isActive": true
}'