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
POSTgoes to thehttpsaddress 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.
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
| Crossing | What crosses | How it is protected |
|---|---|---|
| Your system to the API | The key, your requests and their JSON bodies | HTTPS; 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 system | JSON answers, with the rate headers | HTTPS; customer contact data only with customers.read |
| The store to your receiver | Webhook 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 owner | The key, shown once | Only the store owner creates keys, after a code to their verified mobile |
| The API to your system, once | A 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_sincepoll 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-Keyderived from your document number, so a retry never repeats it. - Stock moves by delta (
increment,decrement);setonly for a stock count. - The receiver answers first and works later, and drops duplicates by
X-Zo-Delivery. - Your system honours
Retry-Afterand stays under 360 calls a minute per key. - Store by id (upsert): a polled row may arrive twice.