Skip to main content

Create Product

Create a new product.

HTTP Request

POST/api/products/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO A 500 SERVER ERROR

Authorization

Authorization

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

Request Body

FieldTypeRequiredDescription
activeBooleanNoWhether the product is active (default: true)
orderIntegerNoDisplay order priority
codeStringNoProduct code/SKU (unique)
titleStringYesProduct title
slugStringYesURL-friendly product identifier (unique)
stock_typeStringNoStock management type (choices: call, limited, unlimited, out_of_stock)
stockIntegerNoAvailable stock quantity
regular_priceDecimalYesOriginal price of the product
sale_priceDecimalNoSale price (if on sale)
price_notesStringNoAdditional pricing notes
excerptStringNoShort product description
imageIntegerNoID of the product's main image
brandIntegerNoBrand ID
categoriesArray of IntegersNoList of Category IDs
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      'active': True,
7      'order': 10,
8      'code': 'GLP-2024-001',
9      'title': 'Gaming Laptop Pro',
10      'slug': 'gaming-laptop-pro',
11      'stock_type': 'limited',
12      'stock': 50,
13      'regular_price': 180000,
14      'sale_price': 155000,
15      'price_note': 'one time offer',
16      'excerpt': 'High-performance gaming laptop with RTX graphics',
17      'image': 342,
18      'brand': 1,
19      'categories': [5, 11],
20      'description': 'Ultimate gaming experience with latest processor and graphics card...'
21  },
22  headers={'Authorization': 'Token <your_api_key>'}
23)
24print(response.json())
25
26# Create minimal product
27response = requests.post('http://www.example.com/api/products', 
28  json={
29      'title': 'Simple Product',
30      'slug': 'simple-product',
31      'regular_price': 350000
32  },
33  headers={'Authorization': 'Token <your_api_key>'}
34)
35print(response.json())

Response Fields

FieldTypeDescription
idIntegerUnique ID of the product
activeBooleanWhether the product is active
orderIntegerRow-order priority (nullable)
codeStringProduct code/SKU (unique, nullable)
titleStringProduct title
slugStringURL-friendly product identifier (unique)
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)
image_dataObjectImage details
created_atString (ISO 8601)Timestamp when product was created
updated_atString (ISO 8601)Timestamp when product was last updated
brand_dataObjectThe product brand data
categories_dataList[Object]The product categories list
descriptionStringAdditional descriptions of the product
metaList[Object]List of meta data on the product

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)
thumbnailsList of thumbnail objectsImgae thumbnails

Thumbnail Data Structure

FieldTypeDescription
idIntegerUnique ID of the thumbnail (unique)
fStringURL to access the thumbnail file
sizeIntegerFile size in bytes (nullable)

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

Meta Data Structure

FieldTypeDescription
idIntegerUnique ID of the meta data
keyStringThe key name of the meta data
value_textStringThe text value of the meta data
value_fileObjectThe file value of the meta data

Meta value_file data structure

FieldTypeDescription
idIntegerUnique ID of the file
typeStringThe type of the file
nameStringThe name of the file
sizeIntegerThe size of the file in bytes
human_readable_sizeStringThe human-readable size of the file
fStringThe url to the file

Example Response

{
"id": 60,
"active": true,
"order": 1,
"code": "86",
"title": "Chair",
"slug": "product-name12",
"stock_type": "limited",
"stock": 10,
"in_stock": true,
"regular_price": 121999,
"sale_price": 122000,
"discount": -1,
"discount_percent": -0.0008196788498266379,
"price": 122000,
"price_notes": "for each one",
"excerpt": "Nam voluptas atque ipsum cum. Enim consectetur expedita nulla nulla harum. Qui blanditiis iusto occaecati. Modi excepturi soluta quibusdam autem fuga.",
"comments_count": 0,
"rating": 0.0,
"image_data": {
"id": 3,
"type": "image",
"name": "logitech-mx-2",
"size": 3166,
"human_readable_size": "3.09 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/11/22/logitech-mx-2.jpg",
"width": 275,
"height": 183,
"mode": "RGB",
"thumbnails": [
{
"id": 213,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_64x64.jpg",
"size": 64
},
{
"id": 214,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_128x128.jpg",
"size": 128
},
{
"id": 215,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_512x512.jpg",
"size": 512
},
{
"id": 216,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_1080x1080.jpg",
"size": 1080
}
]
},
"created_at": "2025-12-27T12:40:13.439538Z",
"updated_at": "2025-12-27T12:40:13.439544Z",
"brand_data": {
"id": 1,
"name": "Logitech"
},
"categories_data": [
{
"id": 1,
"name": "کالای دیجیتال"
},
{
"id": 2,
"name": "ماوس"
}
],
"description": "long description for product",
"meta": []
}

Notes

  • Each product can belong to multiple categories
  • The meta data related to each product is definable from the PageMeta endpoints
  • discount, discount_percent, price, comment_count, rating are computed fields