Skip to main content

Create Order

Create a new order.

HTTP Request

POST/api/orders

Authorization

Authorization

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

Request Body

FieldTypeRequiredDescription
statusStringNoOrder status (`new`, `hold`, `failed`, `cancelled`, `deleted`)
customerIntegerNoCustomer ID
payment_methodIntegerNoPayment method ID
shipping_methodIntegerNoShipping method ID
shipping_costNumberNoCost of shipping
notesStringNoOrder notes
extraObjectNoAdditional 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': 'pending',
7      'customer': 123,
8      'payment_method': 1,
9      'shipping_method': 2,
10      'shipping_cost': 15.00,
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())

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 order
keyStringUnique key of the order (read-only)
statusStringCurrent status of the order
customer_dataObjectCustomer information (read-only)
payment_method_dataObjectPayment method information (read-only)
shipping_method_dataObjectShipping method information (read-only)
shipping_costNumberCost of shipping
notesStringOrder notes
extraObjectAdditional 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 (read-only)
billing_state_dataObjectBilling state information (read-only)
billing_city_dataObjectBilling city information (read-only)
billing_addressStringBilling address
billing_postal_codeStringBilling postal code
billing_national_codeStringBilling national code
billing_mobile_numberStringBilling mobile number
billing_first_nameStringBilling first name
billing_last_nameStringBilling last name
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)

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_dataObjectSnapshot 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

Payment Method Structure

The payment_method object contains:

FieldTypeDescription
idIntegerPayment method ID
nameStringPayment method name
imageObjectPayment method image data

Customer Structure

The customer object contains:

FieldTypeDescription
idIntegerCustomer ID
usernameStringCustomer username
full_nameStringCustomer full name (computed)

Geographic Data Structures

Country, state, and city objects contain:

Country/State:

FieldTypeDescription
idIntegerLocation ID
activeBooleanWhether location is active
nameStringLocation name
codeStringLocation code

City:

FieldTypeDescription
idIntegerCity ID
activeBooleanWhether city is active
nameStringCity name

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.