Skip to main content

Update Multiple Categories

This endpoint allows updating multiple categories in a single request. Each category's details can be updated, including its name, image, description, and more.

Endpoint

  • URL: /categories/multiple
  • Method: PUT

Authentication

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

Request Headers

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

Request Body

The request body should be a JSON array of objects, where each object represents a category whose details you want to update. Below are the fields for each category:

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

[
{
"id": "642bbe8a79562f406f74f38e",
"name": "Online Orderings",
"image": "https://cdn.flexipim.com/spruceindustries/category/1614988845_41qzNLZq6SL.jpg",
"description": "",
"parentCategory": null,
"metaFields": [
{
"code": "pim_id",
"value": 1
}
],
"sortOrder": 0
},
{
"id": "642bbe8a79562f406f74f390",
"name": "Safety & Security",
"image": "https://cdn.flexipim.com/spruceindustries/category/1614988845_41qzNLZq6SL.jpg",
"description": "",
"parentCategory": "642bbe8a79562f406f74f393",
"metaFields": [
{
"code": "pim_id",
"value": 4
},
{
"code": "pim_parent_id",
"value": 1
}
],
"sortOrder": 1
}
]

Response

  • Status Code: 200 OK

Success Response Fields

FieldTypeDescription
successbooleanIndicates whether the categories were updated successfully. Typically true for success.
messagestringA message conveying the outcome of the operation, e.g., "Categories updated successfully".

Example Success Response

{
"success": true,
"message": "Categories updated successfully",
"data": [
{
"id": "642bbe8a79562f406f74f38e",
"name": "Online Orderings",
// Additional updated fields
},
{
"id": "642bbe8a79562f406f74f390",
"name": "Safety & Security",
// Additional updated fields
},
// More category objects
]
}

Error Responses

Status CodeDescription
400Bad Request: Provided data is invalid, missing fields, or malformed.
401Unauthorized: Access token is invalid or missing.
404Not Found: One or more specified category IDs do not exist.
500Internal Server Error: An error occurred on the server.

Notes

  • Ensure all categories are correctly formatted and each has a valid ID in the array of objects in the request body.
  • The accessToken is crucial for authenticating the request and must be valid.
  • Fields you wish to update should be included in each category object; omitted fields will remain unchanged.