Skip to main content

Update Product

Update an existing product.

HTTP Request

PATCH/api/products/:id

Authorization

Authorization

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

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the product to update

Request Body

FieldTypeRequiredDescription
nameStringYesProduct name
codeStringNoProduct code/SKU
slugStringNoURL-friendly product identifier
activeBooleanNoWhether the product is active (default: true)
imageIntegerNoID of the product's main image
orderIntegerNoDisplay order priority
brandIntegerNoBrand ID
categoriesArray of IntegersNoList of Category IDs
stock_typeStringNoStock management type
stockIntegerNoAvailable stock quantity
regular_priceDecimalNoOriginal price of the product
sale_priceDecimalNoSale price (if on sale)
price_notesStringNoAdditional pricing notes
excerptStringNoShort product description
descriptionStringNoFull product description

Example Requests

1import requests
2
3# Partial update (PATCH)
4response = requests.patch('http://www.example.com/api/products/123', 
5  json={
6      'name': 'Updated Gaming Laptop Pro',
7      'sale_price': 899.99,
8      'stock': 25,
9      'active': True
10  },
11  headers={'Authorization': 'Token <your_api_key>'}
12)
13print(response.json())
14
15# Update price and stock
16response = requests.patch('http://www.example.com/api/products/123', 
17  json={
18      'regular_price': 1399.99,
19      'sale_price': 1099.99,
20      'stock': 100
21  },
22  headers={'Authorization': 'Token <your_api_key>'}
23)
24print(response.json())

Status Codes

CodeDescription
200Product updated successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Not found — product does not exist
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the product
activeBooleanWhether the product is active
image_dataObjectImage details (read-only)
orderIntegerDisplay order priority
codeStringProduct code/SKU
nameStringProduct name
slugStringURL-friendly product identifier
stock_typeStringStock management type
stockIntegerAvailable stock quantity
in_stockBooleanWhether the product is in stock (computed)
regular_priceDecimalOriginal price of the product
sale_priceDecimalSale price (if on sale)
discountDecimalDiscount amount (computed)
discount_percentDecimalDiscount percentage (computed)
priceDecimalFinal price after discount (computed)
price_notesStringAdditional pricing notes
excerptStringShort product description
comments_countIntegerNumber of comments (computed)
ratingDecimalAverage product rating (computed)
descriptionStringFull product description
created_atString (ISO 8601)Timestamp when product was created
updated_atString (ISO 8601)Timestamp when product was last updated
brand_dataObjectBrand details (id: int, name: string)
categories_dataArray[Object]List of categories the product belongs to (id: int, name: string)

Image Data Structure

FieldTypeDescription
idIntegerUnique ID of the image
typeStringFile type (e.g., image/jpeg)
nameStringOriginal file name
sizeIntegerFile size in bytes
human_readable_sizeStringHuman readable file size (e.g., 2.5 MB)
fStringURL to access the image file
widthIntegerImage width in pixels
heightIntegerImage height in pixels
modeStringColor mode (e.g., RGB, CMYK)

Brand Data Structure

FieldTypeDescription
idIntegerUnique ID of the brand
nameStringName of the brand

Categories Data Structure

FieldTypeDescription
idIntegerUnique ID of the category
nameStringName of the category

Notes

  • Fields marked as "computed" are generated by the system and cannot be set directly.
  • Date fields are in ISO 8601 format (e.g., "2023-01-01T12:00:00Z").