Basmtak Cashier developer platform

Partner API v1: read sales and catalogue, write items, send orders to the till, receive signed webhooks.

العربية

Base URL https://cashier.basmtak.com/api/partner/v1 · OpenAPI 3.0.3 · Download the OpenAPI file

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

Downloads

All three are generated from the same OpenAPI file as this page, so they always match the live API. No sign-in is needed.

OpenAPI 3 (YAML) · OpenAPI 3 (JSON) · Postman collection (v2.1)

Import it into Postman, set the {{token}} variable to your client token and run any request. «Subscribe» stores {{webhook_id}} and {{webhook_secret}}; the «Webhook signature» folder signs a sample delivery and sends it to {{receiver_url}}, so you can test your receiver before a real event happens.

Authentication

An account owner or manager creates an API client under Back office → Developers and chooses its abilities. The token is shown once. Send it on every call:

curl -H "Authorization: Bearer bmc_…" -H "Accept-Language: ar" https://cashier.basmtak.com/api/partner/v1/ping

The token can also be sent as X-Api-Key. GET /ping answers the client, its abilities and the account: use it as the «test connection» call.

Abilities

Each endpoint needs one ability; a call without it answers 403 insufficient_ability with details.required_ability. pos:webhooks only manages subscriptions: to receive an event, or list its recent objects, the client also needs the ability that reads that data.

AbilityEndpoints
anyGET /ping
pos:readGET /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:writePOST /items · PUT /items/{id}
pos:ordersPOST /orders · GET /orders/{id} · POST /orders/{id}/cancel
pos:webhooksGET /webhooks · POST /webhooks · GET /webhooks/events · GET /webhooks/events/{event}/recent · GET /webhooks/{id} · DELETE /webhooks/{id}

Rate limit

120 requests a minute per API client. A 429 answer carries Retry-After; every answer carries X-RateLimit-Limit and X-RateLimit-Remaining.

Calls whose token matches no active client share a per-address limit of 30 a minute. A plan without the Partner API feature answers 403 not_entitled.

Errors

Every error is JSON {error, message, details}; the message follows Accept-Language (ar or en). Money is always integer halalas (1 SAR = 100).

{"error": "insufficient_ability", "message": "…", "details": {"required_ability": "pos:write"}}
CodeHTTPMeaning
unauthenticated401Missing API token. Send it as "Authorization: Bearer bmc_…".
token_invalid401This API token is not valid or was revoked.
tenant_inactive403This account is suspended or closed.
not_entitled403The account's plan does not include the Partner API.
insufficient_ability403This API client does not have the ability this call needs.
not_found404Not found.
session_open409The session is still open; its Z-report exists once it closes.
order_rejected409The till already rejected this order; it cannot be cancelled.
client_revoked409This API client was revoked.
validation_failed422Some fields are not valid.
cursor_unknown422The since_id cursor does not name a receipt of this account.
branch_unknown422The branch does not exist or is inactive.
branch_unresolved422Name the branch (branch_id): this account has several.
payload_invalid422The order is incomplete.
event_unknown422Unknown webhook event.
url_not_allowed422This URL cannot receive webhooks (HTTPS on a public address only).
webhook_limit422Too many webhook subscriptions.
rate_limited429Too many requests. Try again shortly.

Item writes (POST /items, PUT /items/{id}) also use the catalogue's own codes, for example barcode_taken.

Pagination

Lists answer {data, meta: {total, page, per_page}}. Use ?page= and ?per_page= (default 50, at most 200).

{"data": [ … ], "meta": {"total": 312, "page": 2, "per_page": 50}}

Receipts: the since_id cursor

GET /receipts is oldest first and pages by cursor: pass the meta.next_since_id of the previous answer as ?since_id= until meta.has_more is false. The order is the order receipts reached the server, so a sale made offline and synced later is never skipped. Receipts that arrived in the last 5 seconds are held back until the batch that wrote them has finished.

GET https://cashier.basmtak.com/api/partner/v1/receipts?since_id=01J9ZK3Q7R8S9T0V1W2X3Y4Z5A&per_page=100
{"data": [ … ], "meta": {"per_page": 100, "count": 100, "next_since_id": "01J9ZM…", "has_more": true}}

Retries and idempotency

