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}.
التنزيلات
الملفات الثلاثة مولّدة من ملف OpenAPI نفسه الذي تُبنى منه هذه الصفحة، فتطابق الواجهة الفعلية دائمًا. لا تحتاج إلى تسجيل دخول.
استوردها في Postman، واضبط المتغير {{token}} على رمز عميلك، ثم شغّل أي طلب. طلب «Subscribe» يحفظ {{webhook_id}} و {{webhook_secret}}، ومجلد «Webhook signature» يوقّع إشعارًا تجريبيًا ويرسله إلى {{receiver_url}} لتختبر مستقبِلك قبل وقوع أي حدث حقيقي.
المصادقة
ينشئ المالك أو المدير عميل واجهة من لوحة الإدارة ← المطورون ويختار صلاحياته. يظهر الرمز مرة واحدة. أرسله مع كل طلب:
يمكن أيضًا إرسال الرمز في الترويسة X-Api-Key. الطلب GET /ping يعيد العميل وصلاحياته والحساب؛ استخدمه لاختبار الاتصال.
الصلاحيات
كل نقطة تحتاج صلاحية واحدة؛ الطلب بدونها يعيد 403 insufficient_ability ومعه details.required_ability. الصلاحية pos:webhooks تدير الاشتراكات فقط: لاستقبال حدث أو عرض أحدث عناصره يحتاج العميل أيضًا الصلاحية التي تقرأ تلك البيانات.
الصلاحية
النقاط
any
GET /ping
pos:read
GET /branches · GET /categories · GET /items · GET /items/{id} · GET /price-lists · GET /customers · GET /receipts · GET /receipts/{id} · GET /sessions/{id}/z-report · GET /stock/levels
pos:write
POST /items · PUT /items/{id}
pos:orders
POST /orders · GET /orders/{id} · POST /orders/{id}/cancel
pos:webhooks
GET /webhooks · POST /webhooks · GET /webhooks/events · GET /webhooks/events/{event}/recent · GET /webhooks/{id} · DELETE /webhooks/{id}
حد الطلبات
120 طلبًا في الدقيقة لكل عميل واجهة. الرد 429 يحمل Retry-After، وكل رد يحمل X-RateLimit-Limit و X-RateLimit-Remaining.
الطلبات التي لا يطابق رمزها عميلًا نشطًا تتشارك حدًّا لكل عنوان قدره 30 طلبًا في الدقيقة. والباقة التي لا تشمل واجهة الشركاء تعيد 403 not_entitled.
الأخطاء
كل خطأ JSON بالشكل {error, message, details}، والرسالة بلغة Accept-Language (ar أو en). المبالغ أعداد صحيحة بالهللة دائمًا (1 ريال = 100).
GET /receipts يبدأ بالأقدم ويتنقّل بالمؤشر: أرسل meta.next_since_id من الرد السابق في ?since_id= حتى تصبح meta.has_more خطأ (false). الترتيب هو ترتيب وصول الإيصالات إلى الخادم، فالبيع الذي تم دون اتصال ثم زُامن لاحقًا لا يُتخطّى أبدًا. الإيصالات التي وصلت في آخر 5 ثوانٍ تُؤجَّل حتى تكتمل الدفعة التي كتبتها.
الطلب POST /orders لا يتكرر بحسب external_id لكل عميل واجهة: إرسال الطلب نفسه مرة أخرى يعيد 200 مع duplicate: true والطلب نفسه، ولا تظهر تذكرة ثانية على الكاشير. إلغاء الطلب مرتين لا يغيّر شيئًا. باقي عمليات الكتابة لا تأخذ مفتاح عدم تكرار: عند انتهاء المهلة اقرأ قبل أن تعيد المحاولة (GET /items?sku=…). قد يصل الإشعار أكثر من مرة: أسقط المكرر بحسب X-Basmtak-Event-Id (الحقل id في الجسم).
الإشعارات (REST hooks)
اشترك عبر POST /webhooks {target_url, event} وألغِ عبر DELETE /webhooks/{id} — نمط Zapier و Make. كل إشعار طلب POST بالشكل {id, event, tenant_id, occurred_at, api_version, data}، ويُعاد بتأخير متضاعف؛ 20 إخفاقًا متتاليًا (أو رد 410) توقف الاشتراك.
شكل الإشعار
طلب POST بنوع المحتوى application/json وجسم {id, event, tenant_id, occurred_at, api_version, data}، والحقل data بالشكل نفسه الذي تعيده الواجهة لذلك العنصر. الترويسات: X-Basmtak-Event و X-Basmtak-Event-Id و X-Basmtak-Delivery و X-Basmtak-Timestamp و X-Basmtak-Signature.
التحقق من الإشعار
X-Basmtak-Signature = "sha256=" + HMAC-SHA256 بصيغة hex بالسر على (X-Basmtak-Timestamp + "\n" + "POST" + "\n" + المسار + "\n" + SHA-256 للجسم الخام بصيغة hex). ارفض الطوابع الأقدم من خمس دقائق. X-Basmtak-Event-Id فريد لكل حدث؛ استخدمه لإسقاط المكرر.
مثال محسوب
بهذه المدخلات يجب أن ينتج كودك هذا التوقيع بالضبط (يُحسب مباشرة بالكود نفسه الذي يوقّع الإشعارات الحقيقية). استخدم السر كما استلمته تمامًا بما فيه whsec_، والجسم الخام كما وصل قبل أي تحليل JSON.
أي رد 2xx خلال 10 ثوانٍ يُعد نجاحًا. وما عداه (رمز آخر أو انتهاء المهلة أو عنوان مرفوض) يُعاد بعد 60 ثانية ويتضاعف التأخير كل مرة حتى 6 ساعات؛ وبعد 10 محاولات يُترك الإشعار. 20 إخفاقًا متتاليًا توقف الاشتراك، ورد 410 Gone يوقفه فورًا (طريقة REST hooks لإلغاء الاشتراك). نحفظ رمز الحالة فقط، ولا نحفظ جسم ردّك.
الأحداث
receipt.issuedالصلاحية اللازمة للاستقبال: pos:read
يجب أن يكون رابط الاستقبال HTTPS على عنوان عام (وروابط hooks.zapier.com و hook.*.make.com كذلك). أما الإجراءات (إنشاء طلب، إنشاء صنف أو تعديله) وعمليات البحث (صنف بحسب sku أو الباركود، عميل) فتستدعي النقاط أدناه مباشرة.
نقاط الوصول
meta Connectivity
GET/pingCheck the token and see the client's abilitiesالصلاحية: any
الردود
200
The client, its abilities and the account
401
{error, message, details}
Error
catalogue Branches, categories, items, price lists and customers
GET/branchesList branchesالصلاحية: pos:read
المعاملات
page
query
integer
per_page
query
integer
الردود
200
A page of branches
BranchPage
GET/categoriesList categoriesالصلاحية: pos:read
المعاملات
page
query
integer
per_page
query
integer
الردود
200
A page of categories
GET/itemsList items with their variantsالصلاحية: pos:read
Each variant carries `plu` (V + variant id), the reference to use in orders.
المعاملات
page
query
integer
per_page
query
integer
category_id
query
integer
updated_since
query
string
ISO-8601; only items changed since then
sku
query
string
barcode
query
string
الردود
200
A page of items
ItemPage
POST/itemsCreate an item (one payload with its variants)الصلاحية: pos:write
Same payload as the back office. Barcodes and SKUs are unique per account. Without variants one default variant is made at default_price_halalas.
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.
المعاملات
id
path
integer · required
جسم الطلب ItemWrite
الردود
200
The item
422
{error, message, details}
Error
GET/price-listsPrice lists with their pricesالصلاحية: pos:read
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.
المعاملات
page
query
integer
per_page
query
integer
updated_since
query
string
consented_only
query
boolean
Only customers whose latest marketing consent in the consent ledger is granted (never erased ones).
consent_channel
query
string
With consented_only, only consents that cover this channel.
الردود
200
A page of customers
object
sales Receipts, Z-reports and stock
GET/receiptsReceipts and credit notes, oldest first, with a since_id cursorالصلاحية: pos:read
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.
المعاملات
since_id
query
string
branch_id
query
integer
kind
query
string
per_page
query
integer
الردود
200
Receipts after the cursor
ReceiptCursorPage
422
{error, message, details}
Error
GET/receipts/{id}One receipt or credit noteالصلاحية: pos:read
المعاملات
id
path
string · required
الردود
200
The receipt
object
404
{error, message, details}
Error
GET/sessions/{id}/z-reportThe Z-report of a closed till sessionالصلاحية: pos:read
The Z as stored at close; deposits already invoiced are netted (prepayments_applied).
المعاملات
id
path
string · required
الردود
200
The session with z_report, expected and counted
object
409
{error, message, details}
Error
GET/stock/levelsStock on hand per branch and variantالصلاحية: pos:read
المعاملات
page
query
integer
per_page
query
integer
branch_id
query
integer
variant_id
query
integer
low_only
query
boolean
الردود
200
A page of stock levels
orders Orders sent to the till's incoming-orders panel
POST/ordersSend an order to the tillالصلاحية: pos:orders
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.
GET/orders/{id}The status of one of your ordersالصلاحية: pos:orders
المعاملات
id
path
string · required
الردود
200
The order
404
{error, message, details}
Error
POST/orders/{id}/cancelCancel one of your ordersالصلاحية: pos:orders
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.
GET/webhooks/eventsThe events, each with sample dataالصلاحية: pos:webhooks
الردود
200
{data: [{event, sample}]}
GET/webhooks/events/{event}/recentRecent real objects of one event (REST hook perform list)الصلاحية: pos:webhooks
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.