Skip to main content

Update Attribute

Update a specific attribute.

HTTP Request

PATCH/api/products/attributes/:id

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the attribute to update

Request Body

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

Example Requests

1import requests
2
3# Update an existing attribute
4response = requests.patch('http://www.example.com/api/products/attributes/123',
5  json={
6      'name': 'Updated Color',
7      'description': 'Updated description for the color attribute'
8  },
9  headers={'Authorization': 'Token <your_api_key>'}
10)
11print(response.json())
12
13# Update another attribute
14
15response = requests.patch('http://www.example.com/api/products/attributes/456',
16  json={
17      'name': 'Updated Size',
18      'description': 'Updated description for the size attribute'
19  },
20  headers={'Authorization': 'Token <your_api_key>'}
21)
22print(response.json())

Status Codes

CodeDescription
200Attribute updated successfully
400Bad request — invalid data
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Not found — attribute does not exist
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