Skip to main content

Update Brand

This endpoint is used to update the details of an existing brand. You can change various fields such as name, description, images, and more.

Endpoint

  • URL: /brands/{id}
  • Method: PUT

Replace {id} with the specific brand ID you want to update.

Authentication

  • Header: accessToken
  • Type: Bearer Token
  • Value: <ACCESS-TOKEN>

Request Headers

HeaderTypeDescription
Content-TypestringMust be application/json.
accessTokenstringAccess token for authentication. (required)

Path Parameters

ParameterTypeDescription
idstringThe unique identifier of the brand to be updated.

Request Body

The request body should be a JSON object containing the fields you want to update. Below are the updatable fields:

Updatable Fields

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.

SEO Object (within seo)

FieldTypeDescription
pageTitlestringTitle for the brand page.
metaKeywordsstringMeta keywords for SEO.
metaDescriptionstringMeta description for SEO.

MetaFields Object

Each object in the metaFields array includes:

FieldTypeDescription
codestringCode for the metadata field.
valuemixedValue associated with the metadata (string, number, or array).

Sample Request Body

{
"name": "Nike Official",
"description": "Just Do It - Updated",
"sortOrder": 1,
"isFeatured": true
}

Sample Request with Image Update

{
"name": "Nike",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...",
"seo": {
"pageTitle": "Nike - Official Brand",
"metaKeywords": "nike, sports, athletic, shoes",
"metaDescription": "Discover Nike's official collection"
}
}

Response

  • Status Code: 200 OK

Success Response Fields

FieldTypeDescription
successbooleanIndicates whether the brand was updated successfully. Typically true for success.
messagestringA message conveying the outcome of the operation, e.g., "Brand updated successfully".
dataobjectContains details about the updated brand. See Brand Data Object

Example Success Response

{
"success": true,
"message": "Brand updated successfully",
"data": {
"id": "brand_id_here",
"name": "Nike Official",
"url": "nike",
"description": "Just Do It - Updated",
"image": null,
"productCount": 15,
"sortOrder": 1,
"isFeatured": true,
"isShow": true,
"isShowNavBar": false,
"seo": {
"pageTitle": "Nike - Official Brand",
"metaKeywords": "nike, sports, athletic, shoes",
"metaDescription": "Discover Nike's official collection"
},
"metaFields": [],
"createdAt": "2024-05-07T11:13:02.066Z",
"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: Brand with specified ID does not exist.
500Internal Server Error: An error occurred on the server.

Notes

  • Only the fields included in the request body will be updated. Other fields remain unchanged.
  • When updating images with base64 data, the old image is replaced with the new one after upload.
  • The productCount field cannot be manually updated; it's automatically maintained by the system.
  • Updates are automatically synced with Elasticsearch.
  • If products are associated with this brand, they will also be updated in Elasticsearch to reflect brand changes.
  • Ensure the ID of the brand you wish to update is valid and exists.
  • You must provide a valid accessToken for authentication.