Create order
Create an order (stock is taken, totals are computed by the store)
https://s.zo.sa/api/public/v1 /orders orders.read_writeIdempotency-Key requiredThe Idempotency-Key header is required here (422 validation_failed without it): a retry with the same key returns the first answer and never creates a second order. A customer object (name and mobile) finds the store's customer by that mobile, so it needs customers.read: without it the call is refused with 422 customers_scope_required (on fields.customer.mobile), whether or not the store has that number; a customer_id works with orders.read_write alone. The answer follows the same contact rule as the reads: without customers.read the order names its customer by id and name only. History records the creation with actor api.
Request
Headers
| Name | Type | Required | Description |
|---|---|---|---|
Idempotency-Key | string | required | 1 to 120 visible ASCII characters. A write sent again with the same key runs once; the retry gets the first answer back with the header Idempotent-Replayed: true. Use a new key for each new write. 1 to 120 characters |
Request body
An order the store took outside the storefront. Send customer_id (one of this store's customers) or customer, not both. Totals, VAT, status and payment status are worked out by the store and never read from the body (a total, subtotal, vat, status or payment_status sent is ignored). Stock is taken for each tracked item. The new order's source is api.
One of customer_id or customer is required, not both.
customer_idintegerone ofAn existing customer of this store (GET /customers). Their name, mobile and email are used.customerobjectone ofA new or returning shopper, matched by mobile: a known mobile is that customer, and their stored name and email are kept (the ones sent are used only for a new customer). Needs customers.read (422 customers_scope_required).3 fields
namestringrequiredmobilestringrequiredA Saudi mobile in any common form (05..., 9665..., +9665...).emailstring (email)nullable
itemsarray of objectsrequired4 fields
One of
skuorvariant_idis required; with both, they must name the same variant.skustringone ofThe variant's exact SKU. Either sku or variant_id is required; with both, the variant must match both.variant_idintegerone ofquantityintegerrequiredunit_priceintegernullableHalalas. Left out: the variant's current price (its sale price while the sale runs).
payment_methodstringrequiredcod: paid on delivery. bank_transfer: the order waits in awaiting_payment until the merchant confirms the transfer. manual: already paid (payment_status paid). Online card payment is not available here.shipping_method_idintegernullableOne of the store's shipping methods; its fee applies unless shipping_fee is sent.shipping_feeintegernullableHalalas.discountintegernullableHalalas, at most the subtotal.addressobjectnullable4 fields
citystringnullabledistrictstringnullablestreetstringnullabledetailsstringnullable
customer_notestringnullableThe shopper's note, shown on the order (customer_note).
cURL
curl -sS -X POST "https://s.zo.sa/api/public/v1/orders" \
-H "Authorization: Bearer $ZO_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: erp-order-SO1042" \
-d '{
"customer_id": 2187,
"items": [
{
"sku": "TSHIRT-BLUE-M",
"quantity": 2
}
],
"payment_method": "cod"
}'JavaScript
const response = await fetch('https://s.zo.sa/api/public/v1/orders', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ZO_API_KEY}`,
Accept: 'application/json',
'Content-Type': 'application/json',
'Idempotency-Key': 'erp-order-SO1042',
},
body: JSON.stringify({
"customer_id": 2187,
"items": [
{
"sku": "TSHIRT-BLUE-M",
"quantity": 2
}
],
"payment_method": "cod"
}),
});
console.log(response.status, await response.json());PHP
<?php
$ch = curl_init('https://s.zo.sa/api/public/v1/orders');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ZO_API_KEY'),
'Accept: application/json',
'Content-Type: application/json',
'Idempotency-Key: erp-order-SO1042',
],
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => 2187,
'items' => [
[
'sku' => 'TSHIRT-BLUE-M',
'quantity' => 2,
],
],
'payment_method' => 'cod',
]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status, PHP_EOL, $body, PHP_EOL;Python
import os
import requests
response = requests.post(
"https://s.zo.sa/api/public/v1/orders",
headers={
"Authorization": f"Bearer {os.environ['ZO_API_KEY']}",
"Accept": "application/json",
"Idempotency-Key": "erp-order-SO1042",
},
json={
"customer_id": 2187,
"items": [
{
"sku": "TSHIRT-BLUE-M",
"quantity": 2,
},
],
"payment_method": "cod",
},
timeout=30,
)
print(response.status_code, response.json())An order for an existing customer, by id: this needs orders.read_write only. The store works out the totals and VAT and takes the stock.
{
"data": {
"id": 1043,
"number": "1043",
"status": "under_review",
"payment_status": "pending",
"payment_method": "cod",
"source": "api",
"currency": "SAR",
"totals": {
"subtotal": 5000,
"discount": 0,
"shipping": 0,
"tax": 652,
"total": 5000
},
"customer": {
"id": 2187,
"name": "Sara Ahmed"
},
"items": [
{
"id": 3302,
"product_id": 501,
"variant_id": 811,
"sku": "TSHIRT-BLUE-M",
"name": {
"ar": "...",
"en": "Blue T-shirt"
},
"quantity": 2,
"unit_price": 2500,
"total": 5000,
"options": null
}
],
"created_at": "2026-11-23T08:30:00Z",
"updated_at": "2026-11-23T08:30:00Z"
}
}Example. The answer for a key without customers.read: the customer is {id, name}, and shipping_address and customer_note are absent. tax is the VAT already inside total.
Responses
Response schema
dataobjectrequiredAn order. shipping_address is present only with the customers.read scope (null for an order with nothing to ship) and so is customer_note; without that scope both keys are absent. Card codes, gift links, file paths and merchant notes are never shown.14 fields
idintegerrequirednumberstringrequiredThe order number the merchant and the shopper see.statusstringrequiredpayment_statusstringrequiredpayment_methodstringrequiredsourcestringrequirednullableWhere the order came from: storefront, manual (typed in the dashboard), api (created through this API), or a marketplace (trendyol, amazon).currencystringrequiredtotalsobjectrequiredHalalas. shipping includes the cash-on-delivery fee; tax is the VAT already included in total. total may also hold paid order options.5 fields
subtotalintegerrequireddiscountintegerrequiredshippingintegerrequiredtaxintegerrequiredtotalintegerrequired
customerobjectrequiredWho placed the order. Without the customers.read scope only id and name are present; with it, mobile and email are added.4 fields
idintegerrequirednullableThe customer record (GET /customers/{id}).namestringrequirednullablemobilestringnullablePresent only with customers.read. E.164 for Saudi numbers.emailstringnullablePresent only with customers.read.
customer_notestringnullableWhat the shopper wrote with the order. Present only with customers.read (free text that may hold contact details).shipping_addressobjectnullable9 fields
namestringrequirednullableThe recipient (the customer unless the address names someone else).mobilestringrequirednullablecountrystringrequiredISO 3166-1 alpha-2; SA unless the address says otherwise.citystringrequirednullableThe city's name as the shopper reads it.districtstringrequirednullablestreetstringrequirednullablebuildingstringrequirednullablepostal_codestringrequirednullabledetailsstringrequirednullableAddress details the shopper typed (landmark, floor and so on).
itemsarray of objectsrequired9 fields
idintegerrequiredproduct_idintegerrequirednullableNull when the line is not tied to a product.variant_idintegerrequirednullableskustringrequirednullablenameobjectrequired2 fields
arstringrequirednullableenstringrequirednullable
quantityintegerrequiredunit_priceintegerrequiredHalalas.totalintegerrequiredHalalas.optionsobjectrequirednullableThe chosen option values as one text (for example "Red / L"); null for a product without options.2 fields
arstringrequirednullableenstringrequirednullable
created_atstring (date-time)requiredWhen the order was placed.updated_atstring (date-time)required
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.