Skip to main content

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

id
integer
required
The unique identifier of the category to update

Request Body

name
string
The category name
description
string
Detailed description of the category
parentId
integer
ID of the parent category. Set to null to make it a main category
isActive
boolean
Whether the category should be active

Response

Returns the updated category object.
id
integer
Unique identifier for the category
name
string
The category name
description
string
Detailed description of the category
parentId
integer
ID of the parent category (null for main categories)
isActive
boolean
Whether the category is currently active
product_ids
array
List of product IDs associated with this category
subcategory_ids
array
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
  }'

Build docs developers (and LLMs) love