Sifr Wahid Developers

Concepts

Authentication and scopes

One header authenticates every call; the key's scopes decide what it may read and change.

The key in the header

  • 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}.read or {resource}.read_write; read_write includes read. The store itself is store.read only.
  • A key without the route's scope gets 403 insufficient_scope, naming the missing scope.
HTTP
GET /api/public/v1/store HTTP/1.1
Host: s.zo.sa
Authorization: Bearer zo_live_...
Accept: application/json

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 (Webhooks)

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).

  • Creating an order for a customer by mobile needs customers.read as well; without it the call is 422 customers_scope_required. A customer_id works with orders.read_write alone.
  • A shipment's label (GET /shipments/{id}/label) needs customers.read too, because the label carries the shopper's address and mobile.

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.

Scopes for webhooks

Subscribing to an event needs the read scope of the event's resource, else 403 insufficient_scope: order.* needs orders.read, product.* needs products.read, customer.* needs customers.read, and so on (GET /webhooks/events names the scope of each event). The stock events product.quantity.low and product.available need inventory.read or products.read. Scopes are checked again at every send. Every event and its scope: Webhook events.

Operations per scope

Each operation names the scope it needs in the OpenAPI file (x-scope). A key with {resource}.read_write also holds {resource}.read.

ScopeOperations that need it
carts.readGET /carts/abandoned
customers.readGET /customers
GET /customers/{id}
customers.read_writePOST /customers
PATCH /customers/{id}
inventory.readGET /inventory
GET /inventory/movements
GET /branches
inventory.read_writePOST /inventory/adjustments
marketing.readGET /coupons
GET /coupons/{id}
marketing.read_writePOST /coupons
PATCH /coupons/{id}
DELETE /coupons/{id}
orders.readGET /orders
GET /orders/{id}
GET /orders/{id}/history
GET /order-statuses
orders.read_writePOST /orders
POST /orders/{id}/status
payments.readGET /orders/{id}/payments
GET /payment-methods
products.readGET /products
GET /products/{id}
GET /products/sku/{sku}
GET /categories
GET /categories/{id}
GET /brands
GET /brands/{id}
products.read_writePOST /products
PATCH /products/{id}
DELETE /products/{id}
PATCH /products/sku/{sku}
POST /products/{id}/images
DELETE /products/{id}/images/{image}
POST /categories
PATCH /categories/{id}
DELETE /categories/{id}
POST /brands
reviews.readGET /reviews
GET /reviews/{id}
reviews.read_writePUT /reviews/{id}/reply
DELETE /reviews/{id}/reply
shipments.readGET /shipments
GET /shipments/{id}
GET /shipments/{id}/label
GET /orders/{id}/shipments
shipments.read_writeDELETE /shipments/{id}
POST /orders/{id}/shipments
store.readGET /store
webhooks.readGET /webhooks/events
GET /webhooks
GET /webhooks/{id}
GET /webhooks/{id}/deliveries
GET /webhooks/{id}/deliveries/{delivery}
webhooks.read_writePOST /webhooks
PATCH /webhooks/{id}
DELETE /webhooks/{id}
POST /webhooks/{id}/secret
POST /webhooks/{id}/test
POST /webhooks/{id}/deliveries/{delivery}/resend