Skip to main content

Create Order

Create a new order.

HTTP Request

POST/api/orders/
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 OrderPermission or Admin
  • Permission Code: 2201
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Request Body

FieldTypeRequiredDescription
statusStringNoOrder status (`new`, `hold`, `failed`, `cancelled`, `processing`, `shipped`, `completed`, `refunded`, default=`new`)
customerIntegerNoCustomer ID
payment_methodIntegerNoPayment method ID
shipping_methodIntegerNoShipping method ID
shipping_costNumberNoCost of shipping
notesStringNoOrder notes
extraJsonFieldNoAdditional order data
billing_countryIntegerNoBilling country ID
billing_stateIntegerNoBilling state ID
billing_cityIntegerNoBilling city ID
billing_addressStringNoBilling address
billing_postal_codeStringNoBilling postal code
billing_national_codeStringNoBilling national code
billing_mobile_numberStringNoBilling mobile number
billing_first_nameStringNoBilling first name
billing_last_nameStringNoBilling last name

Example Requests

1import requests
2
3# Create a new order
4response = requests.post('http://www.example.com/api/orders', 
5  json={
6      'status': 'new',
7      'customer': 123,
8      'payment_method': 1,
9      'shipping_method': 2,
10      'shipping_cost': 75000,
11      'notes': 'Urgent delivery required',
12      'billing_first_name': 'John',
13      'billing_last_name': 'Doe',
14      'billing_address': '123 Main St',
15      'billing_mobile_number': '+1234567890'
16  },
17  headers={'Authorization': 'Token <your_api_key>'}
18)
19print(response.json())
20
21# Create minimal order
22response = requests.post('http://www.example.com/api/orders', 
23  json={
24      'customer': 456,
25      'notes': 'Standard order'
26  },
27  headers={'Authorization': 'Token <your_api_key>'}
28)
29print(response.json())

Response Fields

FieldTypeDescription
idIntegerUnique ID of the order
keyStringUnique key of the order (unique)
statusStringCurrent status of the order(choices)
customer_dataObjectCustomer information (nullable)
payment_method_dataObjectPayment method information (nullable)
shipping_method_dataObjectShipping method information (nullable)
shipping_costNumberCost of shipping (default=0)
notesStringOrder notes (nullable)
extraJsonFieldAdditional order data
created_atString (ISO 8601)Timestamp when order was created
updated_atString (ISO 8601)Timestamp when order was last updated
billing_country_dataObjectBilling country information (nullable)
billing_state_dataObjectBilling state information (nullable)
billing_city_dataObjectBilling city information (nullable)
billing_addressStringBilling address (nullable)
billing_postal_codeStringBilling postal code (nullable)
billing_national_codeStringBilling national code (nullable)
billing_mobile_numberStringBilling mobile number (nullable, valid iranian mobile number)
billing_first_nameStringBilling first name (nullable)
billing_last_nameStringBilling last name (nullable)
countIntegerNumber of items in order (computed field)
quantityIntegerTotal quantity of items (computed field)
items_subtotalNumberSubtotal of all items (computed field)
items_discountNumberTotal discount on items (computed field)
subtotalNumberOrder subtotal (computed field)
total_discountNumberTotal discount amount (computed field)
totalNumberOrder total amount (computed field)
amount_paidNumberAmount already paid (computed field)
amount_outstandingNumberOutstanding amount (computed field)
is_paidBooleanWhether order is fully paid (computed field)
itemsArrayList of order items (read-only)
paymentsArrayList of order payments (read-only)

Customer Structure

The customer object contains:

FieldTypeDescription
idIntegerCustomer ID
usernameStringCustomer username
mobile_numberStringCustomer mobile number
first_nameStringCustomer first name
last_nameStringCustomer last name
full_nameStringCustomer full name (computed)

Payment Method Structure

The payment_method object contains:

FieldTypeDescription
idIntegerPayment method ID
nameStringPayment method name
imageObjectPayment method image data

