Update Brand
Updates an existing brand with new information. Only the provided fields will be updated.
HTTP Request
PATCH/api/products/brands/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the brand to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | String | No | Brand name (must be unique) |
| slug | String | No | URL-friendly version of the brand name (auto-generated if not provided) |
| image | Integer | No | ID of the brand image |
| order | Integer | No | Display order for brand sorting |
| description | String | No | Brand description (max 500 characters) |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Update brand name and order
4response = requests.patch('http://www.example.com/api/products/brands/123',
5 json={
6 'name': 'Nike Sports',
7 'order': 2,
8 'description': 'Updated brand description with new focus on sports equipment'
9 },
10 headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())
13
14# Update only the image
15response = requests.patch('http://www.example.com/api/products/brands/123',
16 json={
17 'image': 456
18 },
19 headers={'Authorization': 'Token <your_api_key>'}
20)
21print(response.json())
22
23# Remove image by setting to null
24response = requests.patch('http://www.example.com/api/products/brands/123',
25 json={
26 'image': None
27 },
28 headers={'Authorization': 'Token <your_api_key>'}
29)
30print(response.json())1# Update brand name and order
2curl -X PATCH "http://www.example.com/api/products/brands/123" \
3-H "Authorization: Token <your_api_key>" \
4-H "Content-Type: application/json" \
5-d '{
6 "name": "Nike Sports",
7 "order": 2,
8 "description": "Updated brand description with new focus on sports equipment"
9}'
10
11# Update only the image
12curl -X PATCH "http://www.example.com/api/products/brands/123" \
13-H "Authorization: Token <your_api_key>" \
14-H "Content-Type: application/json" \
15-d '{
16 "image": 456
17}'
18
19# Remove image by setting to null
20curl -X PATCH "http://www.example.com/api/products/brands/123" \
21-H "Authorization: Token <your_api_key>" \
22-H "Content-Type: application/json" \
23-d '{
24 "image": null
25}'Status Codes
| Code | Description |
|---|---|
| 200 | Brand updated successfully |
| 400 | Bad request — invalid input or duplicate name |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Not found — brand does not exist |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the brand |
| image_data | Object | Brand image details (read-only) |
| order | Integer | Display order for brand sorting |
| name | String | Brand name (unique) |
| slug | String | URL-friendly version of the brand name |
| description | String | Brand description (max 500 characters) |
| products_count | Integer | Number of products associated with brand |
| created_at | String (ISO 8601) | Timestamp when brand was created |
| updated_at | String (ISO 8601) | Timestamp when brand was last updated |
Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Image ID |
| type | String | File type |
| name | String | Image file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size |
| f | String | Image file URL |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Image color mode |