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
| Field | Type | Required | Description |
|---|---|---|---|
| active | Boolean | No | Whether the product is active (default: true) |
| order | Integer | No | Display order priority |
| code | String | No | Product code/SKU (unique) |
| title | String | Yes | Product title |
| slug | String | Yes | URL-friendly product identifier (unique) |
| stock_type | String | No | Stock management type (choices: call, limited, unlimited, out_of_stock) |
| stock | Integer | No | Available stock quantity |
| regular_price | Decimal | Yes | Original price of the product |
| sale_price | Decimal | No | Sale price (if on sale) |
| price_notes | String | No | Additional pricing notes |
| excerpt | String | No | Short product description |
| image | Integer | No | ID of the product's main image |
| brand | Integer | No | Brand ID |
| categories | Array of Integers | No | List of Category IDs |
| description | String | No | Full product description |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1curl -X POST "http://www.example.com/api/products" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
2 "active": true,
3 "order": 10,
4 "code": "GLP-2024-001",
5 "title": "Gaming Laptop Pro",
6 "slug": "gaming-laptop-pro",
7 "stock_type": "limited",
8 "stock": 50,
9 "regular_price": 180000,
10 "sale_price": 155000,
11 "price_note": "one time offer",
12 "excerpt": "High-performance gaming laptop with RTX graphics",
13 "image": 342,
14 "brand": 1,
15 "categories": [5, 11],
16 "description": "Ultimate gaming experience with latest processor and graphics card..."
17 }'Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the product |
| active | Boolean | Whether the product is active |
| order | Integer | Row-order priority (nullable) |
| code | String | Product code/SKU (unique, nullable) |
| title | String | Product title |
| slug | String | URL-friendly product identifier (unique) |
| stock_type | String | Stock management type |
| stock | Integer | Available stock quantity |
| in_stock | Boolean | Whether the product is in stock (computed) |
| regular_price | Decimal | Original price of the product |
| sale_price | Decimal | Sale price (if on sale) |
| discount | Decimal | Discount amount (computed) |
| discount_percent | Decimal | Discount percentage (computed) |
| price | Decimal | Final price after discount (computed) |
| price_notes | String | Additional pricing notes |
| excerpt | String | Short product description |
| comments_count | Integer | Number of comments (computed) |
| rating | Decimal | Average product rating (computed) |
| image_data | Object | Image details |
| created_at | String (ISO 8601) | Timestamp when product was created |
| updated_at | String (ISO 8601) | Timestamp when product was last updated |
| brand_data | Object | The product brand data |
| categories_data | List[Object] | The product categories list |
| description | String | Additional descriptions of the product |
| meta | List[Object] | List of meta data on the product |
Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the image |
| type | String | File type (e.g., image/jpeg) |
| name | String | Original file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Color mode (e.g., RGB, CMYK) |
| thumbnails | List of thumbnail objects | Imgae thumbnails |
Thumbnail Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the thumbnail (unique) |
| f | String | URL to access the thumbnail file |
| size | Integer | File size in bytes (nullable) |
Brand Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the brand |
| name | String | Name of the brand |
Categories Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the category |
| name | String | Name of the category |
Meta Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the meta data |
| key | String | The key name of the meta data |
| value_text | String | The text value of the meta data |
| value_file | Object | The file value of the meta data |
Meta value_file data structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the file |
| type | String | The type of the file |
| name | String | The name of the file |
| size | Integer | The size of the file in bytes |
| human_readable_size | String | The human-readable size of the file |
| f | String | The 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,ratingare computed fields