Build

Business audience and joins

Your app can serve people, businesses, or both. A business joins your app from SALOPHA with one consent sheet, and then opens it as the business. You receive the real business id, decide whether joins need your review, and can link each business to your own merchant record.

Last updated: November 7, 2026 · Browser SDK 1.6.0 · Bridge protocol 1.2

How it works#

  1. Your manifest declares an audience: whether people can use the app, and whether businesses can join it.
  2. 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().
  3. 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.
  4. The join creates a membership: active at once (joinApproval: "auto") or pendingReview until you decide (joinApproval: "developer"). Your server gets platform.business.joined.v1.
  5. Members open your app as the business. The launch, the token exchange and me() carry an actor with the business id, the member's role and permissions.
  6. The business can leave at any time from its settings («التطبيقات المرتبطة», linked apps). You get platform.business.left.v1 and 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
  }
}
FieldDefaultMeaning
audience{ "users": true, "businesses": { "mode": "none" } }Absent means people only, exactly as before.
userstrueWhether personal accounts can open the app. Must be false when businesses.mode is required.
businesses.modenonenone: no business joins. optional: people and businesses. required: a business-only app (hidden from the personal catalog).
businesses.joinApprovalautoauto: 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.verifiedOnlyfalseOnly verified businesses may join.
businesses.eligibility.countries[] (any)ISO country codes a business must be in.
businesses.eligibility.inviteOnlyfalseOnly 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:

sourceCreated byproviderExternalId
joinThe business, from SALOPHA (consent sheet)null until you assign your own merchant id
partnerYou, 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" } }
] }
reasonWhy the business cannot join
not_supportedThe app does not accept businesses (mode: none).
business_inactiveThe business is suspended or closed.
categoryNone of the business's categories is in eligibility.categories.
not_verifiedverifiedOnly is set and the business is not verified.
countryThe business is outside eligibility.countries.
invite_onlyinviteOnly 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 is active and the business can open your app right away.
  • Developer approval (joinApproval: "developer"): the membership is pendingReview. List pending joins with platform.bindings({ status: "pendingReview" }) and decide with platform.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 includes actor.
  • Page. initialize() returns ctx.actor (also ctx.launch.actor), and getLaunchContext() returns actor. Older hosts don't send it; SDK 1.5 then reports { kind: "user" }.
  • Server. The token exchange (POST /v1/mini-apps/auth/token) and GET /v1/mini-apps/auth/me return the same actor (me answers 403 actor_revoked once the membership or the person's role in the business ends). The sub is still the person's pairwise id; the business is identified by its real platform business id.
Trust the server, not the page. The page's 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: true and a page on SDK ≥ 1.6, the page stays open and receives identityChanged { actor, sessionId } (actorChanged fires too). Drop everything held for the previous identity, call requestAuthCode() (it returns the new identity's code), sign in again and refresh with getContext(). Without liveSwitch the host reloads the page with the new session.
  • Tokens are bound to one identity. Send x-salopha-actor: user or x-salopha-actor: business:<id> on auth/me (server SDK: me(token, expectActor)); the hub answers 403 identity_mismatch for a token of another identity.
  • A business identity never receives the person's own data: addresses.read, transactions.read and addresses.grant.business are dropped from its tokens and refused by the bridge.
  • sub stays the person's pairwise id. Key your data by (sub, actor.businessId). Cookies and localStorage are 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):

MethodReturnsNotes
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 actorChangedthe new Actorapp.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
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"
}
EventstatusNotes
platform.business.joined.v1active or pendingReviewphones and branches only when listed in audience.businesses.shares.
platform.business.left.v1cancelledSame 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:

RouteSDKNotes
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" });
}