Create Multiple Brands
This endpoint is used to create multiple brands in a single request. It accepts an array of brand objects and creates them in bulk.
Endpoint
- URL:
/brands/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 containing multiple brand objects. Each brand object should follow the same structure as the single brand creation.
Required Fields (for each brand)
| Field | Type | Description |
|---|---|---|
name | string | The name of the brand. |
url | string | URL path segment for the brand. |
Optional Fields (for each brand)
| Field | Type | Description |
|---|---|---|
description | string | A brief description of the brand. |
image | string | Brand main image. Can be a URL or base64 encoded image data. |
sortOrder | number | Order for sorting brands. Defaults to 0. |
isShow | boolean | Whether the brand is shown. Defaults to true. |
isShowNavBar | boolean | Whether the brand is shown in the navigation bar. Defaults to false. |
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). |
Sample Request Body
[
{
"name": "Nike",
"url": "nike",
"description": "Just Do It",
"isFeatured": true,
"isShow": true,
"sortOrder": 1,
"seo": {
"pageTitle": "Nike Brand",
"metaKeywords": "nike, sports, shoes",
"metaDescription": "Official Nike brand page"
}
},
{
"name": "Adidas",
"url": "adidas",
"description": "Impossible is Nothing",
"isFeatured": true,
"isShow": true,
"sortOrder": 2,
"seo": {
"pageTitle": "Adidas Brand",
"metaKeywords": "adidas, sports, shoes",
"metaDescription": "Official Adidas brand page"
}
},
{
"name": "Puma",
"url": "puma",
"description": "Forever Faster",
"isFeatured": false,
"isShow": true,
"sortOrder": 3
}
]
Response
- Status Code: 201 Created
Success Response Body
{
"success": true,
"message": "Brands added successfully",
"data": [
{
"id": "brand_id_1",
"name": "Nike",
"url": "nike",
"description": "Just Do It",
"productCount": 0,
"sortOrder": 1,
"isFeatured": true,
"isShow": true,
"isShowNavBar": false,
"seo": {
"pageTitle": "Nike Brand",
"metaKeywords": "nike, sports, shoes",
"metaDescription": "Official Nike brand page"
},
"metaFields": [],
"createdAt": "2024-05-07T11:13:02.066Z",
"updatedAt": "2024-05-07T11:13:02.066Z"
},
{
"id": "brand_id_2",
"name": "Adidas",
"url": "adidas",
"description": "Impossible is Nothing",
"productCount": 0,
"sortOrder": 2,
"isFeatured": true,
"isShow": true,
"isShowNavBar": false,
"seo": {
"pageTitle": "Adidas Brand",
"metaKeywords": "adidas, sports, shoes",
"metaDescription": "Official Adidas brand page"
},
"metaFields": [],
"createdAt": "2024-05-07T11:13:02.066Z",
"updatedAt": "2024-05-07T11:13:02.066Z"
},
{
"id": "brand_id_3",
"name": "Puma",
"url": "puma",
"description": "Forever Faster",
"productCount": 0,
"sortOrder": 3,
"isFeatured": false,
"isShow": true,
"isShowNavBar": false,
"seo": null,
"metaFields": [],
"createdAt": "2024-05-07T11:13:02.066Z",
"updatedAt": "2024-05-07T11:13:02.066Z"
}
]
}
Success Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the brands were created successfully. |
message | string | A message conveying the outcome of the operation. |
data | array | Array of newly created brand objects. See Brand Data Object |
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request: Provided data is invalid or malformed. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 500 | Internal Server Error: An error occurred on the server. |
Notes
- All brands in the array are processed and created in a single transaction.
- If any brand fails validation, the entire operation may be rolled back depending on server configuration.
- Each brand is independently validated for required fields.
- Base64 images are automatically uploaded for each brand that includes them.
- All created brands are automatically synced with Elasticsearch.
- The
productCountfor each new brand is initialized to 0.