Sifr Wahid Developers

API reference / Orders

Create order

Create an order (stock is taken, totals are computed by the store)

POST https://s.zo.sa/api/public/v1/orders
Scope orders.read_writeIdempotency-Key required

The 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

NameTypeRequiredDescription
Idempotency-Keystringrequired1 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

application/json required

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 of
    An existing customer of this store (GET /customers). Their name, mobile and email are used.
  • customerobjectone of
    A 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
    • namestringrequired
      Up to 100 characters
    • mobilestringrequired
      A Saudi mobile in any common form (05..., 9665..., +9665...).
      Up to 20 characters
    • emailstring (email)nullable
      Up to 190 characters
  • itemsarray of objectsrequired
    1 to 50 items
    4 fields

    One of sku or variant_id is required; with both, they must name the same variant.

    • skustringone of
      The variant's exact SKU. Either sku or variant_id is required; with both, the variant must match both.
      Up to 64 characters
    • variant_idintegerone of
    • quantityintegerrequired
      1 to 999
    • unit_priceintegernullable
      Halalas. Left out: the variant's current price (its sale price while the sale runs).
      0 to 99999999
  • payment_methodstringrequired
    cod: 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.
    One of cod, bank_transfer, manual
  • shipping_method_idintegernullable
    One of the store's shipping methods; its fee applies unless shipping_fee is sent.
  • shipping_feeintegernullable
    Halalas.
    0 to 9999999
  • discountintegernullable
    Halalas, at most the subtotal.
    0 to 99999999
  • addressobjectnullable
    4 fields
    • citystringnullable
      Up to 80 characters
    • districtstringnullable
      Up to 80 characters
    • streetstringnullable
      Up to 190 characters
    • detailsstringnullable
      Up to 190 characters
  • customer_notestringnullable
    The shopper's note, shown on the order (customer_note).
    Up to 500 characters

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.

Response 201
{
  "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

201The new order.
Response schema
  • dataobjectrequired
    An 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
    • idintegerrequired
    • numberstringrequired
      The order number the merchant and the shopper see.
    • statusstringrequired
      One of awaiting_payment, under_review, in_progress, ready, shipping, delivered, completed, cancelled, return_in_progress, returned
    • payment_statusstringrequired
      One of pending, paid, refund_due, refunded
    • payment_methodstringrequired
      One of cod, bank_transfer, online, manual
    • sourcestringrequirednullable
      Where the order came from: storefront, manual (typed in the dashboard), api (created through this API), or a marketplace (trendyol, amazon).
    • currencystringrequired
      Examples SAR
    • totalsobjectrequired
      Halalas. shipping includes the cash-on-delivery fee; tax is the VAT already included in total. total may also hold paid order options.
      5 fields
      • subtotalintegerrequired
      • discountintegerrequired
      • shippingintegerrequired
      • taxintegerrequired
      • totalintegerrequired
    • customerobjectrequired
      Who placed the order. Without the customers.read scope only id and name are present; with it, mobile and email are added.
      4 fields
      • idintegerrequirednullable
        The customer record (GET /customers/{id}).
      • namestringrequirednullable
      • mobilestringnullable
        Present only with customers.read. E.164 for Saudi numbers.
      • emailstringnullable
        Present only with customers.read.
    • customer_notestringnullable
      What the shopper wrote with the order. Present only with customers.read (free text that may hold contact details).
    • shipping_addressobjectnullable
      9 fields
      • namestringrequirednullable
        The recipient (the customer unless the address names someone else).
      • mobilestringrequirednullable
      • countrystringrequired
        ISO 3166-1 alpha-2; SA unless the address says otherwise.
      • citystringrequirednullable
        The city's name as the shopper reads it.
      • districtstringrequirednullable
      • streetstringrequirednullable
      • buildingstringrequirednullable
      • postal_codestringrequirednullable
      • detailsstringrequirednullable
        Address details the shopper typed (landmark, floor and so on).
    • itemsarray of objectsrequired
      9 fields
      • idintegerrequired
      • product_idintegerrequirednullable
        Null when the line is not tied to a product.
      • variant_idintegerrequirednullable
      • skustringrequirednullable
      • nameobjectrequired
        2 fields
        • arstringrequirednullable
        • enstringrequirednullable
      • quantityintegerrequired
      • unit_priceintegerrequired
        Halalas.
      • totalintegerrequired
        Halalas.
      • optionsobjectrequirednullable
        The chosen option values as one text (for example "Red / L"); null for a product without options.
        2 fields
        • arstringrequirednullable
        • enstringrequirednullable
    • created_atstring (date-time)required
      When the order was placed.
    • updated_atstring (date-time)required
401Missing, unknown, revoked or expired key.

An error object: {"error": {"code", "message", "fields"}}.

402The store's plan does not include this feature (error code feature_locked, with the feature and the plan that has it). Every operation answers it with feature public_api when the key's store is not on the Pro plan.

An error object: {"error": {"code", "message", "fields"}}.

403The key lacks the scope (code insufficient_scope, naming it in scope), the caller's address is not allowed (ip_not_allowed), or the store is suspended (store_suspended: reads stay allowed, every write answers this).

An error object: {"error": {"code", "message", "fields"}}.

409out_of_stock (items lists the indexes of the items there is not enough stock for; nothing was created), or duplicate_request (the same Idempotency-Key is still running).

An error object: {"error": {"code", "message", "fields"}}.

422validation_failed (fields names the input, such as items.0.sku for a SKU this store does not have, items.0.variant_id, customer_id or customer.mobile). Nothing was created.

An error object: {"error": {"code", "message", "fields"}}.

429Too many requests (code rate_limited); see Retry-After.

An error object: {"error": {"code", "message", "fields"}}.