- This guide is for a developer connecting one system of one merchant to their store: products and stock from the system to the store, and orders from the store to the system. It needs no Odoo-specific code: any system that can send HTTPS requests and keep a key will do.
- The API is on the Pro plan only. A store on Basic or Plus cannot create a key, and a key of a store that moved to another plan is answered 402
feature_lockedwith"feature": "public_api"and"required_plan": "pro"(ornullwhile the Pro plan is not on sale). - Base URL:
https://s.zo.sa/api/public/v1. Every path on this page is relative to it, and the full contract of every path and field is in the OpenAPI file.
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.
- All → Developer tools → API keys (
/settings/api-keys) → New key. - 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.
- 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 acustomerobject with a mobile is answered 422customers_scope_required. - Sensitive scopes (customers, and payments and shipments read and write, which move money) show a warning. The full table is under scopes.
- IP addresses (optional, recommended): up to 20 addresses or ranges (IPv4 or IPv6, such as
203.0.113.7or203.0.113.0/24). A call from any other address is answered 403ip_not_allowed. - Expiry (optional): the key stops at the end of that day, Riyadh time.
- Next, then Send verification code: a 4-digit code goes to the owner's verified mobile. Type it, then Create.
- 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
- In an environment variable or a secrets store (such as
ZO_API_KEY), never in code, a repository or an emailed file. - In the
Authorizationheader only, never in the URL (a key in the query string is refused). - To rotate: create a new key, move your system to it, then revoke the old one. If a key leaks, revoke it on the page at once: the next call with it is answered 401
invalid_token, and the webhooks it created stop.
2. The first call
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" -iThe answer is 200 with the rate headers:
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"}}- Every amount is an integer in halalas (100 halalas = 1 SAR).
- Dates are ISO 8601 in UTC.
- Translated text is an object
{ar, en}; either side may benull. Thearside holds the Arabic text, shown as"..."in the examples. - Send
Accept-Language: enfor English error messages (Arabic by default).
3. Authentication and scopes
- Send the key only in
Authorization: Bearer zo_live_…. A key in the query string is refused: it ends up in logs and browser history. - Scopes are
{resource}.reador{resource}.read_write;read_writeincludesread. The store itself isstore.readonly. - A key without the route's scope gets 403
insufficient_scope, naming the missing scope.
| Scope | What it unlocks |
|---|---|
store.read | The store's data (GET /store) |
products.read / products.read_write | Products, categories and brands: read, then create, update and delete |
inventory.read / inventory.read_write | Stock per branch, its movements and the branches, then adjusting quantities |
orders.read / orders.read_write | Orders, their history and the statuses, then creating an order and changing its status |
customers.read / customers.read_write | Customers, and contact data everywhere, then adding and updating a customer |
carts.read / carts.read_write | Abandoned carts (needs the abandoned_carts feature); no write endpoint in v1 |
marketing.read / marketing.read_write | Coupons: read, then create, update and delete |
shipments.read / shipments.read_write | Shipments, then shipping an order and cancelling a shipment |
payments.read / payments.read_write | An order's payments and the payment methods; no write endpoint in v1 |
reviews.read / reviews.read_write | Reviews, then the store's reply |
webhooks.read / webhooks.read_write | The 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:
{ "error": { "code": "validation_failed", "message": "…", "fields": { "variants.0.sku": ["…"] } } }The codes an integration meets:
| Code | Status | What to do |
|---|---|---|
unauthenticated | 401 | No Authorization header. Add it. |
invalid_token | 401 | Wrong, revoked or expired key. Ask the owner for a new key; do not retry. |
feature_locked | 402 | The store is not on Pro (feature: public_api), or another feature is missing (webhooks, abandoned_carts). |
ip_not_allowed | 403 | Your server is not in the key's address list. |
insufficient_scope | 403 | The key lacks the route's scope; scope names it. |
store_suspended | 403 | The store is suspended: reads work, writes are refused. |
not_found | 404 | No row with that id or SKU in this store. |
validation_failed | 422 | Invalid input; fields names each field by its path in the body. |
customers_scope_required | 422 | An order for a customer by mobile without customers.read; send customer_id or add the scope. |
invalid_transition | 422 | A status move that is not allowed; from and to. |
idempotency_key_reused | 422 | An Idempotency-Key used with a different body. |
duplicate_request | 409 | The same call with the same key is still running; retry in a moment. |
out_of_stock | 409 | Not enough stock for the order's lines; items lists them. |
insufficient_stock | 409 | A decrement below zero; available holds what is on hand. |
customer_exists | 409 | The store has a customer with that mobile; customer_id names it. |
rate_limited | 429 | Past the per-minute limit; wait Retry-After. |
images_queue_full | 429 | 50 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
- 360 calls a minute per key (Pro). Each key has its own counter, apart from the merchant dashboard's.
- Every answer that goes through the counter carries
X-RateLimit-Limit,X-RateLimit-RemainingandX-RateLimit-Reset(unix time). 401 and 402 answers do not: they are refused before the count. - The count is exact: concurrent calls never pass the limit, and a refused call is not counted.
- On a 429: wait the seconds in
Retry-After, then send the same call again (with the same Idempotency-Key for a write). - On a network error or a 5xx: retry with growing waits and jitter (1, then 2, then 4 seconds, up to 60), with the same Idempotency-Key for a write, so the operation never runs twice.
- Do not retry other 4xx answers: fix the call. The exception is 409
duplicate_request(retry in a moment). - Stay under the limit: spread calls (about 5 a second), batch stock adjustments up to 100 lines, and read lists with
per_page=100.
6. Lists and sync
- Lists are ordered by
(updated_at, id)and read page by page: passmeta.next_cursorascursor; it isnullon the last page and opaque. per_page1 to 100 (default 50; more is capped at 100).updated_sinceandcreated_since: ISO 8601, inclusive, whole seconds, no offset means UTC.- Same-second limit and re-sync recipe:
updated_athas second precision, so a row changed in the very second a page ends on can be missed by that run. Keep the largestupdated_atyou saw and start the next run withupdated_sinceequal to it: the filter is inclusive, so that second is read again. A row changed while you page moves to the end and may arrive twice, so store by id (upsert). - Lists whose rows never change are ordered by
created_atonly and refuseupdated_since(422): stock movements (GET /inventory/movements), abandoned carts (GET /carts/abandoned; a cart becomes abandoned by time passing, so read the list afresh each time) and webhook deliveries (GET /webhooks/{id}/deliveries). - Deletions: a deleted row (a product, customer, coupon…) vanishes from the lists and never comes back through
updated_since. To learn what was deleted, re-read the whole list now and then and compare, or subscribe to the*.deletedwebhooks (Pro plan).
7. Idempotency on writes
- The
Idempotency-Keyheader: 1 to 120 visible characters. Required onPOST /orders,POST /inventory/adjustmentsandPOST /orders/{id}/shipments(422 without it), optional on the other writes. Ignored onPOST /webhooksandPATCH /webhooks/{id}, because the stored answer would keep the secret. - Derive it from your document number, such as
odoo-move-48213orerp-order-SO1042: a retry after a dropped connection sends the same key, so the order or the stock movement never happens twice. - A second call with the same key within 24 hours gets the first answer back with
Idempotent-Replayed: true. Compare the two after parsing the JSON, not as text: the order of keys may differ. - The same key with a different body: 422
idempotency_key_reused. While the first runs: 409duplicate_request. - 4xx answers are replayed as they were for the same key, so send a new key after fixing the input. 5xx answers and 429
images_queue_fullare not kept, so a retry with the same key runs. - A call that died unfinished (a timeout, a stopped worker) keeps its key for 300 seconds, then the next call with that key takes it over.
8. Syncing products and stock from an ERP
The SKU is the link. Give every variant in the store the SKU your system uses.
- First load: read
GET /products?per_page=100page by page, passingmeta.next_cursorascursoruntil it isnull, and keep each product and variant id against its SKU. - Upsert each item:
GET /products/sku/{sku}. A 404 means a new item:POST /productswith the name and the variants (each withskuandpricein halalas),weight_gramswhen it ships, andstatus: activeto 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
quantitykey is answered 422. Stock has its own path. - A product with sizes or colours:
optionswith their values, and each variant'svaluesholds one value key of every option.
- Pictures: send public links in
images(orPOST /products/{id}/imageswith{url}). They are copied in the background: the answer lists the link inimages_pendingwith statuspending(and 202 for one picture), then it joinsimagesandproduct.updatedis sent. When the copy fails it turnsfailedwithimage_unreachable,too_many_imagesorcopy_failed. A product has 10 pictures, and a store has at most 50 links waiting at once (beyond that, 429images_queue_fullwithRetry-After). A copy job downloads for 60 seconds at most, so with many slow links some may endcopy_failed: send them again in a new write. - Stock by delta:
- Read the level:
GET /inventory?sku={sku}(orvariant_id), per branch. Branch ids come fromGET /branches. - Each movement in your system:
POST /inventory/adjustmentswith{"items":[{"sku":"…","mode":"increment","quantity":5}]}ordecrement, up to 100 lines a call, applied all or nothing, with anIdempotency-Keyfrom the movement number. Withoutbranch_idit goes to the default branch. mode: setmakes 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_stockwithavailable, and nothing is applied.
- Read the level:
- The merchant's own changes: subscribe to
product.updated,product.createdandproduct.deletedto mirror them in your system.
9. Syncing orders into an ERP
- Events: subscribe to
order.createdandorder.status.updated(section 10). On each delivery: verify the signature, drop duplicates byX-Zo-Delivery, answer 2xx at once, then do the work in the background. - 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 withcustomers.read. - Polling fallback: every hour,
GET /orders?updated_since={the largest updated_at you kept}&per_page=100and follownext_cursor. The filter is inclusive, so the last second is read again: store by id (upsert). This catches any event you missed. - Status from your system to the store:
GET /order-statusesgives, for each status, the statuses an order may move to (next).POST /orders/{id}/statuswith{"status":"ready","note":"…"}. A move that is not allowed: 422invalid_transition.- Shipping with your own carrier's tracking number:
POST /orders/{id}/shipmentswith{"tracking_number":"…","carrier_name":"…"}and anIdempotency-Key. The order moves to shipping.
- An order from your system (phone, point of sale):
POST /orderswith anIdempotency-Key,itemsbysku, acustomer_idof an existing customer or acustomerwith name and mobile (needscustomers.read; an existing customer keeps their stored name and email), andpayment_methodcod,bank_transferormanual. The store works out the totals and VAT and takes the stock (409out_of_stockwhen short).
10. Webhooks
Setup
Create the webhook in the dashboard under Developer tools → Webhooks, or through the API:
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}'- The URL is
httpson a public address. One event per webhook; every event is inGET /webhooks/events. A store has 10 webhooks (Pro), shared by the dashboard and every key, and a key sees only the ones it made. - Subscribing to an event needs the read scope of the event's resource, else 403
insufficient_scope:order.*needsorders.read,product.*needsproducts.read,customer.*needscustomers.read, and so on (GET /webhooks/eventsnames the scope of each event). Scopes are checked again at every send. - The secret is shown once, in the create answer (
secret). Keep it. To change it,POST /webhooks/{id}/secret; the old one stops at once. - Every delivery carries
X-Zo-Event,X-Zo-Delivery(the same id on a retry),X-Zo-TimestampandX-Zo-Signature, and the body{event, merchant, created_at, data}. - Note: amounts inside webhook payloads are in riyals (two decimals), as in the dashboard's webhooks, unlike the API's answers, which are in halalas. The envelope's
created_atis in the Riyadh offset (+03:00), while dates in the API's answers are UTC.
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:
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);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);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
- Answer any 2xx within 15 seconds. Otherwise the delivery is tried 3 more times, 5 minutes apart.
- After 50 failures in a row, or 10 timeouts in a row, the webhook switches itself off and the owner is told. Switch it back on with
PATCH /webhooks/{id}and{"is_active": true}once the receiver is fixed. POST /webhooks/{id}/testsends a sample now and answers its result; your receiver has 5 seconds (1 to connect).GET /webhooks/{id}/deliveriesis the last 30 days, andPOST /webhooks/{id}/deliveries/{delivery}/resendsends the same event again: it answers 202 with statuspending; read the outcome later withGET /webhooks/{id}/deliveries/{delivery}.- Outbound address: webhooks come from
174.138.100.139, but the server has at times sent from134.122.85.105; an allow-list should hold both.
11. Go-live checklist
- The store is on Pro, and the owner created the key under the system's name.
- The fewest scopes, with customers read only when needed.
- Your servers' IP addresses are in the key's list, with an expiry date for a temporary integration.
- The key is in an environment variable or a secrets store, never in code or logs.
- Every write sends an
Idempotency-Keyderived from the document number. - Your system honours
Retry-Afterand retries with growing waits for temporary errors only. - Webhooks use signature v2, and the receiver verifies it, refuses timestamps older than 300 seconds, drops duplicates by
X-Zo-Deliveryand answers within 15 seconds. - An hourly
updated_sincepoll closes any gap. - Every variant's SKU in the store is the one in your system.
- Amounts are in halalas both ways.
- Monitoring alerts on 401, 402 or 403 (a revoked key, a plan change, a new address).
Try everything on a test store on Pro with its own key before the merchant's real store.
12. Common mistakes
- Sending a quantity on a product: answered 422. Stock goes through
POST /inventory/adjustmentsonly. setfor every movement: erases the store's sales between your read and your write. Useincrementanddecrement, andsetfor stock counts.- A random Idempotency-Key on each retry: repeats the call. Derive the key from the document number and keep it for every try.
- Verifying the signature on re-encoded JSON: the signature covers the body as it arrived. Read the raw body before any parsing.
- Long work before answering a delivery: past 15 seconds the delivery is retried and the webhook may switch off. Answer first, then work.
- Riyals instead of halalas:
price: 50means 50 halalas. 50 SAR is5000. - One key for every system: revoking it stops them all, and you cannot tell who did what. One key per system.
- The key in the URL: refused, and it stays in logs. The header only.
- Expecting
customer.mobilewithoutcustomers.read: it never appears. Add the scope or work with the customer id. - Retrying a 429 at once: refused again. Wait
Retry-After.
13. Downloads
OpenAPI 3.1 file (openapi-public.yaml)
- The exact contract of every path, field and error code, with the scope each operation needs in
x-scope. Open it in any OpenAPI viewer (Swagger Editor, Redocly, Stoplight). - Postman: import the file with «Import» to build the collection from the contract, then set the base URL to
https://s.zo.sa/api/public/v1and Bearer authentication with a variable holding the key.
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.