Server

Server SDK and partner API

Everything that needs a secret happens on your server. The server SDK wraps the partner API for Node.js; any language can call the HTTP endpoints directly.

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

Install and configure#

npm install https://apps.salopha.com/sdk/v1/salopha-mini-app-server-sdk-1.6.0.tgz
import { PlatformClient, PlatformError } from "@salopha/mini-app-server-sdk";

const platform = new PlatformClient({
  baseUrl: process.env.SALOPHA_API_BASE!,           // https://api.salopha.com/v1
  clientId: process.env.SALOPHA_CLIENT_ID!,
  clientSecret: process.env.SALOPHA_CLIENT_SECRET!,  // server only
  appId: process.env.SALOPHA_APP_ID!,
  // eventKey: { keyId, privateKeyPem },             // Ed25519, for publishTransactionEvent
  // timeoutMs, fetch                                 // optional
});

Node.js 18 or later, no dependencies. Errors are PlatformError { status, code, details }.

Methods#

MethodCallsAuth
exchangeCode({ code, launchSessionId, nonce, codeVerifier? })POST /mini-apps/auth/tokenclient secret
me(userToken)GET /mini-apps/auth/meuser token
addresses(userToken)GET /mini-apps/auth/me/addressesuser token (addresses.read)
transactions(userToken, limit = 30)GET /mini-apps/auth/me/transactionsuser token (transactions.read)
businesses(userToken)GET /mini-apps/auth/me/businessesuser token: SALOPHA businesses bound to your app where the user is staff
serverToken()POST /mini-apps/auth/client-tokenclient secret; cached for its 15 minutes
notify({ sub | subs, title, body, path?, dedupeKey?, collapseKey? })POST /partner/notificationsserver token
user(sub)GET /partner/users/{sub}server token: the profile with the same consent
stats()GET /partner/statsserver token
bindings(providerExternalId?) · bindings({ status?, providerExternalId? })GET /partner/bindings?status=&providerExternalId=server token
decideBinding(businessId, { decision, providerExternalId?, note? })POST /partner/bindings/{businessId}/decisionserver token: approve or reject a pending business join (1.5)
setProviderExternalId(businessId, providerExternalId)PUT /partner/bindings/{businessId}server token: assign your merchant id (1.5)
bindMerchant({ sub, providerExternalId, businessId } | { sub, providerExternalId, create })POST /partner/bindingsserver token (business.binding.manage)
publishTransactionEvent(event)POST /partner/apps/{appId}/transaction-eventsEd25519 signature (eventKey)
verifyWebhook(headers, method, path, rawBody)—checks a platform call's signature against the published keys
handlePlatformCall({ method, path, headers, rawBody }, { search?, resolve?, businessJoined?, businessLeft?, webhook? })—answers platform calls; returns { status, body }

Partner HTTP API#

Base URL https://api.salopha.com/v1. JSON in and out.

CallAuthNotes
POST /mini-apps/auth/token { clientId, clientSecret, code, launchSessionId, nonce, codeVerifier? }client secret{ access_token, expires_in, sub, scope, profile?, actor }. Replaying a code revokes the session. actor says whether the app runs as the person or a business (acting identity).
GET /mini-apps/auth/me · /me/addresses · /me/transactions · /me/businessesuser tokenConsent re-checked live on every call
POST /mini-apps/auth/client-token { clientId, clientSecret }client secretServer token for 15 minutes (aud miniapp-server:<appId>); rotating the secret ends old ones
POST /partner/notifications { sub | subs[≤500], title ≤120, body ≤300, path?, dedupeKey?, collapseKey? }server tokenPer item: sent, no_consent, unknown_subject, rate_limited (20 per user per app per hour)
GET /partner/users/{sub} · GET /partner/statsserver token
GET | POST /partner/bindingsserver tokenMerchant bindings and business memberships; GET filters by status and providerExternalId
POST /partner/bindings/{businessId}/decision { decision: "approve" | "reject", providerExternalId?, note? }server tokenDecide a pending business join
PUT /partner/bindings/{businessId} { providerExternalId }server tokenAssign your own merchant id
POST /partner/apps/{appId}/transaction-eventsEd25519 signatureSee Transactions and webhooks
POST /share/search { appId, query, actionId?, limit ≤ 40, locale }SALOPHA user (the app calls it)The hub's side of chat search: forwards to your objects/search with the user's pairwise id and sanitizes the answer
GET /mini-apps/{appId}/providers/{externalId}/businessSALOPHA user (the app calls it)Which business chat a merchant maps to

Calls from SALOPHA to you#

SALOPHA calls your webhookUrl base (for example https://shop.example.com/api/v1/platform), always signed with Ed25519. The public keys are published at https://api.salopha.com/v1/.well-known/salopha-webhook-keys.json.

PathWhenTimeout
POST <webhookUrl>/webhooksConsent revoked, binding changed, business joined or left, transaction rated, version published, transaction actions10 s (asynchronous, retried)
POST <webhookUrl>/actionsA user runs a transaction action8 s
POST <webhookUrl>/objects/searchChat search4 s
POST <webhookUrl>/objects/resolveA chat card is created or opened3 s
api.post("/api/v1/platform/*", express.raw({ type: "*/*" }), async (req, res) => {
  const r = await platform.handlePlatformCall({ method: req.method, path: req.originalUrl, headers: req.headers, rawBody: req.body }, {
    search: (q) => searchCatalog(q),
    resolve: (q) => cardFor(q.ref),
    webhook: (event) => onPlatformEvent(event),
  });
  res.status(r.status).json(r.body);
});

Verify the raw body bytes as received: hash first, then parse. Answer 2xx within the timeout and process asynchronous events idempotently by eventId. Signing details are in Request signing.

Notifications#

const r = await platform.notify({ subs: [a, b], title: "New offer", body: "20% off today", path: "/offers", dedupeKey: "offer:2026-11-04" });
for (const item of r.items) if (item.status === "rate_limited") retryLater(item.sub);

Keep an outbox (id, sub, title, body, path, attempts, next attempt) and deliver from it. no_consent and unknown_subject are final; retry the rest with backoff. See Notifications for how users see them.

Statistics#

stats() returns your subscribers (users who opened the app at least once), active users, favourites, home-screen shortcuts, notification opt-ins, and 30-day series. The same numbers, with 90-day series and a subscriber list, are in the admin console.

Merchant bindings#

Connect each merchant in your app (your id: a store slug, an agency id…) to a SALOPHA business, so customers message it through the business chat.

// In your merchant console, after the merchant signed in through SALOPHA:
const mine = await platform.businesses(userToken);           // businesses they manage
await platform.bindMerchant({ sub, providerExternalId: "store-1", businessId: mine[0].businessId });
// Or create the business from the merchant's data:
await platform.bindMerchant({ sub, providerExternalId: "store-1", create: { name: { ar: "…", en: "…" }, categoryIds: ["restaurants"], phones: ["+964…"] } });

// On your server, cached:
const reachable = await platform.bindings();  // [{ providerExternalId, status, chatAvailable, businessName, … }]

Businesses can also join your app themselves from SALOPHA (source: "join", providerExternalId: null until you assign one); see Business audience and joins for approving joins and assigning your merchant id.

A binding's status is one of active, pendingReview, needsInfo, paused, suspended, rejected, expired, cancelled or notRegistered; chatAvailable is true when it is active and the business is open. Official apps and trusted developers are active at once; others after review. One business per merchant.