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
| 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 to be created. Below are the fields for each category:
Required Fields
| Field | Type | Description |
|---|---|---|
name | string | The name of the category. |
url | string | URL path segment for the category. |
Optional Fields
| Field | Type | Description |
|---|---|---|
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 | 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 (string, number, or array). |
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 | The code for the metadata field. |
value | string, number, or array | The 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
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the categories were created successfully. |
message | string | A message conveying the outcome of the operation, e.g., "Categories created successfully". |
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request: Provided data is invalid, missing fields, or malformed. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 500 | Internal 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
accessTokenis 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.