Delete Brand
This endpoint is used to delete an existing brand by its ID. Deleting a brand will automatically unassign it from all associated products.
Endpoint
- URL:
/brands/{id} - Method:
DELETE
Replace {id} with the specific brand ID you want to delete.
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
accessToken | string | Access token for authentication. (required) |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the brand to be deleted. |
Example Request
Here is an example using curl to delete a brand:
curl --location --request DELETE '<BASE-URL>/brands/brand_id_here' \
--header 'accessToken: <ACCESS-TOKEN>'
Note
- Replace the placeholder in the URL with the actual brand ID.
- Ensure you include a valid
accessTokenin the request to authenticate.
Response
- Status Code: 200 OK
Success Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the brand was deleted successfully. |
message | string | A message conveying the outcome of the operation, including the brand name. |
Example Success Response
{
"success": true,
"message": "Brand Nike deleted successfully"
}
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. |
Important Notes
Automatic Product Updates
When a brand is deleted, the system automatically:
- Unassigns the brand from all associated products - All products that had this brand assigned will have their brand reference removed.
- Updates Elasticsearch - All affected products are updated in Elasticsearch to reflect the brand removal.
- Maintains data integrity - Ensures no orphaned references remain in the database.
Example Impact
If you delete a brand named "Nike" that has 50 products associated with it:
- All 50 products will have their brand field set to
null - All 50 products will be updated in Elasticsearch
- The brand "Nike" will be completely removed from the system
- The operation completes in a single transaction
Best Practices
- Review before deletion: Check how many products are associated with the brand before deleting.
- Alternative approach: Consider setting
isShow: falseinstead of deleting if you want to hide the brand temporarily. - Backup: Ensure you have backups if you need to restore brand data later.
Cannot Be Undone
Brand deletion is permanent and cannot be undone. If you need to restore a deleted brand:
- Create a new brand with the same details
- Re-assign products to the new brand using the Assign Products to Brand endpoint
Notes
- Ensure the ID of the brand you wish to delete is valid and exists.
- You must provide a valid
accessTokenfor authentication. - The deletion process is transactional - either everything succeeds or everything fails.