Order sync
The flow from the store to your system: a signed webhook tells you at once, you read the full order, send status back, and an hourly poll closes any gap.
updated_at you kept, page by page.The steps
Events
Subscribe to
order.createdandorder.status.updated. 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.Status back
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 is 422invalid_transition. Shipping with your own carrier's tracking number:POST /orders/{id}/shipmentswith{"tracking_number":"…","carrier_name":"…"}and anIdempotency-Key.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.
Amounts inside webhook payloads are in riyals (two decimals), as in the dashboard's webhooks, unlike the API's answers, which are in halalas. Read the order with GET /orders/{id} for the amounts you book.
The step-by-step guide: Sync orders into an ERP. The operations: Orders and Shipments.