Home / Developers / API guide

Public API guide

A practical guide for a developer connecting an ERP, Odoo, an accounting or an inventory system to a store on Sifr Wahid (Zero One), in the order you will need it.

1. Getting a key

Who creates it: the store owner only, in the dashboard, and never from a support session.

Labels below are the dashboard's English labels. Switch the dashboard language to English to see them.

  1. All → Developer tools → API keys (/settings/api-keys) → New key.
  2. Name: the system that will use it, such as "Odoo main warehouse". One key per system, so you know who did what and can revoke one without the others.
  3. Scopes: for each resource None, Read or Read and write. Pick the fewest. For an ERP, usually:
    • Products, inventory, orders and webhooks: read and write.
    • Store: read.
    • Customers: read only when you need the customer's mobile, email and address on orders, or create orders for a customer by mobile. Without it an order's customer is {id, name} only, and a customer object with a mobile is answered 422 customers_scope_required.
    • Sensitive scopes (customers, and payments and shipments read and write, which move money) show a warning. The full table is under scopes.
  4. IP addresses (optional, recommended): up to 20 addresses or ranges (IPv4 or IPv6, such as 203.0.113.7 or 203.0.113.0/24). A call from any other address is answered 403 ip_not_allowed.
  5. Expiry (optional): the key stops at the end of that day, Riyadh time.
  6. Next, then Send verification code: a 4-digit code goes to the owner's verified mobile. Type it, then Create.
  7. The key (zo_live_…) is shown once. Copy it now and press Done, I saved it. The list then shows only its prefix and its last use.

Limits: a store holds at most 20 live keys. The owner may ask for a code 10 times and create 20 keys every 10 minutes, and the codes for one mobile are capped (5 an hour and 10 a day by default).

Keeping it safe

2. The first call

Shell
export ZO_API_KEY='zo_live_...'
curl -sS https://s.zo.sa/api/public/v1/store \
  -H "Authorization: Bearer $ZO_API_KEY" \
  -H "Accept: application/json" -i

The answer is 200 with the rate headers:

HTTP
HTTP/1.1 200 OK
X-RateLimit-Limit: 360
X-RateLimit-Remaining: 359
X-RateLimit-Reset: 1795421160
Content-Type: application/json

{"data":{"id":3,"name":{"ar":"...","en":"My store"},"slug":"my-store","url":"https://s.zo.sa/my-store","currency":"SAR","language":"ar","status":"live","created_at":"2026-11-23T06:01:53.000000Z"}}

3. Authentication and scopes

ScopeWhat it unlocks
store.readThe store's data (GET /store)
products.read / products.read_writeProducts, categories and brands: read, then create, update and delete
inventory.read / inventory.read_writeStock per branch, its movements and the branches, then adjusting quantities
orders.read / orders.read_writeOrders, their history and the statuses, then creating an order and changing its status
customers.read / customers.read_writeCustomers, and contact data everywhere, then adding and updating a customer
carts.read / carts.read_writeAbandoned carts (needs the abandoned_carts feature); no write endpoint in v1
marketing.read / marketing.read_writeCoupons: read, then create, update and delete
shipments.read / shipments.read_writeShipments, then shipping an order and cancelling a shipment
payments.read / payments.read_writeAn order's payments and the payment methods; no write endpoint in v1
reviews.read / reviews.read_writeReviews, then the store's reply
webhooks.read / webhooks.read_writeThe key's own webhooks (section 10)

Customer data: without customers.read, contact data is taken out of every answer and every webhook: an order's customer is {id, name} with no mobile, email or shipping address, customer_note is absent (free text that may hold a number), an abandoned cart's customer is {id, name} with no customer.mobile or customer.email (in the cart webhook payload the field is customer_mobile, dropped the same way).

