Skip to main content

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

HeaderTypeDescription
Content-TypestringMust be application/json.
accessTokenstringAccess 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)

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

Optional Fields (for each brand)

FieldTypeDescription
descriptionstringA brief description of the brand.
imagestringBrand main image. Can be a URL or base64 encoded image data.
sortOrdernumberOrder for sorting brands. Defaults to 0.
isShowbooleanWhether the brand is shown. Defaults to true.
isShowNavBarbooleanWhether the brand is shown in the navigation bar. Defaults to false.
seoobjectSEO details including pageTitle, metaKeywords, and metaDescription.
metaFieldsarrayList 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

FieldTypeDescription
successbooleanIndicates whether the brands were created successfully.
messagestringA message conveying the outcome of the operation.
dataarrayArray of newly created brand objects. See Brand Data Object

Error Responses

Status CodeDescription
400Bad Request: Provided data is invalid or malformed.
401Unauthorized: Access token is invalid or missing.
500Internal 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 productCount for each new brand is initialized to 0.