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
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be application/json. |
accessToken | string | Access 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
| Field | Type | Description |
|---|---|---|
name | string | The name of the category. |
url | string | URL path segment for the category. |
description | string | A brief description of the category. Can be empty or omitted. |
parentCategory | string | ID of the parent category. Can be null if not applicable. |
path | string | Hierarchical path representation of the category. Required if parentCategory is set. |
images | array | List of image objects associated with the category, each containing url and description. |
isParent | boolean | Indicates whether the category is a parent category. |
seo | object | SEO details including pageTitle, metaKeywords, and metaDescription. |
metaFields | array | List of metadata objects, each containing a code and a value. |
Image Object (within images)
| Field | Type | Description |
|---|---|---|
url | string | URL of the image. |
description | string | Description of the image. |
SEO Object (within seo)
| Field | Type | Description |
|---|---|---|
pageTitle | string | Title for the category page. |
metaKeywords | string | Meta keywords for SEO. |
metaDescription | string | Meta description for SEO. |
MetaFields Object
Each object in the metaFields array includes:
| Field | Type | Description |
|---|---|---|
code | string | Code for the metadata field. |
value | mixed | Value 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
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the categories were updated successfully. Typically true for success. |
message | string | A 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 Code | Description |
|---|---|
| 400 | Bad Request: Provided data is invalid, missing fields, or malformed. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 404 | Not Found: One or more specified category IDs do not exist. |
| 500 | Internal 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
accessTokenis 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.