Shipping Method Structure

The shipping_method object contains:

FieldTypeDescription
idIntegerShipping method ID
nameStringShipping method name
imageObjectShipping method image data

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)

Geographic Data Structures

Country, state, and city objects contain:

Country/State:

FieldTypeDescription
idIntegerLocation ID
nameStringLocation name
codeStringLocation code

City:

FieldTypeDescription
idIntegerCity ID
nameStringCity name

Order Items Structure

Each item in the items array contains:

FieldTypeDescription
idIntegerUnique ID of the order item
productIntegerUnique ID of the product
product_nameStringCurrent Product Name
product_dataJsonFieldSnapshot of product data at time of order
unit_priceIntegerPrice per unit (in smallest currency unit)
unit_discountIntegerDiscount per unit (in smallest currency unit)
quantityIntegerQuantity ordered
notesStringItem-specific notes
subtotalIntegerCalculated subtotal (computed field)
discountIntegerTotal discount for this item (computed field)
totalIntegerFinal total for this item (computed field)
created_atString (ISO 8601)Item creation timestamp
updated_atString (ISO 8601)Item last update timestamp

Order Payment Structure

Each item in the payments array contains:

  • The shipping method structure here is the same as the above-mentioned ShippingMethod Structure.
FieldTypeDescription
idIntegerId of the order payment
payment_method_dataObjectPayment method data of the order payment
approvedBooleanWhether the order payment is approved
amountIntegerThe order payment amount
transaction_idStringThe transaction id of the order payment
notesStringThe extra notes about the order payment
created_atString (ISO 8601)The creation datetime of the order payment
updated_atString (ISO 8601)The last updated datetime of the order payment

Example Response

{
"id": 2,
"key": "0c86ab758d3e236cb5a4",
"status": "new",
"customer_data": {
"id": 1,
"username": "BehroozGhorbani",
"mobile_number": "09308744204",
"first_name": "بهروز",
"last_name": "قربانی",
"full_name": "بهروز قربانی"
},
"payment_method_data": {
"id": 1,
"name": "پرداخت در مخل",
"image": null
},
"shipping_method_data": {
"id": 1,
"name": "پیک موتور",
"image": {
"id": 8,
"type": "image",
"name": "پیک موتوری",
"size": 808754,
"human_readable_size": "789.80 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/12/20/Fantasticheskie_kartinki_dlja_monitora_68_63.jpg",
"width": 1920,
"height": 1080,
"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
}
]
}
},
"shipping_cost": 75000,
"notes": "Facilis sequi alias optio. Alias ipsam deserunt. At veniam nam et. Et aut id id aut quae non animi. Sed tempora aut ut ipsa dicta vel eveniet et aspernatur.",
"extra": {
"some": "data"
},
"created_at": "2025-12-27T18:17:09.771123Z",
"updated_at": "2025-12-27T18:17:09.771131Z",
"billing_country_data": {
"id": 1,
"name": "ایران",
"code": "IR"
},
"billing_state_data": {
"id": 1,
"name": "آذربایجان شرقی",
"code": "EA"
},
"billing_city_data": {
"id": 1,
"name": "اسکو"
},
"billing_address": "5411 Stokes Grove",
"billing_postal_code": "1234567890",
"billing_national_code": null,
"billing_mobile_number": "09523296536",
"billing_first_name": "پدرام",
"billing_last_name": "زمانی",
"count": 0,
"quantity": 0,
"items_subtotal": 0,
"items_discount": 0,
"subtotal": 0,
"total_discount": 0,
"total": 75000,
"amount_paid": 0,
"amount_outstanding": 75000,
"is_paid": false,
"is_payable": false,
"items": [],
"payments": []
}

Notes

    • The status field can be set to new, hold, failed, cancelled, or deleted when creating an order.
    • The status field cannot be set to processing, completed, or refunded and shipped during order creation; these statuses are reserved for later stages in the order lifecycle.