The Connect Widget is a hosted, embeddable UI that handles the entire WhatsApp connection flow on your behalf. Your backend creates a short-lived widget session, your frontend embeds the resulting URL, and the user completes the flow — scanning a QR code, entering a pairing code, or clicking through Meta Embedded Signup — all inside the same widget. When the connection succeeds, Titan notifies your app via aDocumentation Index
Fetch the complete documentation index at: https://docs.usetitan.app/llms.txt
Use this file to discover all available pages before exploring further.
postMessage event or a redirect callback.
Widget modes
The widget supports four modes. Choose based on the connection methods you want to offer:| Mode | Tabs shown | Best for |
|---|---|---|
all | QR + Pairing + Cloud API | Letting the user choose their preferred method |
qr | QR code only | Multi-device linking via scan |
pairing | Phone number code only | Users without a camera or on desktop |
cloud-api | Meta Embedded Signup only | Connecting numbers via the official Cloud API |
Integration
Step 1 — Create a widget session (backend)
CallPOST /api/widget/sessions from your server using your API key. Never expose your API key to the browser.
201):
session value — it’s the name you’ll use to send messages once the user connects. The widgetUrl is the URL to embed.
Step 2 — Embed the widget (frontend)
Pass thewidgetUrl from your server to your frontend and embed it using one of three options:
- Script tag
- iframe
- Programmatic
The simplest option. The loader creates an iframe automatically from the
data-widget-url attribute.Step 3 — Listen for the connection event
When the user successfully connects, the widget posts a message to the parent window. Listen for it:Redirect callback
If you prefer a server-side callback overpostMessage, pass a callbackUrl when creating the widget session. After the user connects, the widget redirects them to:
| Parameter | Value |
|---|---|
session | The session name from the widget session response |
status | connected on success |
method | qr, pairing, or cloud-api |
Custom session name
By default Titan generates a random session name likewidget-lz1abc-x9f2. To use your own naming convention, pass sessionName:
BYOA — Bring Your Own Meta App
If you are a platform building on top of Titan and your customers have their own Meta Apps, you can pass their credentials so the Meta Embedded Signup popup shows their branding instead of yours:BYOA requires your customer to be at least an Independent Tech Provider with
Meta and to have the WhatsApp product with Embedded Signup enabled on their
Meta App.
Security
Widget tokens are designed to be safely embedded in iframe URLs:- Short-lived — tokens expire after 15 minutes
- Scoped — each token is bound to a single session and tenant
- HMAC-signed — tampering is detected before the widget page loads; a tampered or expired token returns
403 - Not your API key — the widget token has no ability to call other API endpoints
Troubleshooting
| Issue | Likely cause | Fix |
|---|---|---|
| ”Missing widget token” | No ?token= in the URL | Use the full widgetUrl from the API response, not just the base URL |
| ”Invalid widget token” | Token expired (>15 min) or tampered | Create a new widget session and embed the new URL |
| QR code never appears | Session failed to start | Check that the session was created successfully and your API key has sessions:manage scope |
| Meta signup tab missing | META_APP_ID not configured, or mode is not cloud-api or all | Use mode: "cloud-api" and ensure your account has Cloud API enabled, or pass metaApp for BYOA |
postMessage not received | Checking wrong event properties | The widget posts to *; verify your listener checks event.data.type === 'titan:widget' |