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
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be application/json. |
accessToken | string | Access token for authentication. (required) |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The 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
| 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. |
SEO Object (within seo)
| Field | Type | Description |
|---|---|---|
pageTitle | string | Title for the brand page. |
metaKeywords | string | Meta keywords for SEO. |
metaDescription | string | Meta description for SEO. |
MetaFields Object
Each object in the metaFields array includes:
| Field | Type | Description |
|---|---|---|
code | string | Code for the metadata field. |
value | mixed | Value 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
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the brand was updated successfully. Typically true for success. |
message | string | A message conveying the outcome of the operation, e.g., "Brand updated successfully". |
data | object | Contains 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 Code | Description |
|---|---|
| 400 | Bad Request: Provided data is invalid or malformed. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 404 | Not Found: Brand with specified ID does not exist. |
| 500 | Internal 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
productCountfield 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
accessTokenfor authentication.