{"openapi":"3.1.0","info":{"title":"Naqllah App API","version":"1.0.0","description":"Read access to one store, granted by its owner. The store is the one the access token was issued for."},"servers":[{"url":"https://naqllah.com/api/apps/v1"}],"paths":{"/store":{"get":{"summary":"The store that installed the app","security":[{"oauth":["store.read"]}],"parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Store"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/installation/config":{"get":{"summary":"What the merchant filled in your app's setup fields for this store","security":[{"oauth":["store.read"]}],"parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/InstallationConfig"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products":{"get":{"summary":"List products","security":[{"oauth":["products.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"sku","in":"query","schema":{"type":"string","maxLength":64}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products/{id}":{"get":{"summary":"One product","security":[{"oauth":["products.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Product"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders":{"get":{"summary":"List orders (test orders excluded)","security":[{"oauth":["orders.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"status","in":"query","schema":{"type":"string"}},{"name":"updated_since","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{id}":{"get":{"summary":"One order with its items","security":[{"oauth":["orders.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Order"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{id}/refunds":{"get":{"summary":"The refunds of one order","security":[{"oauth":["orders.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Refund"}}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{id}/invoice":{"get":{"summary":"The tax invoice issued for one order (404 before it is issued)","security":[{"oauth":["invoices.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Invoice"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/usage":{"get":{"summary":"Usage apps: this month's usage, the store's cap and what is left","security":[{"oauth":["store.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/UsageState"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/usage/records":{"post":{"summary":"Usage apps: report units; refused (402) when the month would pass the store's cap","security":[{"oauth":["store.read"]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UsageRecord"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UsageRecord"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UsageRecord"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["quantity"],"properties":{"quantity":{"type":"integer","minimum":1,"maximum":100000},"note":{"type":"string","maxLength":120}}}}}}}},"/abandoned-carts":{"get":{"summary":"Abandoned carts of customers who consent to marketing, newest first","security":[{"oauth":["customers.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"updated_since","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"recovered","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AbandonedCart"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/discounts":{"get":{"summary":"The store's discount codes, newest first","security":[{"oauth":["discounts.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Discount"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/discounts/{id}":{"get":{"summary":"One discount code","security":[{"oauth":["discounts.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Discount"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/discounts/create":{"post":{"summary":"Create a dated discount code (the merchant's conditions cap percent, amount and validity)","security":[{"oauth":["discounts.write"]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["code","type","ends_at"],"properties":{"code":{"type":"string","pattern":"^[A-Za-z0-9-]{4,32}$","description":"Stored in capitals; unique in the store"},"type":{"type":"string","enum":["percent","fixed","free_shipping"]},"value":{"type":"string","pattern":"^[0-9]+(\\.[0-9]{1,2})?$","description":"Percent (1–100) or SAR; not sent for free_shipping"},"min_subtotal":{"type":"string","pattern":"^[0-9]+(\\.[0-9]{1,2})?$"},"max_uses":{"type":"integer","minimum":1},"max_uses_per_customer":{"type":"integer","minimum":1},"ends_at":{"type":"string","format":"date","description":"Last day (Riyadh), today to 365 days ahead"}}}}}}}},"/discounts/{id}/disable":{"post":{"summary":"Turn off a discount code your app created","security":[{"oauth":["discounts.write"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"carrier":{"type":"string","description":"A Naqllah carrier code; required when the merchant limits carriers"}}}}}}}},"/exports":{"post":{"summary":"Start a bulk export of orders, products or customers (also needs that resource's read scope)","security":[{"oauth":["store.read"]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Export"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Export"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Export"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["resource"],"properties":{"resource":{"type":"string","enum":["orders","products","customers"]},"updated_since":{"type":"string","format":"date-time","description":"Only records changed since (customers: created since)"}}}}}}}},"/exports/{id}":{"get":{"summary":"The state of an export; file_url once it is ready","security":[{"oauth":["store.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Export"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/exports/{id}/file":{"get":{"summary":"Download a ready export: gzip, one JSON object per line, for 24 hours","security":[{"oauth":["store.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"The export file: gzip, one JSON object per line","content":{"application/gzip":{"schema":{"type":"string","format":"binary"},"x-record":{"$ref":"#/components/schemas/Order"}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"export_not_ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/payments":{"get":{"summary":"Payment transactions, newest first (order_id, updated_since filters)","security":[{"oauth":["payments.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"order_id","in":"query","schema":{"type":"integer","minimum":1}},{"name":"updated_since","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Payment"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{id}/payments":{"get":{"summary":"One order's transactions and Naqllah's fees on it","security":[{"oauth":["payments.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OrderPayments"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/returns":{"get":{"summary":"Return requests with their lines (order_id, status filters)","security":[{"oauth":["orders.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"order_id","in":"query","schema":{"type":"integer","minimum":1}},{"name":"status","in":"query","schema":{"type":"string","enum":["requested","approved","in_transit","received","completed","rejected"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ReturnRequest"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/customers":{"get":{"summary":"List customers (shoppers only)","security":[{"oauth":["customers.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"updated_since","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"email","in":"query","description":"Exact address, any case","schema":{"type":"string","format":"email"}},{"name":"phone","in":"query","description":"Exact number as stored (local or +966…)","schema":{"type":"string","maxLength":20}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/customers/{id}":{"get":{"summary":"One customer","security":[{"oauth":["customers.read"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Customer"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/shipments":{"get":{"summary":"The shipments of one order (order_id)","security":[{"oauth":["shipping.read"]}],"parameters":[{"name":"order_id","in":"query","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Shipment"}}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{id}/shipping":{"get":{"summary":"The shipping view of an order routed to this app (recipient, address, COD, lines, parcel)","security":[{"oauth":["shipping.orders"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ShippingView"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{id}/shipments":{"post":{"summary":"Record your waybill (and label) for an order routed to your app","security":[{"oauth":["shipments.write"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["awb"],"properties":{"awb":{"type":"string","pattern":"^[A-Za-z0-9-]{4,40}$","description":"Your waybill number"},"service":{"type":"string","maxLength":40},"tracking_url":{"type":"string","format":"uri","description":"https"},"eta":{"type":"string","format":"date-time"},"boxes":{"type":"integer","minimum":1,"maximum":50,"default":1},"label_url":{"type":"string","format":"uri","description":"https, a PDF of at most 2 MB, fetched once and kept privately"}}}}}}}},"/shipments/{id}/events":{"post":{"summary":"Report one tracking step of your shipment, forward only","security":[{"oauth":["shipments.write"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["pending","picked_up","in_transit","out_for_delivery","failed_attempt","delivered","returned"]},"occurred_at":{"type":"string","format":"date-time"},"location":{"type":"string","maxLength":120}}}}}}}},"/shipments/{id}/cancel":{"post":{"summary":"Confirm or refuse the merchant's cancel request","security":[{"oauth":["shipments.write"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["result"],"properties":{"result":{"type":"string","enum":["confirmed","refused"]},"reason":{"type":"string","maxLength":200}}}}}}}},"/shipments/{id}/cod":{"post":{"summary":"Report the cash collected on delivery, then remitted to the merchant","security":[{"oauth":["shipments.write"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["kind","amount"],"properties":{"kind":{"type":"string","enum":["collected","remitted"]},"amount":{"type":"string","pattern":"^[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"reference":{"type":"string","maxLength":80},"occurred_at":{"type":"string","format":"date-time"}}}}}}}},"/returns/{id}/shipments":{"post":{"summary":"Record the reverse waybill of an approved return","security":[{"oauth":["shipments.write"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["awb"],"properties":{"awb":{"type":"string","pattern":"^[A-Za-z0-9-]{4,40}$"},"label_url":{"type":"string","format":"uri","description":"https, a PDF of at most 2 MB"}}}}}}}},"/locations":{"get":{"summary":"The store's stock locations; yours marks your fulfilment app's own","security":[{"oauth":["stock.read"]}],"parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Location"}}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/inventory":{"get":{"summary":"Stock per SKU (product or variant) and location","security":[{"oauth":["stock.read"]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockLevel"}},"meta":{"$ref":"#/components/schemas/Page"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/inventory/counts":{"post":{"summary":"Report absolute counts for your own location (fulfilment apps), once per count_id","security":[{"oauth":["stock.write"]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["location_id","count_id","counts"],"properties":{"location_id":{"type":"integer","minimum":1},"count_id":{"type":"string","pattern":"^[A-Za-z0-9._:-]{4,80}$"},"counts":{"type":"array","maxItems":200,"items":{"type":"object","required":["sku","quantity"],"properties":{"sku":{"type":"string","maxLength":64},"quantity":{"type":"integer","minimum":0}}}}}}}}}}},"/fulfillment/orders":{"get":{"summary":"The orders routed to your fulfilment app on this store, with the warehouse step","security":[{"oauth":["fulfillment.orders"]}],"parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/FulfillmentOrder"}}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/fulfillment/orders/{id}/status":{"post":{"summary":"Report the warehouse's next step: received, picking, packed, handed_over","security":[{"oauth":["fulfillment.orders"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["received","picking","packed","handed_over"]},"note":{"type":"string","maxLength":200}}}}}}}},"/shipping/rates":{"post":{"summary":"Set your rate card for this store (your default card is set in the developer portal)","security":[{"oauth":["shipments.write"]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["services"],"properties":{"valid_from":{"type":"string","format":"date","description":"Today up to a year ahead; default today"},"services":{"type":"array","maxItems":10,"items":{"type":"object","required":["service","first_kg","first_price","cities","eta"],"properties":{"service":{"type":"string","enum":["standard","express","same_day","instant","cold_chain"]},"first_kg":{"type":"number","minimum":0.1,"maximum":100},"first_price":{"type":"string","description":"SAR before VAT, two decimals"},"extra_kg_price":{"type":"string","description":"SAR per started kg above first_kg"},"cities":{"type":"array","items":{"type":"string"},"description":"Names from Naqllah's served-city list, or [\"*\"] for all"},"eta":{"type":"object","properties":{"unit":{"type":"string","enum":["days","hours"]},"min":{"type":"integer"},"max":{"type":"integer"}}},"cod":{"type":"object","properties":{"available":{"type":"boolean"},"fee":{"type":"string"}}},"volumetric_divisor":{"type":"integer","minimum":1000,"maximum":10000,"description":"cm³ per kg (e.g. 5000); when set, a parcel is priced at max(actual, volume ÷ divisor)"}}}}}}}}}}},"/orders/{id}/waybills":{"post":{"summary":"Ask for a waybill through Naqllah carriers; the merchant's policy decides","security":[{"oauth":["waybills.create"]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":80,"pattern":"^[A-Za-z0-9._:-]+$"}}],"responses":{"201":{"description":"done","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"200":{"description":"still running: read the result at /waybills/requests/{uuid}","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"idempotency_key_reused"},"422":{"description":"the store refused it (status failed), or invalid_request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"carrier":{"type":"string","description":"A Naqllah carrier code; required when the merchant limits carriers"}}}}}}}},"/waybills/requests/{uuid}":{"get":{"summary":"One waybill request and its result","security":[{"oauth":["waybills.create"]}],"parameters":[{"name":"uuid","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActionRequest"}}}}}},"401":{"description":"invalid_token or not_installed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope or app_suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"oauth":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"/dashboard/apps/authorize","tokenUrl":"/oauth/token","refreshUrl":"/oauth/token","scopes":{"store.read":"Read basic store details: name, currency and language","products.read":"Read products, their prices and quantities","stock.read":"Read stock quantities in every warehouse","stock.write":"Change stock quantities (recorded in the stock ledger)","orders.read":"Read orders, their statuses and amounts","customers.read":"Read customer details: name, email and mobile number","shipping.read":"Read order shipments: carrier, waybill number and status","shipping.orders":"Read the recipient, address and cash-on-delivery amount of the orders the store sends to this app for shipping","fulfillment.orders":"Take the orders the store sends to its warehouse, prepare and ship them, and report each step","shipments.write":"Record the waybill, label and tracking steps of the orders the store sends to this app, and answer cancel requests","waybills.create":"Issue shipping waybills for orders through Naqllah carriers (the cost is taken from the store balance)","payments.read":"Read payments and amounts received","invoices.read":"Read the invoices issued for orders: number, amounts, the QR code when there is one and a download link","discounts.read":"Read discount codes and offers","discounts.write":"Create and edit discount codes and offers","webhooks.read":"Receive instant notifications of store events allowed by the permissions above","desk.sections":"Add the app's pages to the dashboard menu","storefront.scripts":"Add a reviewed script to the store pages (never checkout, payment or sign-in pages)"}}}}},"schemas":{"Store":{"type":"object","example":{"id":1042,"uuid":"9b2f6c1e-4d3a-4f7b-a1c2-5e8d0f9a7b31","name":"متجر الريم","currency":"SAR","locale":"ar","timezone":"Asia/Riyadh"},"properties":{"id":{"type":"integer"},"uuid":{"type":"string"},"name":{"type":"string"},"currency":{"type":"string"},"locale":{"type":"string"},"timezone":{"type":"string"}}},"Product":{"type":"object","example":{"id":318,"sku":"TS-BLK-M","name":"قميص قطني أسود","name_en":"Black cotton shirt","quantity":24,"price":"89.00","current_price":"89.00","compare_at_price":"119.00","sale":null,"updated_at":"2026-11-04T09:12:44+03:00"},"properties":{"id":{"type":"integer"},"sku":{"type":["string","null"]},"name":{"type":"string"},"name_en":{"type":["string","null"]},"quantity":{"type":"integer"},"price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"compare_at_price":{"oneOf":[{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},{"type":"null"}]},"updated_at":{"type":["string","null"],"format":"date-time"},"current_price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"The price checkout charges now (before VAT): the sale price inside a scheduled sale window, else price."},"sale":{"type":["object","null"],"description":"Scheduled sale (Asia/Riyadh window, starts_at ≤ now < ends_at). Starting or ending sends no webhook.","properties":{"price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"starts_at":{"type":["string","null"]},"ends_at":{"type":"string"},"active":{"type":"boolean"}}},"variants":{"type":"array","description":"One product only","items":{"type":"object","properties":{"id":{"type":"integer"},"sku":{"type":["string","null"]},"options":{"type":"object"},"price":{"oneOf":[{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},{"type":"null"}]},"quantity":{"type":"integer"}}}},"category":{"type":["object","null"],"description":"One product only","properties":{"id":{"type":"integer"},"parent_id":{"type":["integer","null"]},"name":{"type":"string"},"name_en":{"type":["string","null"]},"slug":{"type":["string","null"]}}},"images":{"type":"array","description":"One product only","items":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"alt":{"type":["string","null"]},"primary":{"type":"boolean"},"variant_id":{"type":["integer","null"]}}}}}},"Order":{"type":"object","example":{"id":5521,"number":"NQ-10482","status":"processing","payment_status":"paid","total":"489.00","currency":"SAR","created_at":"2026-11-04T09:14:02+03:00","updated_at":"2026-11-04T09:20:31+03:00"},"properties":{"id":{"type":"integer"},"number":{"type":"string"},"status":{"type":"string"},"payment_status":{"type":["string","null"]},"total":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"currency":{"type":"string"},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"},"items":{"type":"array","description":"One order only","items":{"type":"object","properties":{"id":{"type":"integer"},"product_id":{"type":["integer","null"]},"quantity":{"type":"integer"},"price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"}}}}}},"Customer":{"type":"object","example":{"id":771,"name":"سارة العتيبي","email":"sara@example.com","phone":"+966500000000","marketing_consent":{"email":true,"sms":true,"whatsapp":false},"created_at":"2026-10-21T18:40:00+03:00","updated_at":"2026-11-02T12:05:00+03:00"},"properties":{"id":{"type":"integer"},"name":{"type":["string","null"]},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"marketing_consent":{"type":"object","properties":{"email":{"type":"boolean"},"sms":{"type":"boolean"},"whatsapp":{"type":"boolean"}}},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"}}},"Shipment":{"type":"object","example":{"id":903,"order_id":5521,"carrier":"carrier_code","awb":"7781204512","status":"in_transit","created_at":"2026-11-04T11:02:10+03:00","updated_at":"2026-11-04T15:30:00+03:00"},"properties":{"id":{"type":"integer"},"order_id":{"type":"integer"},"carrier":{"type":"string"},"awb":{"type":"string"},"status":{"type":"string"},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"}}},"UsageState":{"type":"object","example":{"month":"2026-11","unit":"رسالة واتساب","unit_price":"0.15","used":"42.60","cap":"200.00","remaining":"157.40","currency":"SAR","vat_excluded":true},"properties":{"month":{"type":"string"},"unit":{"type":"string"},"unit_price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"used":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"cap":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"remaining":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"currency":{"type":"string"},"vat_excluded":{"type":"boolean"}}},"UsageRecord":{"type":"object","example":{"id":5120,"quantity":12,"amount":"1.80","month":"2026-11","usage":{"month":"2026-11","unit":"رسالة واتساب","unit_price":"0.15","used":"42.60","cap":"200.00","remaining":"157.40","currency":"SAR","vat_excluded":true}},"properties":{"id":{"type":"integer"},"quantity":{"type":"integer"},"amount":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"month":{"type":"string"},"usage":{"$ref":"#/components/schemas/UsageState"}}},"AbandonedCart":{"type":"object","example":{"cart_id":9120,"customer_id":771,"items":[{"product_id":318,"variant_id":1204,"sku":"TS-BLK-M","quantity":2,"unit_price":"89.00"}],"items_count":2,"total":"178.00","recovered":false,"recovered_order_id":null,"created_at":"2026-11-04T08:02:11+03:00","updated_at":"2026-11-04T09:05:00+03:00","marketing_consent":{"email":true,"sms":true,"whatsapp":false}},"properties":{"cart_id":{"type":"integer"},"customer_id":{"type":"integer"},"items":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":["integer","null"]},"variant_id":{"type":["integer","null"]},"sku":{"type":["string","null"]},"quantity":{"type":"integer"},"unit_price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"}}}},"items_count":{"type":"integer"},"total":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"recovered":{"type":"boolean"},"recovered_order_id":{"type":["integer","null"]},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"},"marketing_consent":{"type":"object","properties":{"email":{"type":"boolean"},"sms":{"type":"boolean"},"whatsapp":{"type":"boolean"}}}}},"Discount":{"type":"object","example":{"id":44,"code":"WELCOME10","type":"percent","value":"10.00","min_subtotal":"100.00","max_uses":500,"max_uses_per_customer":1,"used_count":37,"starts_at":null,"ends_at":"2026-12-31T23:59:59+03:00","active":true,"created_by_this_app":true,"created_at":"2026-11-04T09:15:02+03:00"},"properties":{"id":{"type":"integer"},"code":{"type":"string"},"type":{"type":"string","enum":["percent","fixed","free_shipping"]},"value":{"oneOf":[{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},{"type":"null"}]},"min_subtotal":{"oneOf":[{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},{"type":"null"}]},"max_uses":{"type":["integer","null"]},"max_uses_per_customer":{"type":["integer","null"]},"used_count":{"type":"integer"},"starts_at":{"type":["string","null"],"format":"date-time"},"ends_at":{"type":["string","null"],"format":"date-time"},"active":{"type":"boolean"},"created_by_this_app":{"type":"boolean"},"created_at":{"type":["string","null"],"format":"date-time"}}},"Export":{"type":"object","example":{"id":31,"resource":"orders","status":"ready","rows":18240,"updated_since":null,"created_at":"2026-11-04T09:15:02+03:00","expires_at":"2026-11-05T09:16:10+03:00","file_url":"https://naqllah.example/api/apps/v1/exports/31/file"},"properties":{"id":{"type":"integer"},"resource":{"type":"string","enum":["orders","products","customers"]},"status":{"type":"string","enum":["queued","running","ready","failed","expired"]},"rows":{"type":"integer"},"updated_since":{"type":["string","null"],"format":"date-time"},"created_at":{"type":["string","null"],"format":"date-time"},"expires_at":{"type":["string","null"],"format":"date-time"},"file_url":{"type":["string","null"],"format":"uri"}}},"Invoice":{"type":"object","example":{"order_id":5521,"number":"INV-000214","kind":"simplified_tax","seller_name":"متجر الورد","vat_number":null,"issued_at":"2026-11-04T09:15:41+03:00","currency":"SAR","subtotal":"425.22","tax_amount":"63.78","total":"489.00","lines":[{"name":"باقة ورد","quantity":1,"unit_price":"425.22","tax_rate_percent":15,"tax_amount":"63.78","line_total":"489.00"}],"qr_tlv_base64":"AQ3Zhdiq2KzYsSDYp9mE2YjYsdivAg8zMDAwMDAwMDAwMDAwMDM=","pdf_url":"https://ward.example/invoice/INV-000214?expires=1765000000&signature=…"},"properties":{"order_id":{"type":"integer"},"number":{"type":"string"},"kind":{"type":"string","enum":["simplified_tax","commercial"]},"seller_name":{"type":"string"},"vat_number":{"type":["string","null"]},"issued_at":{"type":["string","null"],"format":"date-time"},"currency":{"type":"string"},"subtotal":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"tax_amount":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"total":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"lines":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"quantity":{"type":"integer"},"unit_price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"tax_rate_percent":{"type":"number"},"tax_amount":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"line_total":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"}}}},"qr_tlv_base64":{"type":["string","null"]},"pdf_url":{"type":["string","null"],"format":"uri"}}},"Payment":{"type":"object","example":{"id":811,"order_id":5521,"kind":"payment","method":"mada","amount":"489.00","currency":"SAR","status":"completed","paid_at":"2026-11-04T09:15:40+03:00","created_at":"2026-11-04T09:15:02+03:00","updated_at":"2026-11-04T09:15:40+03:00"},"properties":{"id":{"type":"integer"},"order_id":{"type":"integer"},"kind":{"type":"string","enum":["payment","refund"]},"method":{"type":"string"},"amount":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"currency":{"type":"string"},"status":{"type":"string"},"paid_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"}}},"OrderPayments":{"type":"object","example":{"order_id":5521,"transactions":[{"id":811,"order_id":5521,"kind":"payment","method":"mada","amount":"489.00","currency":"SAR","status":"completed","paid_at":"2026-11-04T09:15:40+03:00","created_at":"2026-11-04T09:15:02+03:00","updated_at":"2026-11-04T09:15:40+03:00"}],"fees":"7.34","currency":"SAR"},"properties":{"order_id":{"type":"integer"},"transactions":{"type":"array","items":{"$ref":"#/components/schemas/Payment"}},"fees":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"currency":{"type":"string"}}},"Refund":{"type":"object","example":{"id":812,"order_id":5521,"amount":"89.00","method":"paymob","status":"completed","created_at":"2026-11-06T13:20:00+03:00"},"properties":{"id":{"type":"integer"},"order_id":{"type":"integer"},"amount":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"method":{"type":"string"},"status":{"type":"string"},"created_at":{"type":["string","null"],"format":"date-time"}}},"ReturnRequest":{"type":"object","example":{"id":77,"order_id":5521,"type":"refund","status":"approved","carrier":null,"awb":null,"lines":[{"order_item_id":9001,"quantity":1}],"created_at":"2026-11-06T09:00:00+03:00","updated_at":"2026-11-06T10:00:00+03:00"},"properties":{"id":{"type":"integer"},"order_id":{"type":"integer"},"type":{"type":"string"},"status":{"type":"string","enum":["requested","approved","in_transit","received","completed","rejected"]},"carrier":{"type":["string","null"]},"awb":{"type":["string","null"]},"lines":{"type":"array","items":{"type":"object","properties":{"order_item_id":{"type":"integer"},"quantity":{"type":"number"}}}},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"}}},"Location":{"type":"object","example":{"id":3,"name":"مستودع الرياض","city":"Riyadh","active":true,"yours":true},"properties":{"id":{"type":"integer"},"name":{"type":"string"},"city":{"type":["string","null"]},"active":{"type":"boolean"},"yours":{"type":"boolean"}}},"StockLevel":{"type":"object","example":{"sku":"TS-BLK-M","product_id":318,"variant_id":44,"location_id":3,"quantity":24},"properties":{"sku":{"type":["string","null"]},"product_id":{"type":"integer"},"variant_id":{"type":["integer","null"]},"location_id":{"type":"integer"},"quantity":{"type":"number"}}},"FulfillmentOrder":{"type":"object","example":{"order_id":5521,"number":"NQ-10482","order_status":"processing","fulfillment_status":"picking","route_id":"1e7b9c40-2d6a-4f3e-9a8b-5c1d0e2f4a67","routed_at":"2026-11-04T09:15:42+03:00"},"properties":{"order_id":{"type":"integer"},"number":{"type":"string"},"order_status":{"type":"string"},"fulfillment_status":{"type":["string","null"],"enum":["received","picking","packed","handed_over",null]},"route_id":{"type":"string","format":"uuid"},"routed_at":{"type":["string","null"],"format":"date-time"}}},"InstallationConfig":{"type":"object","example":{"fields":{"account_number":"400123","api_key":"live_9f2c…","branch":"RUH-02"}},"properties":{"fields":{"type":"object","description":"Your setup field keys and the values this store filled (null while empty). Secrets come in clear: keep them encrypted.","additionalProperties":{"type":["string","null"]}}}},"ShippingView":{"type":"object","example":{"order_id":5521,"number":"NQ-10482","recipient":{"name":"سارة العتيبي","phone":"+966500000000"},"address":{"line1":"شارع الأمير سلطان 12","district":"الروضة","city":"جدة","postcode":"23435","country":"SA","short_address":"RRRD2929","lat":null,"lng":null,"notes":null},"payment":{"method":"cod","cod_amount":"489.00"},"items":[{"id":9001,"sku":"TS-BLK-M","name":"قميص قطني أسود","variant_id":44,"quantity":2,"unit_price":"89.00","weight_g":350}],"declared_value":"489.00","currency":"SAR","parcel":{"weight_kg":0.7,"pieces":1,"dimensions_cm":null}},"properties":{"order_id":{"type":"integer"},"number":{"type":"string"},"recipient":{"type":"object","properties":{"name":{"type":"string"},"phone":{"type":"string"}}},"address":{"type":"object","properties":{"line1":{"type":"string"},"district":{"type":"string"},"city":{"type":"string"},"postcode":{"type":"string"},"country":{"type":"string"},"short_address":{"type":["string","null"],"description":"Saudi national short address"},"lat":{"type":["number","null"]},"lng":{"type":["number","null"]},"notes":{"type":["string","null"]}}},"payment":{"type":"object","properties":{"method":{"type":"string","enum":["prepaid","cod"]},"cod_amount":{"oneOf":[{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},{"type":"null"}]}}},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"sku":{"type":["string","null"]},"name":{"type":["string","null"]},"variant_id":{"type":["integer","null"]},"quantity":{"type":"integer"},"unit_price":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"weight_g":{"type":["integer","null"]}}}},"declared_value":{"type":"string","pattern":"^-?[0-9]+\\.[0-9]{2}$","description":"SAR, two decimals"},"currency":{"type":"string"},"parcel":{"type":"object","properties":{"weight_kg":{"type":"number"},"pieces":{"type":"integer"},"dimensions_cm":{"type":["object","null"],"properties":{"length":{"type":"number"},"width":{"type":"number"},"height":{"type":"number"}}}}}}},"ActionRequest":{"type":"object","example":{"id":"3c9e1f20-8b6a-4d0e-9f51-2a7c4b8d6e10","scope":"waybills.create","status":"done","mode":"notify","reason":null,"result":{"awb":"7781204512"},"error":null,"created_at":"2026-11-04 11:02:09"},"properties":{"id":{"type":"string","format":"uuid"},"scope":{"type":"string"},"status":{"type":"string","enum":["running","done","failed","refused"]},"mode":{"type":"string","enum":["auto","notify","conditions"]},"reason":{"type":["string","null"]},"result":{"type":["object","null"]},"error":{"type":["string","null"]},"created_at":{"type":"string"}}},"Page":{"type":"object","example":{"page":1,"per_page":20,"next_page":2},"properties":{"page":{"type":"integer"},"per_page":{"type":"integer"},"next_page":{"type":["integer","null"]}}},"Error":{"type":"object","example":{"error":"insufficient_scope","message":"The merchant has not granted this permission to the app.","required":"orders.read"},"required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"},"required":{"type":"string"}}}}}}