Sifr Wahid Developers

Architecture (HLD)

System overview

A high-level design for an integrator: the parts, how they talk, the trust boundaries and what crosses them.

The parts

  • Your system: an ERP, Odoo, an accounting or inventory system, or your own code. It keeps one API key per system and sends HTTPS requests with it.
  • The public API at https://s.zo.sa/api/public/v1: REST and JSON. Each key is bound to one store, and every answer is about that store only.
  • The store: products, categories, brands, stock, orders, customers, coupons, shipments, reviews, payments and abandoned carts, read and changed through the API with the scopes the key holds.
  • Webhooks: when something happens in the store, a signed POST goes to the https address you registered, with the body {event, merchant, created_at, data}.
  • Your receiver: verifies the signature on the raw body, drops duplicates by X-Zo-Delivery, answers 2xx at once and does the work in the background.
Your side Sifr Wahid Internet, HTTPS only Your system ERP, Odoo, accounting, inventory or your own code ZO_API_KEY (a secret) Your receiver https on a public host verifies the signature drops duplicate deliveries answers 2xx within 15 s Public API s.zo.sa/api/public/v1 checks the key, plan, address, scope and per-key limit The store one store per key Webhooks one event per webhook signed with its secret (signature strategy) retried when not answered request, JSON body Authorization: Bearer zo_live_... JSON answer, amounts in halalas X-RateLimit-Limit: 360 signed POST {event, merchant, created_at, data} X-Zo-Signature, X-Zo-Timestamp any 2xx
Your system calls the public API over HTTPS with the key in the Authorization header and gets JSON back. The store sends each subscribed event as a signed POST to your receiver, which answers 2xx. Dashed boxes are the trust boundaries.

Trust boundaries and what crosses them

CrossingWhat crossesHow it is protected
Your system to the APIThe key, your requests and their JSON bodiesHTTPS; the key in the Authorization header only, never in the URL; an optional list of up to 20 allowed IP addresses or ranges; scopes per resource
The API to your systemJSON answers, with the rate headersHTTPS; customer contact data only with customers.read
The store to your receiverWebhook deliveries {event, merchant, created_at, data}The receiver URL is https on a public address; no redirects are followed; signature version 2 (a webhook made through the API) signs "{timestamp}.{body}" with the webhook's secret; refuse a timestamp more than 300 seconds away
The dashboard to the ownerThe key, shown onceOnly the store owner creates keys, after a code to their verified mobile
The API to your system, onceA webhook's secret, in the create answer (secret)Shown once; POST /webhooks/{id}/secret makes a new one and the old one stops at once

Two directions of sync

  • From your system to the store: products and stock. Your system calls the API; the SKU links the two. See Product and stock sync.
  • From the store to your system: orders. Webhooks tell you at once, and an hourly updated_since poll closes any gap. See Order sync.

Design rules for an integration

  • One key per system, with the fewest scopes, kept in a secret store.
  • Every write sends an Idempotency-Key derived from your document number, so a retry never repeats it.
  • Stock moves by delta (increment, decrement); set only for a stock count.
  • The receiver answers first and works later, and drops duplicates by X-Zo-Delivery.
  • Your system honours Retry-After and stays under 360 calls a minute per key.
  • Store by id (upsert): a polled row may arrive twice.