Update Product Attribute
Updates an existing product attribute.
HTTP Request
PATCH/api/products/:product_id/attributes/:product_attribute_id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| product_id | Integer | Yes | Unique ID of the product |
| product_attribute_id | Integer | Yes | Unique ID of the product attribute |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| values | Array | Yes | List of attribute values to update |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Update a specific product attribute
4response = requests.patch('http://www.example.com/api/products/123/attributes/456',
5 headers={'Authorization': 'Token <your_api_key>'},
6 json={
7 "values": [10, 11, 12]
8 }
9)
10
11print(response.json())
12
13# Update with single value
14response = requests.patch('http://www.example.com/api/products/123/attributes/456',
15 headers={'Authorization': 'Token <your_api_key>'},
16 json={
17 "values": [20]
18 }
19)
20
21print(response.json())1# Update a specific product attribute
2curl -X PATCH "http://www.example.com/api/products/123/attributes/456" \
3-H "Authorization: Token <your_api_key>" \
4-H "Content-Type: application/json" \
5-d '{
6 "values": [10, 11, 12]
7}'
8
9# Update with single value
10curl -X PATCH "http://www.example.com/api/products/123/attributes/456" \
11-H "Authorization: Token <your_api_key>" \
12-H "Content-Type: application/json" \
13-d '{
14 "values": [20]
15}'Status Codes
| Code | Description |
|---|---|
| 200 | Product attribute updated successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Not found — product or attribute does not exist |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the product attribute |
| attribute_data | Object | Details of the attribute (id, name, description) |
| value_data | Object | Details of the attribute value (id, value) |
| created_at | String (ISO 8601) | Timestamp when product attribute was created |
| updated_at | String (ISO 8601) | Timestamp when product attribute was last updated |
Attribute Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the attribute |
| name | String | Name of the attribute |
| description | String | Description of the attribute |
| created_at | String (ISO 8601) | Timestamp when attribute was created |
| updated_at | String (ISO 8601) | Timestamp when attribute was last updated |
Value Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the attribute value |
| value | String | The value of the attribute |
| created_at | String (ISO 8601) | Timestamp when attribute value was created |
| updated_at | String (ISO 8601) | Timestamp when attribute value was last updated |