Skip to main content

Update Order

Update an existing order.

HTTP Request

PATCH/api/orders/:id

Authorization

Authorization

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

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the order to update

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

Status Options

We have some rules to transition between statuses. Look at the table below:

From \ Tonewholdfailedcancelledprocessingshippedcompletedrefundeddeleted
new
hold
failed
cancelled
processing
shipped
completed
refunded

Transition Rules Diagram

Order Status Transition Diagram

Example Requests

1import requests
2
3# Partial update (PATCH)
4response = requests.patch('http://www.example.com/api/orders/123', 
5  json={
6      'status': 'hold',
7      'notes': 'Updated delivery instructions',
8      'shipping_cost': 20.00
9  },
10  headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())
13
14# Update billing information
15response = requests.patch('http://www.example.com/api/orders/123', 
16  json={
17      'billing_first_name': 'Jane',
18      'billing_last_name': 'Smith',
19      'billing_address': '456 Oak Avenue'
20  },
21  headers={'Authorization': 'Token <your_api_key>'}
22)
23print(response.json())

Status Codes

CodeDescription
200Product updated successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Not found — product does not exist
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