Skip to main content

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

FieldTypeRequiredDescription
nameStringYesAttribute name (max 150 characters)
descriptionStringNoAttribute description (max 500 characters)

Example Requests

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())

Status Codes

CodeDescription
201Attribute created successfully
400Bad request — invalid data
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the attribute
nameStringAttribute name (max 150 characters)
descriptionStringAttribute description (max 500 characters)
created_atString (ISO 8601)Timestamp when attribute was created
updated_atString (ISO 8601)Timestamp when attribute was last updated