Update Multiple Brands
This endpoint is used to update multiple brands in a single request. It accepts an array of brand objects with their IDs and the fields to update.
Endpoint
- URL:
/brands/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 containing multiple brand objects. Each object must include the brand id and the fields you want to update.
Required Fields (for each brand)
| Field | Type | Description |
|---|---|---|
id | string | The unique identifier of the brand to be updated. |
Updatable Fields (for each brand)
| Field | Type | Description |
|---|---|---|
name | string | The name of the brand. |
url | string | URL path segment for the brand. |
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. |
isShow | boolean | Whether the brand is shown. |
isShowNavBar | boolean | Whether the brand is shown in the navigation bar. |
seo | object | SEO details including pageTitle, metaKeywords, and metaDescription. |
metaFields | array | List of metadata objects, each containing a code and a value. |
Sample Request Body
[
{
"id": "brand_id_1",
"name": "Nike Official",
"sortOrder": 1,
"isFeatured": true
},
{
"id": "brand_id_2",
"sortOrder": 2,
"isFeatured": true,
"isShowNavBar": true
},
{
"id": "brand_id_3",
"description": "Updated description for Puma",
"sortOrder": 3,
"seo": {
"pageTitle": "Puma Brand",
"metaDescription": "Official Puma brand page"
}
}
]
Sample Request with Images
[
{
"id": "brand_id_1",
"image": "https://example.com/new-nike-image.png",
"isFeatured": true
},
{
"id": "brand_id_2",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...",
"isFeatured": false
}
]
Response
- Status Code: 200 OK
Success Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the brands were updated successfully. |
message | string | A message conveying the outcome of the operation. |
Example Success Response
{
"success": true,
"message": "Brands updated successfully"
}
Detailed Success Response (if applicable)
Some implementations may return the updated brand data:
{
"success": true,
"message": "Brands updated successfully",
"data": [
{
"id": "brand_id_1",
"name": "Nike Official",
"sortOrder": 1,
"isFeatured": true,
"updatedAt": "2024-10-09T13:05:59.036Z"
},
{
"id": "brand_id_2",
"sortOrder": 2,
"isFeatured": true,
"isShowNavBar": true,
"updatedAt": "2024-10-09T13:05:59.036Z"
}
]
}
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request: Provided data is invalid or malformed. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 404 | Not Found: One or more brand IDs do not exist. |
| 500 | Internal Server Error: An error occurred on the server. |
Notes
- Each brand object in the array must include a valid
idfield. - Only the fields included in each brand object will be updated for that specific brand.
- All updates are processed in a single transaction.
- If one brand update fails, the behavior depends on server configuration (may rollback all or continue with others).
- Base64 images are automatically uploaded for each brand that includes them.
- All updated brands are automatically synced with Elasticsearch.
- Products associated with updated brands will also be updated in Elasticsearch to reflect brand changes.
- This is particularly useful for bulk operations like:
- Reordering multiple brands by updating
sortOrder - Marking multiple brands as featured
- Bulk SEO updates
- Bulk visibility updates
- Reordering multiple brands by updating
- You must provide a valid
accessTokenfor authentication.