Skip to main content

Update Category

This endpoint is used to update the details of an existing category. You can change various fields such as name, description, parent category, and more.

Endpoint

  • URL: /categories/{id}
  • Method: PUT

Replace {id} with the specific category ID you want to update.

Authentication

  • Header: accessToken
  • Type: Bearer Token
  • Value: <ACCESS-TOKEN>

Request Headers

HeaderTypeDescription
Content-TypestringMust be application/json.
accessTokenstringAccess token for authentication. (required)

Path Parameters

ParameterTypeDescription
idstringThe unique identifier of the category to be updated.

Request Body

The request body should be a JSON object containing the fields you want to update. Below are the optional and required fields:

Updatable Fields

FieldTypeDescription
namestringThe name of the category.
urlstringURL path segment for the category.
descriptionstringA brief description of the category. Can be empty or omitted.
parentCategorystringID of the parent category. Can be null if not applicable.
pathstringHierarchical path representation of the category. Required if parentCategory is set.
imagesarrayList of image objects associated with the category, each containing url and description.
isParentbooleanIndicates whether the category is a parent category.
seoobjectSEO details including pageTitle, metaKeywords, and metaDescription.
metaFieldsarrayList of metadata objects, each containing a code and a value.

Image Object (within images)

FieldTypeDescription
urlstringURL of the image.
descriptionstringDescription of the image.

SEO Object (within seo)

FieldTypeDescription
pageTitlestringTitle for the category page.
metaKeywordsstringMeta keywords for SEO.
metaDescriptionstringMeta description for SEO.

MetaFields Object

Each object in the metaFields array includes:

FieldTypeDescription
codestringCode for the metadata field.
valuemixedValue associated with the metadata (string, number, or array).

Sample Request Body

{
"name": "Chem"
}

Response

  • Status Code: 200 OK

Success Response Fields

FieldTypeDescription
successbooleanIndicates whether the category was updated successfully. Typically true for success.
messagestringA message conveying the outcome of the operation, e.g., "Category updated successfully".
dataobjectContains details about the updated category. See Category Data

Example Success Response

{
"success": true,
"message": "Category updated successfully",
"data": {
"id": "632ccc741683c8f033d6e163",
"name": "Chem"
// Other potentially included updated fields
}
}

Error Responses

Status CodeDescription
400Bad Request: Provided data is invalid or malformed.
401Unauthorized: Access token is invalid or missing.
404Not Found: Category with specified ID does not exist.
500Internal Server Error: An error occurred on the server.

Notes

  • Ensure the ID of the category you wish to update is valid and exists.
  • You must provide a valid accessToken for authentication.
  • The fields you want to update must be included in the request body; omitted fields will remain unchanged.