Order Order Docs
Get API Token

Order Docs / API Guide

Overview

The Order platform exposes all of its services through a single API gateway. Every client — storefront, admin dashboard, mobile apps, operations — talks to the gateway; it authenticates the application, verifies the end user, enforces per-endpoint permissions and rate limits, then routes the request to the owning service.

Base URL

All requests go to the API gateway. Every service is mounted under a fixed public prefix (/api/v1/<service>):

example · production
GET https://api.tryordersystem.com/api/v1/promocode/promocodes/view/123

Switch the target gateway with the environment selector in the top bar. The full list of services and prefixes is in the API Reference.

Request lifecycle

On protected routes the gateway runs these checks in order — the order explains which error you get first:

  1. 1
    Route matchunknown path
    404
  2. 2
    App authenticationapp JWT missing / expired / bad signature
    401
  3. 3
    Revocation checkthe token or the application has been revoked
    401
  4. 4
    Identity resolvedthe verified tenant and application identity are attached to the request; any client attempt to spoof them is stripped
  5. 5
    Rate limitchecked before user validation, so over-quota requests are rejected early
    429
  6. 6
    User authorizationvalidates the customer / employee token and checks the required permission
    401 / 403
  7. 7
    Forward to servicethe request is routed to the owning service
    200
Public routes skip the auth, rate-limit and user-authorization steps — but the gateway still strips all identity headers from client input so they can never be spoofed.

Two authentication layers

The platform authenticates at two independent levels — do not confuse them:

LayerCredentialHeaderIssued by
Application (the calling app)app JWT, 1 h TTLAuthorization: Bearer <app JWT>gateway POST /auth/token
End user (customer / employee)user tokenx-authorization-token · x-authorization-employee-tokenthe login endpoints

Every request to a protected route needs the app JWT. Endpoints gated by a user-level rule additionally need the matching user token — see Authentication and Authorization.

Multi-tenancy

