Update Category
Updates an existing category. Only the fields you send are changed; all other fields keep their current values. To move the category, send a new parentCategory.
HTTP Request
- URL:
/categories/{id} - Method:
PUT - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_CATEGORY
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | String | Required. The ID of the category to update. |
Request Body
Send a JSON object with the fields you want to change. At least one field is required.
| Field | Type | Required | Description |
|---|---|---|---|
name | String | No | Name of the category. |
url | String | No | URL slug of the category page. It is converted to lowercase with hyphens. |
description | String | No | Description of the category. Can be empty. |
parentCategory | String | No | ID of the new parent category, or null to make it a top-level category. |
path | String | Conditional | Required when parentCategory is set to an ID. |
image | String | No | URL of the category image. The image is copied to your store's media library. |
sortOrder | Number | No | Display order. Lower numbers appear first. |
isFeatured | Boolean | No | Whether the category is featured. |
isShow | Boolean | No | Whether the category is visible on the storefront. |
isShowNavBar | Boolean | No | Whether the category appears in the navigation bar. |
seo | Object | No | SEO settings with pageTitle, metaKeywords and metaDescription. |
metaFields | Array | No | Custom field values, each with a code and a value. See Metafields. |
cURL Example
curl --location --request PUT '<BASE_URL>/categories/66acedf2bf8641f96544253b' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Cordless Drills & Drivers",
"sortOrder": 3,
"isShowNavBar": true
}'
Response
- 200 OK: The request was processed. Check
successto confirm the category was updated. - 400 Bad Request: The access token is missing, invalid or lacks the required scope, the category ID is not valid, or the request body is not valid.
Sample JSON Response
{
"success": true,
"message": "Category updated successfully",
"data": {
"id": "66acedf2bf8641f96544253b",
"name": "Cordless Drills & Drivers",
"url": "cordless-drills",
"description": "Battery-powered drills and drivers.",
"image": "https://cdn.example.com/categories/cordless-drills.webp",
"parentCategory": "663a0cbe516313e5bc94aa87",
"path": "/663a0cbe516313e5bc94aa87/66acedf2bf8641f96544253b/",
"hasParent": true,
"hasChildren": false,
"productCount": 42,
"sortOrder": 3,
"isFeatured": false,
"isShow": true,
"isShowNavBar": true,
"seo": {
"pageTitle": "Cordless Drills",
"metaKeywords": "cordless, drill",
"metaDescription": "Shop cordless drills."
},
"metaFields": [],
"createdAt": "2024-08-02T14:32:18.344Z",
"updatedAt": "2024-10-21T08:42:17.512Z"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | true when the category was updated. |
message | String | Confirmation message. |
data | Object | The updated category. See Get Category for its fields. |
Notes
- If no category matches the ID, the response has
success: falseand the messageCategory not exists!. - When you move a category to a new parent, the paths of the category and all of its subcategories are updated.
seoreplaces the whole SEO object, so include every SEO field you want to keep.