Skip to main content

Create Product

Create a new product.

HTTP Request

POST/api/products

Authorization

Authorization

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

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# Create a new product
4response = requests.post('http://www.example.com/api/products', 
5  json={
6      'name': 'Gaming Laptop Pro',
7      'code': 'GLP-2024-001',
8      'slug': 'gaming-laptop-pro',
9      'active': True,
10      'brand': 1,
11      'categories': [5],
12      'stock_type': 'managed',
13      'stock': 50,
14      'regular_price': 1299.99,
15      'sale_price': 999.99,
16      'excerpt': 'High-performance gaming laptop with RTX graphics',
17      'description': 'Ultimate gaming experience with latest processor and graphics card...'
18  },
19  headers={'Authorization': 'Token <your_api_key>'}
20)
21print(response.json())
22
23# Create minimal product
24response = requests.post('http://www.example.com/api/products', 
25  json={
26      'name': 'Simple Product',
27      'regular_price': 29.99
28  },
29  headers={'Authorization': 'Token <your_api_key>'}
30)
31print(response.json())

Status Codes

CodeDescription
201Product created successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
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").