The tenant is bound to the app token. It is validated once at token issuance (against the app's tenant grants) and travels as a JWT claim. An x-tenant header sent with an API request is ignored and stripped — switching tenant means requesting a new token. Downstream services receive the verified tenant in the injected x-tenant header.

Health & availability

  • Every upstream is health-checked actively (probe every 5 s; 2 successes → up, 3 failures → down) and passively (real 5xx responses demote a node).
  • A service with no healthy node returns 503 from the gateway.
  • Multi-node upstreams are load-balanced with automatic failover.

Order Docs / API Guide / Authentication

Authentication

Two independent layers: the application authenticates to the gateway (app JWT), and the end user — customer or employee — authenticates with a user token. Most requests carry both.

1 · Application token — POST /auth/token

Issued by the gateway's auth service after database checks. Required for every protected route.

request
POST /auth/token
Content-Type: application/json
x-tenant: <tenant-slug>            ← required; the tenant this token is bound to

{"username": "<app username>", "password": "<app password>"}

What is verified

  1. 1
    Credentialsusername / password checked against the application registry; the application must be active
  2. 2
    Not blockedan app hard-stopped by an admin cannot obtain new tokens
    403
  3. 3
    Tenant grantthe app must be granted the requested tenant
    403
  4. 4
    Application registered for the tenantthe tenant must have an application registered for it
    403
  5. 5
    Token issueda signed bearer token is returned with the claims below
    200

Responses

StatusBody messageMeaning
200—{"access_token":"<JWT>","token_type":"Bearer","expires_in":3600}
400username and password are required · x-tenant header is required · invalid JSON bodymissing input
401invalid credentialsunknown username, wrong password, or inactive app
403application is blockedadmin-blocked app
403application has no access to this tenanttenant not granted to this app
403no application link for this tenanttenant has no link application
429too many failed attempts, try again laterbrute-force throttle — details

Granted tenants — POST /auth/tenants

Lists the tenants your application may request a token for — use it to pick the x-tenant value before calling /auth/token. Same credentials, no x-tenant header.

request
POST /auth/tenants
Content-Type: application/json

{"username": "<app username>", "password": "<app password>"}
200 response
{
  "app_id": "<uuid>",
  "all_tenants": false,
  "tenants": ["tenant-a", "tenant-b"]
}
FieldMeaning
tenantstenants granted to the app by name, sorted; empty when none
all_tenantstrue = the app may request any existing tenant; those are not enumerated in tenants

Credential checks and errors are the same as /auth/token: 400 missing input / invalid JSON · 401 invalid credentials · 403 application is blocked · 429 brute-force throttle (failed attempts count against the same limit).

Token contents

The token is an opaque bearer credential — send it verbatim in the Authorization header. It encodes the tenant it is bound to and its expiry (TTL 3600 s / 1 hour); when it expires, request a new one.

Using the token

protected call
GET /api/v1/menu/menus
Authorization: Bearer <app JWT>
StatusCauseClient action
401header missing, token expired, or bad signaturefetch a new token from /auth/token
401 token revokedthis token was revoked by an adminfetch a new token
401 application blockedthe whole app was stopped by an adminstop retrying; contact ops
Every 401 carries WWW-Authenticate: Bearer (RFC 9110).

Tenant branding — GET /api/v1/tenant/branding

Everything a client needs to theme itself for the tenant in one call: the tenant's details, logo, colors, images and font. The tenant is the one bound to your app token — no x-tenant header or parameter; to read another tenant, request a token for it. Send x-localization: ar|en to pick the language of name.

request
GET /api/v1/tenant/branding
Authorization: Bearer <app JWT>
200 response
{
  "data": {
    "tenant": {
      "slug": "tenant-a",
      "name": "Diner",
      "names": {"ar": "مطعم", "en": "Diner"},
      "logo": "https://…/logo.png",
      "country": "SA",
      "type": "restaurant",
      "domain": "tenant-a.order.sa",
      "currency": {"iso": "SAR", "digits": 2, "names": {"ar": "…", "en": "…"}}
    },
    "website": {
      "colors": {"buttons_background_color": "#EF2811", "body_text_color": "#000000", …},
      "images": {"logo": "…", "favicon": "…", …},
      "font_family": "IBM+Plex+Sans+Arabic"
    },
    "app": {
      "colors": {"background_color": "#FFFFFF", "secondary_color": "…", …},
      "images": {"logo": "…", "navbar_logo": "…", …},
      "font_family": null
    }
  }
}
FieldMeaning
tenantidentity: name (in the request language, and every language in names), main logo, country, type, storefront domain, currency
websitethe web storefront's look
appthe mobile app's look
colors · imageskey → value; the tenant's own value, else the platform default. Unset images are null

Errors: 401 missing / expired / revoked app token (as any protected route) · 404 the token's tenant no longer exists. Changes to the tenant's settings show up immediately.

2 · End-user authentication

End users sign in through the login endpoints (app JWT still required — these endpoints are public, meaning no user token is needed to call them).

Customer registration & login

EndpointMethodPurpose
/api/v1/user/customers/signupPOSTregister a new customer
/api/v1/user/customers/loginPOSTcredentials login
/api/v1/user/customers/otp-loginPOSTOTP login
/api/v1/user/customers/get-codePOSTrequest an OTP / verification code
/api/v1/user/customers/login-dine-inPOSTdine-in (table) login
/api/v1/user/customers/forget-passwordPOSTstart password reset
/api/v1/user/customers/reset-passwordPOSTcomplete password reset
/api/v1/user/customers/logoutPOSTlogout — requires customer

Employee login

EndpointMethodPurpose
/api/v1/user/employees/loginPOSTstaff login
/api/v1/user/employees/logoutPOSTlogout — requires employee
/api/v1/user/employees/detailsGETcurrent employee profile + permissions
/api/v1/user/employees/permissionsGETpermission list
OTP-protected endpoints and 2FA login flows are handled inside the services today; gateway-level OTP enforcement is on the roadmap.

Presenting the user token

HeaderAudienceOn failure
x-authorization-token: Bearer <token>customersilent — the request proceeds without customer identity (guarded endpoints then refuse)
x-authorization-employee-token: Bearer <token>employee401 rejects the request

The gateway validates the token and attaches the verified user identity to the request for the receiving service — see Headers. Customer identity is cached for 1 hour.

Empty bearer values count as absent, not invalid. Bearer , Bearer undefined, Bearer null are treated as "no credentials" — you get *_auth_required (show login), never *_token_invalid (session expired).

2b · Partner apps

A partner app is a third-party app published by Order and installed by each store from its control panel (the store reviews and grants the scopes).

  • The store owner and staff keep signing in with their own accounts (/api/v1/user/employees/login), as before.
  • The partner app never signs in as an employee and never receives an employee token. Do not call /employees/login and do not send x-authorization-employee-token.

How a partner app authenticates

  1. POST /auth/tenants (app username + password): the stores where the app is installed and enabled.
  2. POST /auth/token with x-tenant: <store>: the same request as section 1.
  3. Call the API with only Authorization: Bearer <app JWT>.
partner app
POST /auth/token
Content-Type: application/json
x-tenant: <store-slug>

{"username": "<app username>", "password": "<app password>"}

GET /api/v1/order/...
Authorization: Bearer <app JWT>

Each installation acts as its own hidden integration employee in that store, holding exactly the permissions of the scopes the store granted. The gateway resolves the app token to that identity on every request, so the app can do what those scopes allow and nothing more. That identity cannot log in and is not visible to the store's staff.

On protected routes the token is accepted only as Authorization: Bearer <JWT>. ?jwt=, a cookie or a bare token get 401.

Token errors (partner apps)

StatusMessageMeaning
403application is not availablethe app is not published (draft, or suspended by Order)
403application is not installed for this tenantthe store has not installed the app
403installation is disabledthe store disabled the app (or it is being uninstalled)
409installation is not readythe installation is still being set up; retry shortly

Request errors (partner apps)

StatuserrorMeaning
401installation_revokedthe store disabled or uninstalled the app; stop and request no new token
403integration_route_not_allowedthe endpoint is not available to partner apps
403permission deniedthe store did not grant the scope this endpoint needs (see Authorization)
503integration_identity_unavailabletemporary; retry with backoff

Scopes

ScopeGrants
orders:readread orders (sensitive)
orders:writemanage orders
delivery:writemanage delivery
menu:read / menu:writeread / manage the menu
branches:read / branches:writeread / manage branches
customers:read / customers:writeread (sensitive) / manage customers
coupons:read / coupons:writeread / manage coupons
reservations:writemanage reservations
payments:readread payments (sensitive)
reports:readread reports (sensitive)

Wallet, points and gift cards are not offered to partner apps.

To link a store that installed your app to an account in your system, and to receive install and uninstall events, see OAuth install flow.

3 · Token revocation (admin)

JWTs are stateless, so revocation is a denylist checked on every protected request. Both endpoints are admin-only (X-Admin-Key header):

revocation
POST /auth/revoke        {"token": "<JWT>"}      revoke ONE token
POST /auth/revoke-app    {"app_id": "<uuid>"}    revoke ALL of an app's tokens
  • Revoking an app rejects every token issued before the revocation; tokens issued after work normally.
  • Denylist entries expire when the tokens would have expired anyway (self-cleaning).
  • The check fails open: if the denylist store is down, requests pass (and are logged) — an outage cannot lock the platform out.
  • An admin can also block an app entirely: existing tokens get 401 application blocked and /auth/token returns 403 until unblocked.

Security properties

  • Spoof-proof headers — the gateway strips every identity header from client input (dash and underscore spellings) before injecting verified values.
  • Brute-force throttle — 10 failed logins per username per 15 min → 429 (resets on success).
  • Auditing — every security event (logins, throttles, blocks, revocations, denials) is one structured log line; passwords and tokens are never logged.

Order Docs / API Guide / OAuth install flow

OAuth install flow

How a partner app links a store that installed it to an account in the partner's own system, and the events it receives when a store installs, disables or uninstalls it. Partner apps authenticate as described in Authentication.

1 · Connecting a store

The install works like an OAuth 2.0 authorization code grant: the store approves your app in its control panel, you receive a short-lived one-time code (by redirect, or as a manual code), and your server exchanges it with your app credentials for the store's installation.

/auth/tenants tells you which stores installed your app, not who in your own system owns them. Never link a store to one of your accounts because a user typed its name. Link a store only from a one-time install code that you exchange with your app credentials: Order hands that code to the person who actually installed the app in the store.

  1. Send the signed-in user to the store's app page (recommended), with your own random state (≤ 256 characters) kept in their session: https://<store>.cp2.tryorder.net/apps/<your-app-slug>?state=<random>
  2. The store installs the app (or uses Connect again when it is already installed). Then:
    • If your app has an install redirect URL, the browser is sent to it with ?code=<code>&state=<state> (state only when you sent one; the store name is never in the URL). Check state against the user's session first.
    • Otherwise the store sees a manual code XXXX-XXXX-XXXX to paste into your app (case-insensitive; dashes and spaces ignored).
  3. Exchange the code, server to server, while that user's session is open.
exchange
POST /auth/installations/exchange
Content-Type: application/json

{"username": "<app username>", "password": "<app password>",
 "code": "<code>", "state": "<state, when you sent one>"}

200
{"installation_id": "bd64ccab-…", "tenant": "burger",
 "store": {"name": "burger", "domain": "burger.tryorder.net"},
 "scopes": ["menu:read", "orders:read"], "installed_at": "2026-11-26T21:29:15Z"}

Link tenant / installation_id to the signed-in account, then use POST /auth/token with x-tenant: <tenant> as above.

StatusMessageMeaning
200—the code was valid; it is now used up
400invalid or expired codeunknown, already used, expired, issued to another app, wrong state, or the installation is no longer active: one answer for every case
400username and password are required · code is required · state must be a string · invalid JSON bodybad input
401invalid credentialswrong app credentials; the code is not used up
403application is blockedthe app was stopped by Order; the code is not used up
429too many failed attempts, try again laterrefused codes count as failed logins for your username
  • A code works once. Redirect codes expire after 10 minutes, manual codes after 15 minutes. A new code for the same store replaces the previous unused one.
  • A code refused for a wrong state is used up: ask the store to use Connect again.
  • The store owner is notified by SMS each time a store is connected to your app.

2 · Webhook events for partner apps

Your app's webhook receives the data events of the scopes each store granted, and these lifecycle events for every store, whatever the scopes, including after the store disabled or uninstalled the app:

EventWhen
app.installeda store installed the app
app.enabledthe store re-enabled the app
app.disabledthe store disabled the app; no data events until it is enabled again
app.scopes_changedthe scopes the store granted changed
app.uninstalledthe store uninstalled the app; stop using its tenant
delivery
POST <your webhook URL>
Content-Type: application/json
X-Webhook-Event:     app.installed
X-Webhook-Id:        <event_id>
X-Webhook-Delivery:  <delivery uuid>
X-Webhook-Tenant:    <store>
X-Webhook-Timestamp: <unix ts>
X-Webhook-Signature: t=<unix ts>,v1=<hex hmac_sha256(signing secret, "{t}.{raw body}")>

{"event": "app.installed", "version": 1, "event_id": "5f0c…",
 "occurred_at": "2026-11-26T21:29:16+00:00", "tenant": "burger",
 "data": {"installation_id": "bd64ccab-…", "app_slug": "your-app",
          "scopes": ["menu:read", "orders:read"],
          "store": {"name": "burger", "domain": "burger.tryorder.net"}}}
  • Verify X-Webhook-Signature with your endpoint's signing secret (given once when the app is created) and reject timestamps older than 5 minutes.
  • Retries reuse the same event_id: de-duplicate on it.
  • A lifecycle event never contains a code, a token or an employee id. It tells you a store's state; it is not proof of who owns the store: link stores only through the code exchange above.

Order Docs / API Guide / Authorization

Authorization

Beyond the application token, an endpoint may require an end-user identity — a logged-in customer, or an employee holding a specific permission. Each endpoint states exactly what it needs in its Authorization field; this page explains that vocabulary.

Authorization vocabulary

GuardAllows
publicanyone with a valid app JWT — no user identity needed
customeran authenticated customer
employeeany authenticated employee
employee:<permission>an employee holding that store permission
opan employee of an operations app
op:<permission>an operations employee holding that permission
any_autha customer or an employee
internalnobody — service-to-service only; the public edge refuses with 403 internal_endpoint
An unknown guard fails closed (403 unknown_guard).

Shared endpoints (OR rules)

A rule may list several guards; the request passes when any one is satisfied. Used for endpoints legitimately shared between audiences, e.g. GET /api/v1/menu/menus allows any of employee:view_menus employee:add_coupons employee:update_coupons employee:discounts. An OR never widens access beyond its own branches.

Two permission sets

There is no permission called op — that guard only asserts the app type. Store staff and operations staff each have their own set of permission slugs:

AudienceGuard formExample permissions
Store staffemployee:<perm>orders_page add_menus allow_refund_order
Operationsop:<perm>view_orders view_stores impersonate_manager

Permissions are granted to roles, and an employee inherits them from their role.

The 401 / 403 contract

401 = no valid credentials (authenticate and retry). 403 = credentials accepted, but not allowed (retrying changes nothing). An expired token and a missing token are both 401.

A 403 names the missing permission and the endpoint:

403 response
{
  "error": "permission_denied",
  "required": ["allow_refund_order"],
  "method": "POST",
  "path": "/api/v1/order/orders/refund",
  "message": "permission denied: 'allow_refund_order' is required for POST /api/v1/order/orders/refund"
}

For an OR rule, required lists every acceptable permission. A 401 deliberately carries none of this — an anonymous caller must not be handed the authorization map.

A 403 tells you exactly which permission is missing on which route, so it is safe to surface to the user as "no access". See Responses & Errors, in particular: never treat every 401 as "log out".

Per-endpoint authorization

Every endpoint's exact requirement is on its page in the API Reference. Path matching follows a few simple rules:

  • {param} matches exactly one path segment; a trailing * matches anything.
  • The most specific (longest) path wins when several could match.

Order Docs / API Guide / Headers

Headers

The headers you send with a request, and the headers you get back in the response.

Headers clients send

HeaderRequiredPurpose
Authorization: Bearer <app JWT>protected routesapplication authentication
x-tenantonly on POST /auth/tokenwhich tenant to bind the token to. Ignored / stripped on all other calls
x-authorization-tokencustomer-guarded endpointsthe customer's session token (Bearer <t>)
x-authorization-employee-tokenemployee/op-guarded endpointsthe staff session token

All of the above are in the CORS allow-list for browser clients (credentials disabled).

Verified identity

Once your tokens are verified, the gateway attaches the resolved tenant and user identity to the request for the receiving service. These identity headers are set by the gateway only — any attempt to send them yourself is stripped, so they can never be spoofed. You don't set or read them; just send your tokens and the correct x-tenant at login.

Response headers

HeaderWhenMeaning
X-RateLimit-Limit · X-RateLimit-Remainingrate-limited routesquota state — details
WWW-Authenticate: Bearerevery 401RFC 9110 compliance
Content-Type: application/jsongateway-generated errorsgateway error bodies are always JSON

Order Docs / API Guide / Rate Limiting

Rate Limiting

All quotas are enforced at the gateway and shared across gateway nodes — the quota is global, not per-node.

120 / 60s
API · per app + tenant
10 / 15min
Login fails · per username

API quota

  • The key is the credential application (from the verified JWT claim — spoof-proof) plus the tenant. An app serving several tenants gets an independent bucket per tenant; two different apps calling the same tenant do not share a bucket.
  • The count is checked before end-user validation, so over-quota requests are rejected cheaply.
  • Over limit → 429 with message rate limit exceeded.

Response headers

headers
X-RateLimit-Limit: 120        ← the quota
X-RateLimit-Remaining: 87     ← requests left in the current window

On 429 the body is JSON:

429 body
{"error_msg": "rate limit exceeded"}
Client guidance: watch X-RateLimit-Remaining and back off before hitting zero; on 429, retry after the window resets (up to 60 s). Do not retry immediately in a loop — the window is fixed, not sliding.

Login throttle

  • Counted per username, only on failed attempts; a successful login resets the counter.
  • While throttled, /auth/token returns 429 even with correct credentials.
  • Window: 15 minutes.

Order Docs / API Guide / Responses & Errors

Responses & Errors

Gateway-generated errors are always JSON, and every 401 carries WWW-Authenticate: Bearer. Upstream service errors pass through untouched. Branch on the error slug, never on message — messages get reworded.

shape
{"error": "<slug>", "message": "<human text>"}   // 403s also carry required / method / path

The slug table

StatuserrorMeaningWhat the client should do
401(none — app auth)app JWT missing / expired / bad signaturefetch a new app token from /auth/token
401(none) token revokedthis app token was revokedfetch a new app token
401(none) application blockedthe app was stopped by an adminstop; contact ops
401customer_auth_requiredno customer credentials presentedshow the login screen
401customer_token_invalidcustomer token presented and rejectedsession expired → re-authenticate
401employee_auth_requiredno employee credentials presentedshow the staff login
401employee_token_invalidemployee token presented and rejectedsession expired → re-authenticate
401auth_requiredseveral audiences accepted, none presentedshow login
401session_invalidseveral audiences accepted, presented token rejectedre-authenticate
403permission_deniedlogged in, lacks the permissionshow "no access" — do not log out
403admin_access_requiredstaff, but the app is not an operations appshow "no access"
403internal_endpointservice-to-service endpoint hit from the public edgedon't call this
403unknown_guardmisconfigured rule (fails closed)report a bug
429(none)rate limit / login throttleback off — details
404(none)no route matchedcheck the path
503(none)no healthy upstream noderetry with backoff

Rules clients must follow

  1. 1
    Never treat every 401 as "log out and clear the session"a logged-in customer touching a staff-only endpoint gets employee_auth_required — wiping their session would be wrong. Only *_token_invalid / session_invalid mean "your session died".
  2. 2
    401 vs 403 is remedial401 → authenticate and retry; 403 → retrying changes nothing, the account lacks a grant
  3. 3
    Empty bearer values are "absent", not "invalid"Bearer , Bearer undefined, Bearer null → *_auth_required

403 bodies name the fix

permission_denied
{
  "error": "permission_denied",
  "required": ["view_branches", "order_details_page"],
  "method": "GET",
  "path": "/api/v1/branch/branches/7",
  "message": "permission denied: GET /api/v1/branch/branches/7 requires one of 'view_branches', 'order_details_page'"
}

required / method / path appear on 403 only — a 401 caller has no identity, and naming permissions would hand the authorization map to anonymous callers.

Order Docs / API Guide / Webhooks

Webhooks

How platform events reach you, and how to verify them. When a subscribed event occurs, we send an HTTP POST with a JSON body to your endpoint URL.

To add or edit a webhook endpoint: webhooks are currently provisioned by our team. To request a new endpoint or a change, contact support at [email protected].

Delivery

  • A delivery is considered successful on a 2xx response.
  • On failure we retry up to 5 times with exponential backoff (10 s → 1 m → 5 m → 30 m).
  • 4xx responses (except 429) are not retried — check your URL / signature.
  • The same event may be delivered more than once — use X-Webhook-Id to deduplicate (idempotency).
  • Respond quickly (within a few seconds) and process asynchronously.

Request headers

HeaderMeaning
X-Webhook-EventEvent name (e.g. OrderCreatedEvent)
X-Webhook-IdEvent id — use it to avoid processing duplicates (idempotency)
X-Webhook-DeliveryDelivery id (uuid)
X-Webhook-TimestampUnix timestamp
X-Webhook-SignatureHMAC-SHA256 signature of the body — see Signature verification below
X-Webhook-TenantStore identifier (sent for global endpoints only)

Payload shape

Every event arrives in the same envelope; the data object varies by event type:

envelope
{
  "event": "OrderCreatedEvent",
  "event_id": "9f1c8a2e-7d3b-4a10-9b2c-1e5f0a4d8c22",
  "occurred_at": "2026-06-30T12:28:50+00:00",
  "data": { /* depends on the event — see examples below */ }
}

Signature verification (HMAC-SHA256)

Every request is signed with the X-Webhook-Signature header. The signature is hmac_sha256(raw_body, signing_secret) encoded as hex. Recompute it on your side and compare using a constant-time comparison before trusting the request.

Use the raw request body exactly as received (do not re-encode the JSON) — a single byte difference invalidates the signature.
PHP
<?php
// raw body as received (do not re-encode the JSON)
$payload   = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? '';
$secret    = 'whsec_...'; // your endpoint's signing secret

$expected = hash_hmac('sha256', $payload, $secret);

if (! hash_equals($expected, $signature)) {
    http_response_code(401);
    exit; // invalid signature — ignore the request
}

// valid — process the event, then return 2xx
$event = json_decode($payload, true);
http_response_code(200);
Node.js (Express)
const crypto = require("crypto");

// pass the raw body: app.use(express.raw({ type: "*/*" }))
function isValid(rawBody, signature, secret) {
  const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(signature || "");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

app.post("/webhook", (req, res) => {
  if (!isValid(req.body, req.get("X-Webhook-Signature"), "whsec_...")) {
    return res.status(401).end();
  }
  const event = JSON.parse(req.body.toString());
  res.status(200).end();
});

The signing_secret is shown once when the endpoint is created, and can be regenerated on demand.

Supported events

EventX-Webhook-Event
Coupon createdCouponCreatedEvent
Coupon updatedCouponUpdatedEvent
Coupon deletedCouponDeletedEvent
Order createdOrderCreatedEvent
Order canceledOrderStatusUpdatedEvent
Order completedOrderCompletedEvent

Coupon created — CouponCreatedEvent

data · CouponCreatedEvent
{
  "id": 1234,
  "code": "SUMMER20",
  "type": "percentage",
  "value": 20,
  "tenant": "burger",
  "max_uses": 100,
  "starts_at": "2026-06-01",
  "expires_at": "2026-09-01",
  "is_active": true
}

Coupon updated — CouponUpdatedEvent

Same shape as creation, after the update.

data · CouponUpdatedEvent
{
  "id": 1234,
  "code": "SUMMER25",
  "type": "percentage",
  "value": 25,
  "tenant": "burger",
  "is_active": true
}

Coupon deleted — CouponDeletedEvent

data · CouponDeletedEvent
{
  "id": 1234,
  "code": "SUMMER25",
  "tenant": "burger"
}

Order created — OrderCreatedEvent

data · OrderCreatedEvent
{
  "id": 5001,
  "order_code": "OR-5001",
  "tenant": "burger",
  "status": "new",
  "type": "delivery",
  "total": 84.50,
  "currency": "SAR",
  "branch_id": 12,
  "customer": { "id": 200, "name": "Sara", "mobile": "+9665XXXXXXX" },
  "items": [ { "name": "Burger", "qty": 2, "price": 30.00 } ],
  "created_at": "2026-06-30T12:00:00+00:00"
}

Order canceled — OrderStatusUpdatedEvent

Cancellation arrives as a status update where status = "canceled".

data · OrderStatusUpdatedEvent
{
  "id": 5001,
  "order_code": "OR-5001",
  "tenant": "burger",
  "status": "canceled",
  "updated_at": "2026-06-30T12:20:00+00:00"
}

Order completed — OrderCompletedEvent

data · OrderCompletedEvent
{
  "id": 5001,
  "order_code": "OR-5001",
  "tenant": "burger",
  "status": "completed",
  "completed_at": "2026-06-30T12:45:00+00:00"
}
Fields above are illustrative and may include additional data. To request other events, contact [email protected].

Order Docs / API Guide / Tenant

Tenant details & settings

Read a tenant's identity (name, logo, domain, currency) and its storefront / app settings (colors, images, font, behaviour). All of these need only the app token — they are public, no customer or staff login.

Which one to call

You needCall
Logo, colors, images and font, already groupedGET /api/v1/tenant/branding
Tenant identity only (name, logo, contact, domain, currency, timezone…)GET /api/v1/tenant/tenants/get-tenant-by-slug/{slug}
Any settings group, as raw key / value pairsGET /api/v1/tenant/defaultSettings/getSettingByGroups
Everything to boot a storefront in one readGET /api/v1/tenant/bootstrap/init

Send x-localization: ar|en to choose the language of translated values (title, multi-language settings).

1 · Tenant details — GET /api/v1/tenant/tenants/get-tenant-by-slug/{slug}

{slug} is the tenant slug (e.g. tenant-a).

request
GET /api/v1/tenant/tenants/get-tenant-by-slug/tenant-a
Authorization: Bearer <app JWT>
QueryMeaning
withoptional — mobiles to include mobile_tenants
200 response
{
  "data": {
    "name": "tenant-a",
    "title": "Diner",
    "email": "[email protected]",
    "mobile": "5XXXXXXXX",
    "logo": "https://…/logo.png",
    "country": "SA",
    "country_phone_code": "966",
    "timezone": "Asia/Riyadh",
    "domain": "tenant-a.order.sa",
    "tracking_codes": [],
    "mobile_tenants": [],
    "currency": {"names": {"ar": "…", "en": "…"}, "iso": "SAR", "digits": 2},
    "is_store_enabled": true
  }
}
FieldMeaning
namethe tenant slug (the value of x-tenant)
titledisplay name, in the request language
email · mobilethe tenant's contact email and mobile
logomain logo URL
country · country_phone_code · timezonecountry code, its dialling code, and the tenant's timezone
domainthe canonical storefront host
tracking_codesalways empty here — use trackingCodes from §3
mobile_tenantsthe tenant's mobile numbers (id, country_code, mobile) — only with ?with=mobiles, else []
currencyiso code, decimal digits, localized names
is_store_enabledtrue when at least one branch has online store enabled

Errors: 401 app token missing / expired · 404 no tenant with that slug.

2 · Settings — GET /api/v1/tenant/defaultSettings/getSettingByGroups

Returns every setting in the requested groups for the tenant bound to your app token. Each value is the tenant's own value, otherwise the platform default.

request
GET /api/v1/tenant/defaultSettings/getSettingByGroups?groups=website,app
Authorization: Bearer <app JWT>
QueryMeaning
groupsrequired — comma-separated group names
GroupHolds
websiteweb storefront look: colors, logo, favicon, font, banners, open/closed
appmobile app look: colors, logos
generallanguages (default_lang, available_lang), tax, customer profile rules
socialsocial links and app-store download links
order · checkout · payment · language · marketingordering, checkout and payment behaviour, translations, marketing
reservation · waitingList · dine_inreservation, waiting-list and dine-in pages
200 response
{
  "data": [
    {"key": "website.buttons_background_color", "value": "#EF2811", "values": null},
    {"key": "website.logo", "value": "https://…/logo.png", "values": null},
    {"key": "website.site_name", "value": "Diner", "values": {"ar": "مطعم", "en": "Diner"}},
    {"key": "app.secondary_color", "value": "#111111", "values": null}
  ]
}
FieldMeaning
key<group>.<name>
valuethe value, in the request language for multi-language settings
valuesevery language ({"ar","en"}) for multi-language settings, else null

The two app-store links in social also carry ios_app_id / android_package_id, parsed from the link.

Errors: 401 app token missing / expired · 422 groups missing.

3 · Storefront bootstrap — GET /api/v1/tenant/bootstrap/init

The reads a storefront needs at start-up, merged into one response for the token's tenant. Each part is identical to calling its own endpoint.

request
GET /api/v1/tenant/bootstrap/init?groups=general,website,app&place=web
Authorization: Bearer <app JWT>
QueryMeaning
groupssettings groups for defaultSettings, as in §2
placeweb or mobile — which tracking codes to return
200 response
{
  "data": {
    "mainAppSettings": {"app_id": "…", "app_type": "single", "main_tenant": "tenant-a", "tenants": ["tenant-a"], "countries": ["SA"], … },
    "tenant":          { …tenant details, plus blocks_settings and meta_tags… },
    "trackingCodes":   [ … ],
    "defaultSettings": [ {"key": "…", "value": "…", "values": null}, … ]
  },
  "errors": [ {"key": "trackingCodes", "message": "…"} ]
}
PartSame asIf it fails
mainAppSettingsthe app's settings: type, tenants, countries and currencieswhole call fails
tenanttenant details as in §1, plus blocks_settings (home-page layout) and meta_tags (page-head meta entries); without email / mobilewhole call fails
defaultSettings§2 getSettingByGroupswhole call fails
trackingCodesmarketing / analytics tags for placenull, reason listed in errors
Responses are cached per tenant and language; a change to the tenant's settings shows up immediately.

Order Docs / API Reference

API Reference

Authorization breakdown

Services

ServicePublic prefixAuthEndpoints