Create Attribute
Create a specific attribute.
HTTP Request
POST/api/products/attributes
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | Attribute name (max 150 characters) |
| description | String | No | Attribute description (max 500 characters) |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2# Create a new attribute
3response = requests.post('http://www.example.com/api/products/attributes',
4 json={
5 'name': 'Color',
6 'description': 'The color of the product'
7 },
8 headers={'Authorization': 'Token <your_api_key>'}
9)
10
11print(response.json())
12
13# Create another attribute
14
15response = requests.post('http://www.example.com/api/products/attributes',
16 json={
17 'name': 'Size',
18 'description': 'The size of the product'
19 },
20 headers={'Authorization': 'Token <your_api_key>'}
21)
22
23print(response.json())1# Create a new attribute
2curl -X POST "http://www.example.com/api/products/attributes" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
3 "name": "Color",
4 "description": "The color of the product"
5}'Status Codes
| Code | Description |
|---|---|
| 201 | Attribute created successfully |
| 400 | Bad request — invalid data |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the attribute |
| name | String | Attribute name (max 150 characters) |
| description | String | Attribute description (max 500 characters) |
| created_at | String (ISO 8601) | Timestamp when attribute was created |
| updated_at | String (ISO 8601) | Timestamp when attribute was last updated |