Auphere Embed · Reference
/ v0.1
API reference
Every option, method and endpoint of @auphere/embed and its companion REST API.
createAuphere(config)
Creates the SDK client. Throws synchronously if fetchSession or partnerSlug is missing.
fetchSession() => Promise<WidgetSession>Required- Called whenever the SDK needs a session token: on open, and again when a token is about to expire. Must be re-invocable without user interaction. Both camelCase and raw snake_case mint responses are accepted (see below).
partnerSlugstringRequired- Your partner slug, assigned during onboarding. Used to resolve the iframe’s security policy before any token exists.
appearanceAppearance- Visual overrides applied inside the modal:
colorPrimary(CSS color),radius(e.g."8px"),theme("light" | "dark", defaults to the page’s scheme). localestring- BCP-47 tag, e.g.
"es". Defaults to the page language. embedOriginstring- Override the embed origin. Staging/development only.
// Either shape is accepted by fetchSession:
{ sessionToken: string, expiresIn?: number, whatsapp?: { status, displayPhoneNumber } }
{ session_token: string, expires_in?: number, whatsapp?: { status, display_phone_number } }The Auphere client
getStatus()() => ConnectionStatus- Last known WhatsApp connection state:
"connected" | "not_connected" | "unknown". Starts as"unknown"until the first session mint. refreshStatus()() => Promise<ConnectionStatus>- Re-mints a session (via
fetchSession) and returns the refreshed status. onStatusChange(listener)(s: ConnectionStatus) => void- Subscribes to status flips. Returns an unsubscribe function.
openBroadcast(options)(o: OpenBroadcastOptions) => Promise<void>- Opens the broadcast modal as a fullscreen iframe overlay.
options.recipientsis the audience (see Broadcasts);onDone({ broadcastId, accepted })fires when the broadcast is accepted;onExit()when the modal closes. The returned promise rejects if the modal fails to initialize (e.g. token mint fails). connectWhatsApp(options?)(o?: ConnectWhatsAppOptions) => Promise<void>- Opens the WhatsApp Embedded Signup flow.
onConnected({ displayPhoneNumber })fires on success;onExit()when the modal closes. destroy()() => void- Closes any open overlay and removes all listeners. Call it when your page or component unmounts.
React — AuphereBroadcastButton
Imported from @auphere/embed/react. Renders a button only when the client’s WhatsApp is connected; clicking it opens the broadcast modal.
auphereAuphereRequired- The client created with
createAuphere. recipientsBroadcastRecipient[]Required- The audience, built from your data.
onDonefunction- Same semantics as
openBroadcast’sonDone. classNamestring- Class for the rendered button — style it like any button of yours.
childrenReactNode- Button label.
REST API
Base URL https://api.auphere.com, authenticated with Authorization: Bearer ak_live_… from your backend only. Two endpoints:
POST /v1/widget-sessions
Exchanges your API key for a short-lived session token (15 minutes) scoped to one client. The response also carries the client’s WhatsApp status, so your backend can decide what UI to render.
POST https://api.auphere.com/v1/widget-sessions
Authorization: Bearer ak_live_…
Content-Type: application/json
{ "external_client_ref": "3f6c1a2e-9d41-4b7f-8f2a-0c5d9e1b7a44" }{
"session_token": "eyJhbGciOiJIUzI1NiIs…",
"expires_in": 900,
"whatsapp": { "status": "connected", "display_phone_number": "+58 424-1234567" }
}POST /v1/partners/clients
Provisions (or updates) a client workspace. Idempotent on external_client_ref. Full request/response documented in Provisioning clients.
Error responses
| Status | Meaning |
|---|---|
401 | API key missing, revoked or malformed. |
403 | The session token lacks the required scope, or the key/partner was suspended. Re-mint the token. |
409 | Conflict — e.g. the WhatsApp number is already linked to another workspace. |
413 | Broadcast audience exceeds your per-send cap. |
422 | Validation error — the detail field says exactly what is missing or invalid (placeholder, credential, positional template parameters…). |
429 | Rate limit exceeded for your partner account. Back off and retry. |