{"openapi":"3.0.3","info":{"title":"Basmtak Cashier Partner API","version":"v1","description":"Read sales and the catalogue, write items, send orders to the till and receive signed webhooks. Money is always integer halalas (1 SAR = 100). Errors are JSON {error, message, details}; the message follows Accept-Language (ar or en). Lists answer {data, meta}.\n","contact":{"name":"Basmtak support","email":"support@basmtak.com"}},"servers":[{"url":"/api/partner/v1"}],"security":[{"bearer":[]}],"tags":[{"name":"meta","description":"Connectivity"},{"name":"catalogue","description":"Branches, categories, items, price lists and customers"},{"name":"sales","description":"Receipts, Z-reports and stock"},{"name":"orders","description":"Orders sent to the till's incoming-orders panel"},{"name":"webhooks","description":"REST hooks (Zapier and Make)"}],"paths":{"/ping":{"get":{"tags":["meta"],"operationId":"ping","summary":"Check the token and see the client's abilities","x-ability":"any","responses":{"200":{"description":"The client, its abilities and the account"},"401":{"$ref":"#/components/responses/Error"}}}},"/branches":{"get":{"tags":["catalogue"],"operationId":"listBranches","summary":"List branches","x-ability":"pos:read","parameters":[{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/per_page"}],"responses":{"200":{"description":"A page of branches","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BranchPage"}}}}}}},"/categories":{"get":{"tags":["catalogue"],"operationId":"listCategories","summary":"List categories","x-ability":"pos:read","parameters":[{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/per_page"}],"responses":{"200":{"description":"A page of categories"}}}},"/items":{"get":{"tags":["catalogue"],"operationId":"listItems","summary":"List items with their variants","description":"Each variant carries `plu` (V + variant id), the reference to use in orders.","x-ability":"pos:read","parameters":[{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/per_page"},{"name":"category_id","in":"query","schema":{"type":"integer"}},{"name":"updated_since","in":"query","description":"ISO-8601; only items changed since then","schema":{"type":"string","format":"date-time"}},{"name":"sku","in":"query","schema":{"type":"string"}},{"name":"barcode","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"A page of items","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemPage"}}}}}},"post":{"tags":["catalogue"],"operationId":"createItem","summary":"Create an item (one payload with its variants)","description":"Same payload as the back office. Barcodes and SKUs are unique per account. Without variants one default variant is made at default_price_halalas.","x-ability":"pos:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemWrite"},"example":{"name_ar":"كابتشينو","name_en":"Cappuccino","category_id":3,"variants":[{"name_ar":"صغير","sku":"CAP-S","price_halalas":1400,"is_default":true},{"name_ar":"كبير","sku":"CAP-L","price_halalas":1800}]}}}},"responses":{"201":{"description":"The item","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Item"}}}}}},"403":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"}}}},"/items/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["catalogue"],"operationId":"getItem","summary":"One item","x-ability":"pos:read","responses":{"200":{"description":"The item"},"404":{"$ref":"#/components/responses/Error"}}},"put":{"tags":["catalogue"],"operationId":"updateItem","summary":"Update an item","description":"Arrays present in the body (variants, modifier_group_ids, combo_slots) replace what is stored; rows without id are created, missing ids are deleted. Arrays absent are untouched.","x-ability":"pos:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemWrite"}}}},"responses":{"200":{"description":"The item"},"422":{"$ref":"#/components/responses/Error"}}}},"/price-lists":{"get":{"tags":["catalogue"],"operationId":"listPriceLists","summary":"Price lists with their prices","x-ability":"pos:read","parameters":[{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/per_page"}],"responses":{"200":{"description":"A page of price lists"}}}},"/customers":{"get":{"tags":["catalogue"],"operationId":"listCustomers","summary":"Customers (consented fields only)","description":"Name, phone, email and address are returned only while the customer's marketing consent is granted (PDPL); otherwise they are null. VAT and CR numbers are always returned.","x-ability":"pos:read","parameters":[{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/per_page"},{"name":"updated_since","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"consented_only","in":"query","description":"Only customers whose latest marketing consent in the consent ledger is granted (never erased ones).","schema":{"type":"boolean"}},{"name":"consent_channel","in":"query","description":"With consented_only, only consents that cover this channel.","schema":{"type":"string","enum":["sms","whatsapp","email"]}}],"responses":{"200":{"description":"A page of customers","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}}}}}}}}}},"/receipts":{"get":{"tags":["sales"],"operationId":"listReceipts","summary":"Receipts and credit notes, oldest first, with a since_id cursor","description":"Pass the last receipt id you saw as since_id to get what arrived after it; meta.next_since_id is the value for the next call and meta.has_more says whether to call again now. The order is the server's arrival order, so receipts a till sold offline and synced later are never skipped. Receipts that arrived in the last few seconds are held back.\n","x-ability":"pos:read","parameters":[{"name":"since_id","in":"query","schema":{"type":"string"}},{"name":"branch_id","in":"query","schema":{"type":"integer"}},{"name":"kind","in":"query","schema":{"type":"string","enum":["simplified","standard","credit_note"]}},{"$ref":"#/components/parameters/per_page"}],"responses":{"200":{"description":"Receipts after the cursor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReceiptCursorPage"}}}},"422":{"$ref":"#/components/responses/Error"}}}},"/receipts/{id}":{"get":{"tags":["sales"],"operationId":"getReceipt","summary":"One receipt or credit note","x-ability":"pos:read","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The receipt","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Receipt"}}}}}},"404":{"$ref":"#/components/responses/Error"}}}},"/sessions/{id}/z-report":{"get":{"tags":["sales"],"operationId":"getZReport","summary":"The Z-report of a closed till session","description":"The Z as stored at close; deposits already invoiced are netted (prepayments_applied).","x-ability":"pos:read","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The session with z_report, expected and counted","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ZReportSession"}}}}}},"409":{"$ref":"#/components/responses/Error"}}}},"/stock/levels":{"get":{"tags":["sales"],"operationId":"listStockLevels","summary":"Stock on hand per branch and variant","x-ability":"pos:read","parameters":[{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/per_page"},{"name":"branch_id","in":"query","schema":{"type":"integer"}},{"name":"variant_id","in":"query","schema":{"type":"integer"}},{"name":"low_only","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"A page of stock levels"}}}},"/orders":{"post":{"tags":["orders"],"operationId":"createOrder","summary":"Send an order to the till","description":"The order appears on the branch till's incoming-orders panel; the cashier accepts it and the receipt is issued on the till. Idempotent on external_id per API client: a retry answers 200 with duplicate true. Lines reference a variant by variant_id, or plu / sku / barcode; a line nothing matches stays an open item with your name and price. Prices are VAT-inclusive halalas; a line without a price takes the catalogue price. Status changes come back as order.status_changed webhooks.\n","x-ability":"pos:orders","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderWrite"},"example":{"external_id":"web-1001","branch_id":1,"order_type":"pickup","prepaid":true,"customer":{"name":"Noura","phone":"+966501234567"},"lines":[{"variant_id":21,"qty":2,"unit_price_halalas":1800}]}}}},"responses":{"201":{"description":"The order","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Order"},"duplicate":{"type":"boolean"}}}}}},"200":{"description":"The same order again (a retry)"},"422":{"$ref":"#/components/responses/Error"}}}},"/orders/{id}":{"get":{"tags":["orders"],"operationId":"getOrder","summary":"The status of one of your orders","x-ability":"pos:orders","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The order"},"404":{"$ref":"#/components/responses/Error"}}}},"/orders/{id}/cancel":{"post":{"tags":["orders"],"operationId":"cancelOrder","summary":"Cancel one of your orders","description":"Withdraws the order from the till's incoming-orders panel. Cancelling an order that is already cancelled answers the same order again. If the till already issued its receipt, the receipt stands and the cashier is asked to decide on a refund.","x-ability":"pos:orders","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":200}}}}}},"responses":{"200":{"description":"The order, now cancelled","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Order"}}}}}},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"}}}},"/webhooks":{"get":{"tags":["webhooks"],"operationId":"listWebhooks","summary":"Your subscriptions","x-ability":"pos:webhooks","responses":{"200":{"description":"A page of subscriptions"}}},"post":{"tags":["webhooks"],"operationId":"subscribeWebhook","summary":"Subscribe (REST hook)","description":"The answer carries the subscription id and its signing secret. The secret is shown only here.","x-ability":"pos:webhooks","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"target_url":{"type":"string","description":"HTTPS on a public address"},"event":{"type":"string","enum":["receipt.issued","credit_note.issued","session.closed","stock.low","order.status_changed","customer.created"]},"events":{"type":"array","items":{"type":"string"}},"description":{"type":"string"}}},"example":{"target_url":"https://hooks.zapier.com/hooks/standard/123/abc","event":"receipt.issued"}}}},"responses":{"201":{"description":"{id, secret, data}"},"422":{"$ref":"#/components/responses/Error"}}}},"/webhooks/events":{"get":{"tags":["webhooks"],"operationId":"listWebhookEvents","summary":"The events, each with sample data","x-ability":"pos:webhooks","responses":{"200":{"description":"{data: [{event, sample}]}"}}}},"/webhooks/events/{event}/recent":{"get":{"tags":["webhooks"],"operationId":"listRecentWebhookEvents","summary":"Recent real objects of one event (REST hook perform list)","description":"The newest real objects of one event, each wrapped in the envelope a delivery carries {id, event, tenant_id, occurred_at, api_version, data}, newest first. Zapier calls this as the REST Hook trigger's perform list when a user tests a Zap; Make uses it to fetch sample data. id is event:object-id (stable, for de-duplication), not the uuid of a live delivery. For order.status_changed, from is null and to is the current status. Besides pos:webhooks the client needs the ability that receives the event (pos:read, or pos:orders for order.status_changed). meta.sample is the static sample, for an account with no data yet.\n","x-ability":"pos:webhooks","parameters":[{"name":"event","in":"path","required":true,"schema":{"type":"string","enum":["receipt.issued","credit_note.issued","session.closed","stock.low","order.status_changed","customer.created"]}},{"name":"limit","in":"query","description":"1 to 25, default 3","schema":{"type":"integer"}}],"responses":{"200":{"description":"{data: [{id, event, tenant_id, occurred_at, api_version, data}], meta: {event, count, sample}}"},"403":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"}}}},"/webhooks/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["webhooks"],"operationId":"getWebhook","summary":"One subscription","x-ability":"pos:webhooks","responses":{"200":{"description":"The subscription"}}},"delete":{"tags":["webhooks"],"operationId":"unsubscribeWebhook","summary":"Unsubscribe (REST hook)","x-ability":"pos:webhooks","responses":{"204":{"description":"Removed"},"404":{"$ref":"#/components/responses/Error"}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Authorization: Bearer bmc_… (or X-Api-Key)"}},"parameters":{"page":{"name":"page","in":"query","schema":{"type":"integer","minimum":1}},"per_page":{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":200}}},"responses":{"Error":{"description":"{error, message, details}","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"details":{"type":"object"}}},"Meta":{"type":"object","properties":{"total":{"type":"integer"},"page":{"type":"integer"},"per_page":{"type":"integer"}}},"Branch":{"type":"object","properties":{"id":{"type":"integer"},"code":{"type":"string"},"name_ar":{"type":"string"},"name_en":{"type":"string"},"is_active":{"type":"boolean"}}},"BranchPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Branch"}},"meta":{"$ref":"#/components/schemas/Meta"}}},"Variant":{"type":"object","properties":{"id":{"type":"integer"},"plu":{"type":"string"},"sku":{"type":"string"},"barcode":{"type":"string"},"price_halalas":{"type":"integer"},"is_default":{"type":"boolean"}}},"Item":{"type":"object","properties":{"id":{"type":"integer"},"category_id":{"type":"integer"},"name_ar":{"type":"string"},"name_en":{"type":"string"},"default_price_halalas":{"type":"integer"},"is_active":{"type":"boolean"},"variants":{"type":"array","items":{"$ref":"#/components/schemas/Variant"}}}},"ItemPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Item"}},"meta":{"$ref":"#/components/schemas/Meta"}}},"ItemWrite":{"type":"object","required":["name_ar"],"properties":{"name_ar":{"type":"string"},"name_en":{"type":"string"},"category_id":{"type":"integer"},"tax_rate_id":{"type":"integer"},"default_price_halalas":{"type":"integer"},"track_stock":{"type":"boolean"},"is_active":{"type":"boolean"},"external_ref":{"type":"string"},"variants":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"name_ar":{"type":"string"},"sku":{"type":"string"},"barcode":{"type":"string"},"price_halalas":{"type":"integer"},"is_default":{"type":"boolean"}}}}}},"Customer":{"type":"object","properties":{"id":{"type":"integer"},"marketing_consent":{"type":"boolean"},"consent_covers":{"type":"array","description":"The contact fields the consent covers; phone and email are null unless listed here.","items":{"type":"string","enum":["phone","email"]}},"name":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"vat_number":{"type":"string","nullable":true}}},"ReceiptLine":{"type":"object","properties":{"line_no":{"type":"integer"},"line_kind":{"type":"string","description":"item, or charge (a service / delivery charge line)"},"item_id":{"type":"integer","nullable":true},"variant_id":{"type":"integer","nullable":true},"name":{"type":"string"},"name_secondary":{"type":"string","nullable":true},"qty":{"type":"string"},"unit_code":{"type":"string","nullable":true},"unit_price_halalas":{"type":"integer"},"discount_halalas":{"type":"integer"},"tax_code":{"type":"string"},"tax_rate":{"type":"number"},"net_halalas":{"type":"integer"},"tax_halalas":{"type":"integer"},"total_halalas":{"type":"integer"},"modifiers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"price_delta_halalas":{"type":"integer"}}}}}},"Receipt":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"kind":{"type":"string","enum":["simplified","standard","credit_note"]},"uuid":{"type":"string"},"refund_of":{"type":"string","nullable":true},"branch_id":{"type":"integer"},"register_id":{"type":"integer"},"session_id":{"type":"string","nullable":true},"cashier_id":{"type":"integer","nullable":true},"customer_id":{"type":"integer","nullable":true},"ticket_id":{"type":"string","nullable":true},"order_type":{"type":"string","nullable":true},"channel":{"type":"string","nullable":true},"currency":{"type":"string","description":"SAR or AED; every …_halalas amount is in this currency's minor unit (halalas / fils)"},"issued_at":{"type":"string","format":"date-time"},"business_date":{"type":"string","format":"date"},"subtotal_halalas":{"type":"integer"},"discount_halalas":{"type":"integer"},"tax_halalas":{"type":"integer"},"total_halalas":{"type":"integer"},"rounding_halalas":{"type":"integer"},"tip_halalas":{"type":"integer"},"prepaid_applied":{"type":"object","nullable":true,"description":"The part of this final invoice already paid on a deposit invoice (gross, taxable, tax)"},"amount_due_halalas":{"type":"integer","description":"total_halalas minus prepaid_applied.gross_halalas"},"tax_breakdown":{"type":"array","items":{"type":"object"}},"buyer":{"type":"object","nullable":true,"description":"The business buyer of a standard (B2B) invoice (name, vat_number, cr_number); null on a simplified receipt"},"zatca_status":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/ReceiptLine"}},"payments":{"type":"array","items":{"type":"object","properties":{"tender":{"type":"string"},"amount_halalas":{"type":"integer"},"tip_halalas":{"type":"integer"},"scheme":{"type":"string"},"last4":{"type":"string"},"channel":{"type":"string","nullable":true}}}}}},"Session":{"type":"object","description":"A till session (the session.closed event and GET sessions/{id}/z-report). Three net-sales figures sit side by side: net_sales_halalas keeps its published meaning — sales minus returns WITH VAT, as stored on the Z (the same number as sales_incl_vat_halalas); net_sales_ex_vat_halalas is the app's «صافي المبيعات» (without VAT), the figure the back office and the royalty basis use. Null while the session has no Z.\n","properties":{"id":{"type":"string"},"branch_id":{"type":"integer"},"register_id":{"type":"integer"},"status":{"type":"string"},"business_date":{"type":"string","format":"date","nullable":true},"opened_at":{"type":"string","format":"date-time"},"closed_at":{"type":"string","format":"date-time","nullable":true},"closed_via":{"type":"string","nullable":true},"opening_float_halalas":{"type":"integer"},"variance_halalas":{"type":"integer","nullable":true},"receipts":{"type":"integer","nullable":true},"total_halalas":{"type":"integer","nullable":true},"net_sales_halalas":{"type":"integer","nullable":true,"description":"Sales minus returns INCLUDING VAT (legacy meaning, kept for existing integrations)"},"sales_incl_vat_halalas":{"type":"integer","nullable":true,"description":"The same figure as net_sales_halalas, named"},"net_sales_ex_vat_halalas":{"type":"integer","nullable":true,"description":"Net sales WITHOUT VAT («صافي المبيعات») — use this one for revenue"}}},"ZReportSession":{"allOf":[{"$ref":"#/components/schemas/Session"},{"type":"object","properties":{"z_report":{"type":"object","description":"The Z as stored at close; deposits already invoiced are netted (prepayments_applied)"},"expected":{"type":"object","nullable":true},"counted":{"type":"object","nullable":true}}}]},"ReceiptCursorPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Receipt"}},"meta":{"type":"object","properties":{"per_page":{"type":"integer"},"count":{"type":"integer"},"next_since_id":{"type":"string","nullable":true},"has_more":{"type":"boolean"}}}}},"OrderWrite":{"type":"object","required":["external_id","lines"],"properties":{"external_id":{"type":"string"},"display_id":{"type":"string"},"branch_id":{"type":"integer"},"order_type":{"type":"string","enum":["pickup","delivery","takeaway"]},"prepaid":{"type":"boolean"},"discount_halalas":{"type":"integer"},"delivery_fee_halalas":{"type":"integer","description":"The delivery fee the customer paid, VAT-inclusive; added to the order as a charge line"},"scheduled_at":{"type":"string","format":"date-time"},"note":{"type":"string"},"source":{"type":"string"},"customer":{"type":"object","properties":{"name":{"type":"string"},"phone":{"type":"string"},"address":{"type":"string"}}},"lines":{"type":"array","items":{"type":"object","required":["qty"],"properties":{"variant_id":{"type":"integer"},"plu":{"type":"string"},"sku":{"type":"string"},"barcode":{"type":"string"},"name":{"type":"string"},"qty":{"type":"number"},"unit_price_halalas":{"type":"integer"},"note":{"type":"string"},"modifiers":{"type":"array","items":{"type":"object"}}}}}}},"Order":{"type":"object","properties":{"id":{"type":"string"},"external_id":{"type":"string"},"provider":{"type":"string"},"status":{"type":"string","enum":["received","accepted","rejected","ready","dispatched","cancelled"]},"total_halalas":{"type":"integer"},"unmatched_count":{"type":"integer"},"receipt_id":{"type":"string","nullable":true}}}}},"x-webhook-events":["receipt.issued","credit_note.issued","session.closed","stock.low","order.status_changed","customer.created"]}