POST /orders is idempotent on external_id per API client: sending the same order again answers 200 with duplicate: true and the same order, never a second ticket on the till. Cancelling an order twice is a no-op. Other writes take no idempotency key: on a timeout, read before you retry (GET /items?sku=…). Webhook deliveries may arrive more than once: drop repeats by X-Basmtak-Event-Id (the body's id).

Webhooks (REST hooks)

Subscribe with POST /webhooks {target_url, event} and unsubscribe with DELETE /webhooks/{id} — the Zapier and Make REST-hook pattern. Each delivery is a POST of {id, event, tenant_id, occurred_at, api_version, data}, retried with exponential backoff; 20 failures in a row (or a 410 answer) switch the subscription off.

What a delivery looks like

A POST with Content-Type application/json and the body {id, event, tenant_id, occurred_at, api_version, data}; data has the same shape the API returns for that object. Headers: X-Basmtak-Event, X-Basmtak-Event-Id, X-Basmtak-Delivery, X-Basmtak-Timestamp and X-Basmtak-Signature.

Verifying a delivery

X-Basmtak-Signature = "sha256=" + hex HMAC-SHA256(secret, X-Basmtak-Timestamp + "\n" + "POST" + "\n" + path + "\n" + hex SHA-256(raw body)). Reject timestamps older than five minutes. X-Basmtak-Event-Id is unique per event — use it to drop duplicates.

Worked example

With these inputs your code must produce exactly this signature (computed live by the code that signs real deliveries). Use the secret exactly as you received it, including whsec_, and the raw body bytes, before any JSON parsing.

Secretwhsec_example0000000000000000000000000000000000
X-Basmtak-Timestamp1798761600
Path of your URL (no query string)/hooks/standard/123/abc
Raw body{"id":"7d3f0c52-1a4b-4c8e-9f21-6b0d2e5a9c11","event":"ping","tenant_id":1,"occurred_at":"2027-01-01T03:00:00+03:00","api_version":"v1","data":{}}
SHA-256 of the body (hex)d950161f336317f2a060361c620449e231a81b783e5ad56dd34940641a0219b6
Canonical string (lines joined by \n)
1798761600
POST
/hooks/standard/123/abc
d950161f336317f2a060361c620449e231a81b783e5ad56dd34940641a0219b6
X-Basmtak-Signaturesha256=ced5fbb70b35667445f95e9f3e74b1db659649cbbc99eec039b69d010ccead26
// Node.js (Express: app.use(express.raw({type: 'application/json'})))
const crypto = require('crypto');
function verify(req, secret) {
  const ts = req.get('X-Basmtak-Timestamp');
  if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const path = req.originalUrl.split('?')[0];
  const canonical = ts + "\nPOST\n" + path + "\n" + crypto.createHash('sha256').update(req.body).digest('hex');
  const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(canonical).digest('hex');
  const given = req.get('X-Basmtak-Signature') || '';
  return given.length === expected.length && crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}
<?php // PHP
$body = file_get_contents('php://input');
$ts = $_SERVER['HTTP_X_BASMTAK_TIMESTAMP'] ?? '';
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$canonical = $ts . "\nPOST\n" . $path . "\n" . hash('sha256', $body);
$ok = ctype_digit($ts) && abs(time() - (int) $ts) <= 300
   && hash_equals('sha256=' . hash_hmac('sha256', $canonical, $secret), $_SERVER['HTTP_X_BASMTAK_SIGNATURE'] ?? '');
# Python
import hashlib, hmac, time
def verify(secret: str, ts: str, path: str, body: bytes, signature: str) -> bool:
    if not ts.isdigit() or abs(time.time() - int(ts)) > 300:
        return False
    canonical = f"{ts}\nPOST\n{path}\n{hashlib.sha256(body).hexdigest()}"
    expected = "sha256=" + hmac.new(secret.encode(), canonical.encode(), hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)

Retries and switching off

Any 2xx answer within 10 seconds is a success. Anything else (another status, a timeout, a refused address) is retried after 60 seconds, doubling each time up to 6 hours; after 10 attempts the delivery is given up. 20 failed attempts in a row switch the subscription off, and a 410 Gone answer switches it off at once (the REST-hook way to unsubscribe). Only the status code is kept, never your answer's body.

Events

receipt.issued Ability to receive: pos:read

Sample data

{
    "id": "01J9ZK3Q7R8S9T0V1W2X3Y4Z5A",
    "number": "R1-418",
    "kind": "simplified",
    "branch_id": 1,
    "register_id": 3,
    "session_id": "01J9ZJ0000000000000000000S",
    "issued_at": "2027-04-02T18:21:07+03:00",
    "business_date": "2027-04-02",
    "currency": "SAR",
    "subtotal_halalas": 3130,
    "tax_halalas": 470,
    "total_halalas": 3600,
    "prepaid_applied": null,
    "amount_due_halalas": 3600,
    "lines": [
        {
            "line_no": 1,
            "variant_id": 21,
            "name": "كابتشينو كبير",
            "qty": "2",
            "unit_price_halalas": 1800,
            "total_halalas": 3600
        }
    ],
    "payments": [
        {
            "tender": "card",
            "amount_halalas": 3600,
            "scheme": "mada",
            "last4": "4242"
        }
    ]
}
credit_note.issued Ability to receive: pos:read

Sample data

{
    "kind": "credit_note",
    "refund_of": "01J9ZK3Q7R8S9T0V1W2X3Y4Z5A",
    "total_halalas": 1800,
    "id": "01J9ZK3Q7R8S9T0V1W2X3Y4Z5A",
    "number": "R1-418",
    "branch_id": 1,
    "register_id": 3,
    "session_id": "01J9ZJ0000000000000000000S",
    "issued_at": "2027-04-02T18:21:07+03:00",
    "business_date": "2027-04-02",
    "currency": "SAR",
    "subtotal_halalas": 3130,
    "tax_halalas": 470,
    "prepaid_applied": null,
    "amount_due_halalas": 3600,
    "lines": [
        {
            "line_no": 1,
            "variant_id": 21,
            "name": "كابتشينو كبير",
            "qty": "2",
            "unit_price_halalas": 1800,
            "total_halalas": 3600
        }
    ],
    "payments": [
        {
            "tender": "card",
            "amount_halalas": 3600,
            "scheme": "mada",
            "last4": "4242"
        }
    ]
}
session.closed Ability to receive: pos:read

Sample data

{
    "id": "01J9ZJ0000000000000000000S",
    "branch_id": 1,
    "register_id": 3,
    "status": "closed",
    "business_date": "2027-04-02",
    "receipts": 57,
    "total_halalas": 412300,
    "net_sales_halalas": 412300,
    "sales_incl_vat_halalas": 412300,
    "net_sales_ex_vat_halalas": 358522,
    "variance_halalas": -50,
    "z_report": {
        "sales": {
            "total_halalas": 412300
        }
    }
}
stock.low Ability to receive: pos:read

Sample data

{
    "branch_id": 1,
    "variant_id": 21,
    "sku": "MILK-1L",
    "name_ar": "حليب ١ لتر",
    "qty": "3.0000",
    "reorder_point": "5.0000",
    "suggested_qty": "7.0000"
}
order.status_changed Ability to receive: pos:orders

Sample data

{
    "from": "received",
    "to": "accepted",
    "id": "01J9ZM0000000000000000000O",
    "external_id": "web-1001",
    "provider": "partner:4",
    "status": "accepted",
    "total_halalas": 5400
}
customer.created Ability to receive: pos:read

Sample data

{
    "id": 77,
    "marketing_consent": true,
    "name": "نورة",
    "phone": "+966501234567",
    "email": null,
    "vat_number": null
}

REST hooks for Zapier and Make

The API offers everything the Zapier REST Hook trigger and Make's instant (webhook) trigger need. Authentication is an API key sent as a bearer token.

StepCallAnswer
Test connectionGET /ping200 with the client, its abilities and the account
SubscribePOST /webhooks {"target_url": "…", "event": "receipt.issued"}201 {id, secret, data}; keep id for unsubscribing (the secret is shown only here)
UnsubscribeDELETE /webhooks/{id}204; a 410 Gone answer from your hook URL does the same
Perform list (sample data)GET /webhooks/events/{event}/recent?limit=3the newest real objects of that event, in the delivery envelope; meta.sample is a static sample for an empty account
Event listGET /webhooks/eventsevery event with a sample
curl -X POST https://cashier.basmtak.com/api/partner/v1/webhooks -H "Authorization: Bearer bmc_…" -H "Content-Type: application/json" \
     -d '{"target_url": "https://hooks.zapier.com/hooks/standard/123/abc", "event": "receipt.issued"}'
{"id": 41, "secret": "whsec_…", "data": {"id": 41, "event": "receipt.issued", "target_url": "https://hooks.zapier.com/hooks/standard/123/abc", …}}

curl https://cashier.basmtak.com/api/partner/v1/webhooks/events/receipt.issued/recent?limit=1 -H "Authorization: Bearer bmc_…"
{"data": [{"id": "receipt.issued:01J9ZK…", "event": "receipt.issued", "tenant_id": 7, "occurred_at": "…", "api_version": "v1", "data": {…}}], "meta": {"event": "receipt.issued", "count": 1, "sample": {…}}}

curl -X DELETE https://cashier.basmtak.com/api/partner/v1/webhooks/41 -H "Authorization: Bearer bmc_…"   # 204

The hook URL must be HTTPS on a public address (hooks.zapier.com and hook.*.make.com are). A Zap or scenario that only needs actions (create an order, create or update an item) or searches (find an item by sku or barcode, find a customer) calls the endpoints below directly.

Endpoints

meta Connectivity
GET /ping Check the token and see the client's abilities Ability: any

Responses

200The client, its abilities and the account
401{error, message, details}Error
catalogue Branches, categories, items, price lists and customers
GET /branches List branches Ability: pos:read

Parameters

pagequeryinteger
per_pagequeryinteger

Responses

200A page of branchesBranchPage
GET /categories List categories Ability: pos:read

Parameters

pagequeryinteger
per_pagequeryinteger

Responses

200A page of categories
GET /items List items with their variants Ability: pos:read

Each variant carries `plu` (V + variant id), the reference to use in orders.

Parameters

pagequeryinteger
per_pagequeryinteger
category_idqueryinteger
updated_sincequerystringISO-8601; only items changed since then
skuquerystring
barcodequerystring

Responses

200A page of itemsItemPage
POST /items Create an item (one payload with its variants) Ability: 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.

Request body ItemWrite

{
    "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

201The itemobject
403{error, message, details}Error
422{error, message, details}Error
GET /items/{id} One item Ability: pos:read

Parameters

idpathinteger · required

Responses

200The item
404{error, message, details}Error
PUT /items/{id} Update an item Ability: pos:write

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.

Parameters

idpathinteger · required

Request body ItemWrite

Responses

200The item
422{error, message, details}Error
GET /price-lists Price lists with their prices Ability: pos:read

Parameters

pagequeryinteger
per_pagequeryinteger

Responses

200A page of price lists
GET /customers Customers (consented fields only) Ability: 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.

Parameters

pagequeryinteger
per_pagequeryinteger
updated_sincequerystring
consented_onlyquerybooleanOnly customers whose latest marketing consent in the consent ledger is granted (never erased ones).
consent_channelquerystringWith consented_only, only consents that cover this channel.

Responses

200A page of customersobject
sales Receipts, Z-reports and stock
GET /receipts Receipts and credit notes, oldest first, with a since_id cursor Ability: 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.

Parameters

since_idquerystring
branch_idqueryinteger
kindquerystring
per_pagequeryinteger

Responses

200Receipts after the cursorReceiptCursorPage
422{error, message, details}Error
GET /receipts/{id} One receipt or credit note Ability: pos:read

Parameters

idpathstring · required

Responses

200The receiptobject
404{error, message, details}Error
GET /sessions/{id}/z-report The Z-report of a closed till session Ability: pos:read

The Z as stored at close; deposits already invoiced are netted (prepayments_applied).

Parameters

idpathstring · required

Responses

200The session with z_report, expected and countedobject
409{error, message, details}Error
GET /stock/levels Stock on hand per branch and variant Ability: pos:read

Parameters

pagequeryinteger
per_pagequeryinteger
branch_idqueryinteger
variant_idqueryinteger
low_onlyqueryboolean

Responses

200A page of stock levels
orders Orders sent to the till's incoming-orders panel
POST /orders Send an order to the till Ability: 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.

Request body OrderWrite

{
    "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

201The orderobject
200The same order again (a retry)
422{error, message, details}Error
GET /orders/{id} The status of one of your orders Ability: pos:orders

Parameters

idpathstring · required

Responses

200The order
404{error, message, details}Error
POST /orders/{id}/cancel Cancel one of your orders Ability: 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.

Parameters

idpathstring · required

Request body object

Responses

200The order, now cancelledobject
404{error, message, details}Error
409{error, message, details}Error
webhooks REST hooks (Zapier and Make)
GET /webhooks Your subscriptions Ability: pos:webhooks

Responses

200A page of subscriptions
POST /webhooks Subscribe (REST hook) Ability: pos:webhooks

The answer carries the subscription id and its signing secret. The secret is shown only here.

Request body object

{
    "target_url": "https://hooks.zapier.com/hooks/standard/123/abc",
    "event": "receipt.issued"
}

Responses

201{id, secret, data}
422{error, message, details}Error
GET /webhooks/events The events, each with sample data Ability: pos:webhooks

Responses

200{data: [{event, sample}]}
GET /webhooks/events/{event}/recent Recent real objects of one event (REST hook perform list) Ability: 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.

Parameters

eventpathstring · required
limitqueryinteger1 to 25, default 3

Responses

200{data: [{id, event, tenant_id, occurred_at, api_version, data}], meta: {event, count, sample}}
403{error, message, details}Error
422{error, message, details}Error
GET /webhooks/{id} One subscription Ability: pos:webhooks

Parameters

idpathinteger · required

Responses

200The subscription
DELETE /webhooks/{id} Unsubscribe (REST hook) Ability: pos:webhooks

Parameters

idpathinteger · required

Responses

204Removed
404{error, message, details}Error