Skip to main content

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

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 object must include the brand id and the fields you want to update.

Required Fields (for each brand)

FieldTypeDescription
idstringThe unique identifier of the brand to be updated.

Updatable Fields (for each brand)

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

FieldTypeDescription
successbooleanIndicates whether the brands were updated successfully.
messagestringA 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 CodeDescription
400Bad Request: Provided data is invalid or malformed.
401Unauthorized: Access token is invalid or missing.
404Not Found: One or more brand IDs do not exist.
500Internal Server Error: An error occurred on the server.

Notes

  • Each brand object in the array must include a valid id field.
  • 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
  • You must provide a valid accessToken for authentication.