How it works#
- Your manifest declares an
audience: whether people can use the app, and whether businesses can join it. - A business owner or manager sees your app under «خدمات لنشاطك» (services for your business), or taps «انضم بنشاطك» (join with your business) on its details page, or your page calls
requestBusinessJoin(). - SALOPHA shows a native sheet with the user's businesses (ineligible ones greyed out with the reason), what your app will receive, and a consent button.
- The join creates a membership:
activeat once (joinApproval: "auto") orpendingReviewuntil you decide (joinApproval: "developer"). Your server getsplatform.business.joined.v1. - Members open your app as the business. The launch, the token exchange and
me()carry anactorwith the business id, the member's role and permissions. - The business can leave at any time from its settings («التطبيقات المرتبطة», linked apps). You get
platform.business.left.v1and its sessions in your app end.
Manifest audience#
"audience": {
"users": true, // people can use the app with their personal account
"businesses": {
"mode": "optional", // "none" | "optional" | "required" (business-only)
"joinApproval": "auto", // "auto" | "developer"
"eligibility": { "categories": ["restaurants", "cafe"], "verifiedOnly": false, "countries": ["IQ"], "inviteOnly": false },
"shares": ["profile", "phones", "branches"], // shown on the consent sheet, sent in the joined webhook
"consolePath": "/biz" // where a member lands when opening the app as the business
}
}
| Field | Default | Meaning |
|---|---|---|
audience | { "users": true, "businesses": { "mode": "none" } } | Absent means people only, exactly as before. |
users | true | Whether personal accounts can open the app. Must be false when businesses.mode is required. |
businesses.mode | none | none: no business joins. optional: people and businesses. required: a business-only app (hidden from the personal catalog). |
businesses.joinApproval | auto | auto: a join is active at once. developer: it waits as pendingReview until your server approves or rejects it. |
businesses.eligibility.categories | [] (any) | Platform category ids a business must have one of. |
businesses.eligibility.verifiedOnly | false | Only verified businesses may join. |
businesses.eligibility.countries | [] (any) | ISO country codes a business must be in. |
businesses.eligibility.inviteOnly | false | Only businesses you bound yourself (bindMerchant) can use the app; nobody can join from SALOPHA. |
businesses.shares | [] | What the business shares with you on joining: profile (name, logo, categories, verified), phones, branches. |
businesses.consolePath | / | The path opened when a member opens the app as the business (entryDeepLink). |
The audience is part of the manifest you edit on the developer platform and is frozen into each release.
Memberships#
A membership is the same record as a merchant binding: one per business, app and branch. It has a source:
source | Created by | providerExternalId |
|---|---|---|
join | The business, from SALOPHA (consent sheet) | null until you assign your own merchant id |
partner | You, with bindMerchant() | Your merchant id |
Statuses are the binding statuses: pendingReview, active, rejected, cancelled (left), and the others listed in Merchant bindings.
Eligibility#
SALOPHA lists the businesses where the signed-in user may manage linked apps and checks each against your audience:
GET /v1/mini-apps/{appId}/business-eligibility (SALOPHA user token)
{ "items": [
{ "businessId": "biz_1", "name": { "ar": "مطعم الريف", "en": "Al Reef" }, "logo": { "source": "network", "value": "https://…" }, "verified": true,
"categoryIds": ["restaurants"], "eligible": true, "membership": null },
{ "businessId": "biz_2", "name": { "ar": "…", "en": "…" }, "logo": null, "verified": false,
"categoryIds": ["grocery"], "eligible": false, "reason": "category", "membership": { "status": "cancelled" } }
] }
reason | Why the business cannot join |
|---|---|
not_supported | The app does not accept businesses (mode: none). |
business_inactive | The business is suspended or closed. |
category | None of the business's categories is in eligibility.categories. |
not_verified | verifiedOnly is set and the business is not verified. |
country | The business is outside eligibility.countries. |
invite_only | inviteOnly is set: only you can bind businesses. |
Joining#
The host calls this after the user consents on the sheet. Your page never calls it directly; it calls requestBusinessJoin().
POST /v1/mini-apps/{appId}/business-join { "businessId": "biz_1" } (SALOPHA user token)
→ { "status": "active" | "pendingReview", "businessId": "biz_1", "bindingId": "bnd_…" }
- Automatic approval (
joinApproval: "auto"): the membership isactiveand the business can open your app right away. - Developer approval (
joinApproval: "developer"): the membership ispendingReview. List pending joins withplatform.bindings({ status: "pendingReview" })and decide withplatform.decideBinding()(see Partner routes).
Either way your server receives platform.business.joined.v1.
Leaving#
DELETE /v1/businesses/{businessId}/apps/{appId} (SALOPHA user token) → 204
The membership becomes cancelled, the business's live sessions in your app end, and you receive platform.business.left.v1. Stop acting for that business; keep only what your own records require.
The business settings page («التطبيقات المرتبطة») reads its linked apps from:
GET /v1/businesses/{businessId}/apps (SALOPHA user token)
→ { "items": [ { "bindingId", "appId", "slug", "name", "icon", "status", "source", "providerExternalId",
"branchId"?, "consolePath", "appAvailable", "createdAt", "updatedAt" } ] }
Catalog per actor#
GET /v1/mini-apps?actor=business:{businessId}
GET /v1/mini-apps?actor=user (default)
With actor=business:<id>, the catalog lists apps whose audience accepts businesses and where the business is eligible or already a member; each item carries businessMembership: { status } | null. With actor=user, business-only apps (mode: required) are hidden.
Acting identity#
Every launch runs as an actor: the person, or one of their businesses.
type Actor =
| { kind: "user" }
| { kind: "business"; businessId: string; name: { ar: string; en: string }; verified: boolean;
categoryIds: string[]; role: string; permissions: string[] };
- Launch. The host opens the app as a business by creating the launch session with
businessId(POST /v1/mini-apps/{appId}/launch-sessions { …, businessId }). It needs an active membership and the caller's right to act for that business; the response includesactor. - Page.
initialize()returnsctx.actor(alsoctx.launch.actor), andgetLaunchContext()returnsactor. Older hosts don't send it; SDK 1.5 then reports{ kind: "user" }. - Server. The token exchange (
POST /v1/mini-apps/auth/token) andGET /v1/mini-apps/auth/mereturn the sameactor(meanswers 403actor_revokedonce the membership or the person's role in the business ends). Thesubis still the person's pairwise id; the business is identified by its real platform business id.
actor is a hint for the interface. Authorise business actions on your server with the actor from the token exchange or me(), and check role/permissions there.// Your sign-in route
const r = await platform.exchangeCode({ code, launchSessionId, nonce });
const session = { sub: r.sub, businessId: r.actor.kind === "business" ? r.actor.businessId : null };
Switching identity#
Browser and server SDK 1.6
Apps used both personally and for businesses can let the user switch identity without closing the app. Declare it in the manifest; the hub validates it against audience:
"audience": { "users": true, "businesses": { "mode": "optional" } },
"identities": { "switchable": true, "kinds": ["personal", "business"], "liveSwitch": true }
- The host shows the active identity's photo (the person, or the business logo) in the runtime header. A tap lists the identities the user may use in your app: themself (when
audience.users) and each business linked to your app where their role allows acting for it. - Switching is re-authorized by the hub: a new launch session is issued for the new identity, and the old session ends with every token minted from it revoked. The host resets its bridge state (sign-in code, one-time consents) and partitions
storage.*per identity. - With
liveSwitch: trueand a page on SDK ≥ 1.6, the page stays open and receivesidentityChanged { actor, sessionId }(actorChangedfires too). Drop everything held for the previous identity, callrequestAuthCode()(it returns the new identity's code), sign in again and refresh withgetContext(). WithoutliveSwitchthe host reloads the page with the new session. - Tokens are bound to one identity. Send
x-salopha-actor: userorx-salopha-actor: business:<id>onauth/me(server SDK:me(token, expectActor)); the hub answers403 identity_mismatchfor a token of another identity. - A business identity never receives the person's own data:
addresses.read,transactions.readandaddresses.grant.businessare dropped from its tokens and refused by the bridge. substays the person's pairwise id. Key your data by(sub, actor.businessId). Cookies andlocalStorageare per origin in the platform web view: key them by actor too, or rely on the reload.
Browser SDK#
SDK 1.5 adds two methods and one event (bridge protocol stays 1.2):
| Method | Returns | Notes |
|---|---|---|
requestBusinessJoin({ businessId? }) | { status: "active" | "pendingReview" | "cancelled", businessId? } | Opens the host's join sheet. cancelled means the user dismissed it. |
switchActor({ kind: "user" } | { kind: "business", businessId }) | { switched } | The host relaunches your app as that actor (new launch session, new sign-in code). The business needs an active membership. |
event actorChanged | the new Actor | app.context.actor is updated before handlers run. |
const ctx = await app.initialize();
if (ctx.actor.kind === "business") {
showConsole(ctx.actor); // you are at audience.businesses.consolePath
} else if (wantsBusinessFeatures) {
const r = await app.requestBusinessJoin();
if (r.status === "active") await app.switchActor({ kind: "business", businessId: r.businessId! });
if (r.status === "pendingReview") showNotice("Thanks! We review new businesses within a day.");
}
app.on("actorChanged", (actor) => render(actor));
Older hosts answer both methods with method_not_allowed; feature-detect and hide the button. In a plain browser, the simulator plays joins and switches:
new SalophaMiniApp({ devSimulator: {
actor: { kind: "user" },
businesses: [{ businessId: "biz_1", name: { ar: "مطعم الريف", en: "Al Reef" }, verified: true, categoryIds: ["restaurants"] }],
joinApproval: "developer", // joins come back as pendingReview
} });
app.simulator?.setMembership("biz_1", "active"); // play your approval
Links#
salopha://launch/<appId>?as=business&biz=<businessId>&path=/biz/orders
Opens your app as that business (when the user can act for it and the membership is active) at path. Without as=business the app opens as the person. Apps that accept both ask once: «افتح كشخص أم باسم نشاطك؟» (open as yourself or as your business?).
Webhooks#
Both events are POSTed, signed, to <webhookUrl>/webhooks like every platform call:
{
"eventId": "evt_…",
"eventType": "platform.business.joined.v1",
"appId": "my_app",
"businessId": "biz_1",
"business": { "name": { "ar": "مطعم الريف", "en": "Al Reef" }, "logo": { "source": "network", "value": "https://…" }, "verified": true,
"categoryIds": ["restaurants"], "phones": [ … ], "branches": [ … ] },
"status": "pendingReview",
"joinedBySub": "pw_…",
"occurredAt": "2026-11-07T10:00:00Z"
}
| Event | status | Notes |
|---|---|---|
platform.business.joined.v1 | active or pendingReview | phones and branches only when listed in audience.businesses.shares. |
platform.business.left.v1 | cancelled | Same body; the business's sessions in your app have ended. |
joinedBySub is your pairwise id of the member who joined or left. Process events idempotently by eventId.
const r = await platform.handlePlatformCall(req, {
businessJoined: async (e) => { await merchants.upsertFromPlatform(e); if (e.status === "pendingReview") await queueReview(e.businessId); },
businessLeft: async (e) => merchants.deactivate(e.businessId),
});
Partner routes#
Server token (client credentials). The server SDK wraps them:
| Route | SDK | Notes |
|---|---|---|
GET /v1/partner/bindings?status=&providerExternalId= | bindings({ status?, providerExternalId? }) | e.g. status=pendingReview for joins waiting for you. Items: { bindingId, businessId, branchId?, providerExternalId | null, source, status, chatAvailable, businessName, updatedAt }. |
POST /v1/partner/bindings/{businessId}/decision { decision: "approve" | "reject", providerExternalId?, note? } | decideBinding(businessId, { decision, providerExternalId?, note? }) | Approve or reject a pending join; optionally assign your merchant id on approval. Returns the binding. |
PUT /v1/partner/bindings/{businessId} { providerExternalId } | setProviderExternalId(businessId, providerExternalId) | Assign or change your own merchant id later. Returns the binding. |
for (const b of await platform.bindings({ status: "pendingReview" })) {
const ok = await myReview(b.businessId);
await platform.decideBinding(b.businessId, ok ? { decision: "approve", providerExternalId: await createMerchant(b) } : { decision: "reject", note: "Outside our delivery area" });
}