Skip to main content

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​

ParameterTypeDescription
idStringRequired. 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.

FieldTypeRequiredDescription
nameStringNoName of the category.
urlStringNoURL slug of the category page. It is converted to lowercase with hyphens.
descriptionStringNoDescription of the category. Can be empty.
parentCategoryStringNoID of the new parent category, or null to make it a top-level category.
pathStringConditionalRequired when parentCategory is set to an ID.
imageStringNoURL of the category image. The image is copied to your store's media library.
sortOrderNumberNoDisplay order. Lower numbers appear first.
isFeaturedBooleanNoWhether the category is featured.
isShowBooleanNoWhether the category is visible on the storefront.
isShowNavBarBooleanNoWhether the category appears in the navigation bar.
seoObjectNoSEO settings with pageTitle, metaKeywords and metaDescription.
metaFieldsArrayNoCustom 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 success to 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​

FieldTypeDescription
successBooleantrue when the category was updated.
messageStringConfirmation message.
dataObjectThe updated category. See Get Category for its fields.

Notes​

  • If no category matches the ID, the response has success: false and the message Category not exists!.
  • When you move a category to a new parent, the paths of the category and all of its subcategories are updated.
  • seo replaces the whole SEO object, so include every SEO field you want to keep.