Kapso runs messaging
Use@kapso/sdk to open onboarding from your product. Your backend creates the setup link; the browser receives only its token, never your Kapso API key.
Requirements
- an active Multi-partner Solution with Messages processed by: Kapso
- the browser origin in the setup link’s
allowed_origins - the same HTTPS domain added in Meta’s Facebook Login for Business settings
dedicated or coexistence. Create separate setup links if your product offers both paths.
Install the SDK
Create a setup link on your backend
Keep your Kapso API key on the server. Create one setup link for the customer and specify every browser origin that may launch it.data.token to your frontend. Do not expose your Kapso API key.
Connect from the browser
Configure the setup path
The setup link controls the customer experience:allowed_connection_types: ["dedicated"]— API-only WhatsApp numberallowed_connection_types: ["coexistence"]— keep using WhatsApp Business Appprovision_phone_number: true— use a Kapso-provided or project-pool numbermeta_billing_mode: "partner_managed"— use Kapso credits for Meta fees
Handle cancellation and errors
Catch SDK initialization failures separately from connection failures. Keepconnect() inside the button’s click handler so the browser allows Meta’s popup.
whatsapp.destroy() if your application removes the onboarding component before setup completes.
Confirm connection on your backend
Use the browser result for immediate UI feedback. For server-side reliability, subscribe to Kapso project webhooks and listen forwhatsapp.phone_number.created.
See Detect connection and Webhooks.
You run messaging
Use the Meta JavaScript SDK and your own backend. This path does not use@kapso/sdk, a Kapso setup link, or Kapso’s onboarding endpoints. You own registration, messaging, and message webhooks; Kapso provides managed billing.
Prepare your Meta app
- Activate a Multi-partner Solution with Messages processed by: Your infrastructure and App with messaging permission: Your Meta app.
- Copy the Meta solution ID from Tenants > Multi-partner solution. This is not the Meta App ID or a Kapso UUID.
- Create a Facebook Login for Business configuration for your Tech Provider app, using WhatsApp Embedded Signup v4 and the products you need.
- Add your HTTPS domain and OAuth redirect URIs in Meta’s login settings. Kapso setup-link
allowed_originsdoes not apply to this path. - Configure your webhook endpoint and subscribe your Meta app to
account_updateandmessages.
Launch Embedded Signup
If you already have Embedded Signup, addextras.setup.solutionID to your existing FB.login options. Keep the SDK initialization and flow options appropriate for your configuration.
For a new v4 integration, this example initializes Meta once and enables the button only after FB.init completes:
solutionID is case-sensitive and belongs inside extras.setup, not at the top level. Keep it as a string. The Solution ID links the customer’s authorization to both partners. See Meta’s Multi-partner Solution instructions.
If you offer multiple solutions, select the correct App ID, configuration ID, and Solution ID for the customer before enabling the button. Store that expected context with the onboarding attempt on your backend.
Complete onboarding on your backend
The example’s/api/whatsapp/onboarding/complete is an endpoint in your application. Protect it with your normal authentication and CSRF controls; adapt the request headers to your framework. Bind the attempt to the signed-in customer.
- Exchange
codethrough Meta’sGET /oauth/access_token, using your App ID and app secret. Store the returned business token securely on your server; do not log it or return it to the browser. - Resolve the authorized WABA and phone number using that token. If multiple assets are available, confirm the customer’s selection rather than choosing the first result. You can also collect IDs through Meta’s
WA_EMBEDDED_SIGNUPbrowser event: validate the event origin and verify asset access server-side. Browser-supplied IDs are not proof of ownership or funding. - Subscribe your app to the customer’s WABA with
POST /{WABA_ID}/subscribed_appsso your backend receives message webhooks. - Register the phone number with
POST /{PHONE_NUMBER_ID}/registerwhen required by the selected flow. The example targets the standard Cloud API flow; follow Meta’s separate requirements for coexistence, migrations, or WABA-only signup. - Persist the connection in your system. Return success only after the required backend setup completes.
Confirm managed funding in Kapso
Meta notifies Kapso throughaccount_update when the customer joins the solution. Kapso detects the WABA and attempts to fund it automatically, subject to eligibility and your project’s prepaid balance. You do not need to send Kapso the customer’s authorization code or business token.
Open Tenants > Multi-partner solution, find the WABA, and confirm that managed funding is verified before sending paid messages. A successful signup callback or a detected WABA alone does not confirm funding. If the account shows Needs attention, resolve the displayed issue first.
External onboarding does not create a Kapso WhatsApp configuration or emit the hosted path’s whatsapp.phone_number.created event. Your own backend tracks connection completion; the Kapso account table tracks funding and aggregate usage.
If the WABA does not appear, check that signup used the exact active Solution ID and the correct Meta app. If those match, contact Kapso with the Solution ID, WABA ID, and signup time. Do not send secrets or access tokens.
Once funded, keep sending through your own Meta integration. Kapso checks Pricing Analytics about every five minutes; usage can arrive later. Kapso cannot block sends made through your infrastructure, so keep enough balance for usage between checks. See managed billing and beta limitations.