Sensitive scopes: customers.read, customers.read_write (shoppers' data), payments.read_write and shipments.read_write (they move money: a carrier label is paid from the store wallet). The dashboard warns when one is picked.

4. Errors

Every error has the same shape. code is stable for your program, message is for people, and fields appears only on errors about inputs:

JSON
{ "error": { "code": "validation_failed", "message": "…", "fields": { "variants.0.sku": ["…"] } } }

The codes an integration meets:

CodeStatusWhat to do
unauthenticated401No Authorization header. Add it.
invalid_token401Wrong, revoked or expired key. Ask the owner for a new key; do not retry.
feature_locked402The store is not on Pro (feature: public_api), or another feature is missing (webhooks, abandoned_carts).
ip_not_allowed403Your server is not in the key's address list.
insufficient_scope403The key lacks the route's scope; scope names it.
store_suspended403The store is suspended: reads work, writes are refused.
not_found404No row with that id or SKU in this store.
validation_failed422Invalid input; fields names each field by its path in the body.
customers_scope_required422An order for a customer by mobile without customers.read; send customer_id or add the scope.
invalid_transition422A status move that is not allowed; from and to.
idempotency_key_reused422An Idempotency-Key used with a different body.
duplicate_request409The same call with the same key is still running; retry in a moment.
out_of_stock409Not enough stock for the order's lines; items lists them.
insufficient_stock409A decrement below zero; available holds what is on hand.
customer_exists409The store has a customer with that mobile; customer_id names it.
rate_limited429Past the per-minute limit; wait Retry-After.
images_queue_full42950 picture links wait to be copied in the store; wait Retry-After.

Less frequent codes: wallet_insufficient (402, wallet too low for a label), plan_limit (422, plan limit reached, such as the number of webhooks), stock_managed_by_codes (422, a digital card product's stock is its unsold codes and cannot be adjusted through inventory/adjustments) and too_many_variants (422, the options make more variants than a product may have).

5. Limits and retries

6. Lists and sync

7. Idempotency on writes

8. Syncing products and stock from an ERP

The SKU is the link. Give every variant in the store the SKU your system uses.

  1. First load: read GET /products?per_page=100 page by page, passing meta.next_cursor as cursor until it is null, and keep each product and variant id against its SKU.
  2. Upsert each item:
    • GET /products/sku/{sku}. A 404 means a new item: POST /products with the name and the variants (each with sku and price in halalas), weight_grams when it ships, and status: active to show it.
    • When found: PATCH /products/sku/{sku} with only the fields that changed (keys you do not send stay).
    • Never send a quantity on a product: any quantity key is answered 422. Stock has its own path.
    • A product with sizes or colours: options with their values, and each variant's values holds one value key of every option.
  3. Pictures: send public links in images (or POST /products/{id}/images with {url}). They are copied in the background: the answer lists the link in images_pending with status pending (and 202 for one picture), then it joins images and product.updated is sent. When the copy fails it turns failed with image_unreachable, too_many_images or copy_failed. A product has 10 pictures, and a store has at most 50 links waiting at once (beyond that, 429 images_queue_full with Retry-After). A copy job downloads for 60 seconds at most, so with many slow links some may end copy_failed: send them again in a new write.
  4. Stock by delta:
    • Read the level: GET /inventory?sku={sku} (or variant_id), per branch. Branch ids come from GET /branches.
    • Each movement in your system: POST /inventory/adjustments with {"items":[{"sku":"…","mode":"increment","quantity":5}]} or decrement, up to 100 lines a call, applied all or nothing, with an Idempotency-Key from the movement number. Without branch_id it goes to the default branch.
    • mode: set makes the level an exact number: for a stock count only, because it erases what the store sold between your read and your write.
    • A decrement below zero: 409 insufficient_stock with available, and nothing is applied.
  5. The merchant's own changes: subscribe to product.updated, product.created and product.deleted to mirror them in your system.

9. Syncing orders into an ERP

  1. Events: subscribe to order.created and order.status.updated (section 10). On each delivery: verify the signature, drop duplicates by X-Zo-Delivery, answer 2xx at once, then do the work in the background.
  2. Details: GET /orders/{id} with the id in the event (data.id): lines, amounts in halalas, status and payment method. The customer's contact data and address appear only with customers.read.
  3. Polling fallback: every hour, GET /orders?updated_since={the largest updated_at you kept}&per_page=100 and follow next_cursor. The filter is inclusive, so the last second is read again: store by id (upsert). This catches any event you missed.
  4. Status from your system to the store:
    • GET /order-statuses gives, for each status, the statuses an order may move to (next).
    • POST /orders/{id}/status with {"status":"ready","note":"…"}. A move that is not allowed: 422 invalid_transition.
    • Shipping with your own carrier's tracking number: POST /orders/{id}/shipments with {"tracking_number":"…","carrier_name":"…"} and an Idempotency-Key. The order moves to shipping.
  5. An order from your system (phone, point of sale): POST /orders with an Idempotency-Key, items by sku, a customer_id of an existing customer or a customer with name and mobile (needs customers.read; an existing customer keeps their stored name and email), and payment_method cod, bank_transfer or manual. The store works out the totals and VAT and takes the stock (409 out_of_stock when short).

10. Webhooks

Setup

Create the webhook in the dashboard under Developer tools → Webhooks, or through the API:

Shell
curl -sS https://s.zo.sa/api/public/v1/webhooks -H "Authorization: Bearer $ZO_API_KEY" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -d '{"name":"ERP orders","event":"order.created","url":"https://erp.example.com/zo/hooks","security_strategy":"signature","signature_version":2}'

Verifying the signature (version 2)

X-Zo-Signature is the hex HMAC-SHA256 of "{timestamp}.{body}" with the secret, where body is the request body exactly as it arrived, before any parsing. Refuse a timestamp more than 300 seconds away. The functions below are the same ones the live test runs on every delivery:

PHP
function zo_verify(string $body, string $secret, string $signature, ?string $timestamp, int $tolerance = 300): bool
{
    if ($timestamp === null) { // version 1
        return hash_equals(hash_hmac('sha256', $body, $secret), strtolower($signature));
    }
    if (! preg_match('/^\d{1,12}$/', $timestamp) || abs(time() - (int) $timestamp) > $tolerance) {
        return false;
    }

    return hash_equals(hash_hmac('sha256', $timestamp.'.'.$body, $secret), strtolower($signature));
}

// $ok = zo_verify(file_get_contents('php://input'), $secret, $_SERVER['HTTP_X_ZO_SIGNATURE'] ?? '', $_SERVER['HTTP_X_ZO_TIMESTAMP'] ?? null);
Node
const crypto = require('crypto');

// rawBody: the request body as a Buffer or string, before any JSON parsing
function zoVerify(rawBody, secret, signature, timestamp, tolerance = 300) {
  let signed = rawBody;
  if (timestamp != null) { // version 2
    if (!/^\d{1,12}$/.test(timestamp) || Math.abs(Math.floor(Date.now() / 1000) - Number(timestamp)) > tolerance) return false;
    signed = Buffer.concat([Buffer.from(timestamp + '.'), Buffer.from(rawBody)]);
  }
  const expected = Buffer.from(crypto.createHmac('sha256', secret).update(signed).digest('hex'));
  const given = Buffer.from(String(signature || '').toLowerCase());
  return given.length === expected.length && crypto.timingSafeEqual(given, expected);
}

// const ok = zoVerify(req.rawBody, secret, req.get('X-Zo-Signature'), req.get('X-Zo-Timestamp') ?? null);
Python
import hashlib
import hmac
import re
import time


def zo_verify(body: bytes, secret: str, signature: str, timestamp: str | None, tolerance: int = 300) -> bool:
    if timestamp is None:  # version 1
        signed = body
    else:  # version 2
        if not re.fullmatch(r"\d{1,12}", timestamp) or abs(int(time.time()) - int(timestamp)) > tolerance:
            return False
        signed = timestamp.encode() + b"." + body
    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, (signature or "").lower())

# ok = zo_verify(request.get_data(), secret, request.headers.get("X-Zo-Signature", ""), request.headers.get("X-Zo-Timestamp"))

Retries

11. Go-live checklist

Try everything on a test store on Pro with its own key before the merchant's real store.

12. Common mistakes

13. Downloads

OpenAPI 3.1 file (openapi-public.yaml)

14. Support

For a question about an integration or a problem with a key, write to info@zo.sa or message us on WhatsApp +966 58 075 1402. Give the error code and the time of the call, and never send the key itself.