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
| Field | Type | Required | Description |
|---|---|---|---|
| status | String | No | Order status (`new`, `hold`, `failed`, `cancelled`, `deleted`) |
| customer | Integer | No | Customer ID |
| payment_method | Integer | No | Payment method ID |
| shipping_method | Integer | No | Shipping method ID |
| shipping_cost | Number | No | Cost of shipping |
| notes | String | No | Order notes |
| extra | Object | No | Additional order data |
| billing_country | Integer | No | Billing country ID |
| billing_state | Integer | No | Billing state ID |
| billing_city | Integer | No | Billing city ID |
| billing_address | String | No | Billing address |
| billing_postal_code | String | No | Billing postal code |
| billing_national_code | String | No | Billing national code |
| billing_mobile_number | String | No | Billing mobile number |
| billing_first_name | String | No | Billing first name |
| billing_last_name | String | No | Billing last name |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1# Create a new order
2curl -X POST "http://www.example.com/api/orders" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
3 "status": "pending",
4 "customer": 123,
5 "payment_method": 1,
6 "shipping_method": 2,
7 "shipping_cost": 15.00,
8 "notes": "Urgent delivery required",
9 "billing_first_name": "John",
10 "billing_last_name": "Doe",
11 "billing_address": "123 Main St",
12 "billing_mobile_number": "+1234567890"
13}'
14
15# Create minimal order
16curl -X POST "http://www.example.com/api/orders" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
17 "customer": 456,
18 "notes": "Standard order"
19}'Status Codes
| Code | Description |
|---|---|
| 201 | Product created successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the order |
| key | String | Unique key of the order (read-only) |
| status | String | Current status of the order |
| customer_data | Object | Customer information (read-only) |
| payment_method_data | Object | Payment method information (read-only) |
| shipping_method_data | Object | Shipping method information (read-only) |
| shipping_cost | Number | Cost of shipping |
| notes | String | Order notes |
| extra | Object | Additional order data |
| created_at | String (ISO 8601) | Timestamp when order was created |
| updated_at | String (ISO 8601) | Timestamp when order was last updated |
| billing_country_data | Object | Billing country information (read-only) |
| billing_state_data | Object | Billing state information (read-only) |
| billing_city_data | Object | Billing city information (read-only) |
| billing_address | String | Billing address |
| billing_postal_code | String | Billing postal code |
| billing_national_code | String | Billing national code |
| billing_mobile_number | String | Billing mobile number |
| billing_first_name | String | Billing first name |
| billing_last_name | String | Billing last name |
| count | Integer | Number of items in order (computed field) |
| quantity | Integer | Total quantity of items (computed field) |
| items_subtotal | Number | Subtotal of all items (computed field) |
| items_discount | Number | Total discount on items (computed field) |
| subtotal | Number | Order subtotal (computed field) |
| total_discount | Number | Total discount amount (computed field) |
| total | Number | Order total amount (computed field) |
| amount_paid | Number | Amount already paid (computed field) |
| amount_outstanding | Number | Outstanding amount (computed field) |
| is_paid | Boolean | Whether order is fully paid (computed field) |
| items | Array | List of order items (read-only) |
| payments | Array | List of order payments (read-only) |
Order Items Structure
Each item in the items array contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the order item |
| product | Integer | Unique ID of the product |
| product_name | String | Current Product Name |
| product_data | Object | Snapshot of product data at time of order |
| unit_price | Integer | Price per unit (in smallest currency unit) |
| unit_discount | Integer | Discount per unit (in smallest currency unit) |
| quantity | Integer | Quantity ordered |
| notes | String | Item-specific notes |
| subtotal | Integer | Calculated subtotal (computed field) |
| discount | Integer | Total discount for this item (computed field) |
| total | Integer | Final total for this item (computed field) |
| created_at | String (ISO 8601) | Item creation timestamp |
| updated_at | String (ISO 8601) | Item last update timestamp |
Payment Method Structure
The payment_method object contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Payment method ID |
| name | String | Payment method name |
| image | Object | Payment method image data |
Customer Structure
The customer object contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Customer ID |
| username | String | Customer username |
| full_name | String | Customer full name (computed) |
Geographic Data Structures
Country, state, and city objects contain:
Country/State:
| Field | Type | Description |
|---|---|---|
| id | Integer | Location ID |
| active | Boolean | Whether location is active |
| name | String | Location name |
| code | String | Location code |
City:
| Field | Type | Description |
|---|---|---|
| id | Integer | City ID |
| active | Boolean | Whether city is active |
| name | String | City name |
Notes
- The
statusfield can be set tonew,hold,failed,cancelled, ordeletedwhen creating an order. - The
statusfield cannot be set toprocessing,completed, orrefundedandshippedduring order creation; these statuses are reserved for later stages in the order lifecycle.