Skip to main content

Create Multiple Categories

This endpoint is used to create multiple categories in the system in a single request. Each category can have its own set of details, including optional metadata.

Endpoint

  • URL: /categories/multiple
  • Method: POST

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 to be created. Below are the fields for each category:

Required Fields

FieldTypeDescription
namestringThe name of the category.
urlstringURL path segment for the category.

Optional Fields

FieldTypeDescription
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.
isParentbooleanWhether the category is a parent category.
seoobjectSEO details including pageTitle, metaKeywords, and metaDescription.
metaFieldsarrayList of metadata objects, each containing a code and a value (string, number, or array).

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
codestringThe code for the metadata field.
valuestring, number, or arrayThe value associated with the metadata field. Can be a string, number, or array.

Sample Request Body

[
{
"name": "Online Orderings",
"image": "https://cdn.flexipim.com/spruceindustries/category/1614988845_41qzNLZq6SL.jpg",
"description": "",
"metaFields": [
{
"code": "pim_id",
"value": 1
}
],
"sortOrder": 0
},
{
"name": "Safety & Security",
"image": "https://cdn.flexipim.com/spruceindustries/category/1614988845_41qzNLZq6SL.jpg",
"description": "",
"metaFields": [
{
"code": "pim_id",
"value": 2
},
{
"code": "pim_parent_id",
"value": 1
}
],
"sortOrder": 1
},
{
"name": "testsdf",
"image": "https://cdn.flexipim.com/spruceindustries/category/1614988845_41qzNLZq6SL.jpg",
"description": "",
"metaFields": [
{
"code": "pim_id",
"value": 4
},
{
"code": "pim_parent_id",
"value": 2
}
],
"sortOrder": 2
}
]

Response

  • Status Code: 200 Created (typically for successful creation)

Success Response Fields

FieldTypeDescription
successbooleanIndicates whether the categories were created successfully.
messagestringA message conveying the outcome of the operation, e.g., "Categories created successfully".

Error Responses

Status CodeDescription
400Bad Request: Provided data is invalid, missing fields, or malformed.
401Unauthorized: Access token is invalid or missing.
500Internal Server Error: An error occurred on the server.

Notes

  • Ensure all categories are correctly formatted in the array of objects in the request body.
  • The accessToken is crucial for authenticating the request and must be valid.
  • Large batches of categories might affect the response time, ensure the system supports the intended load.