Overview
The Connection SDK is a ready-made modal you embed in your own software. Your customer clicks “connect”, scans the QR code (or uses their phone number), and their Z-API instance connects — without you building any screen.- Loads with a single
<script>tag — exposeswindow.ZAPIConnector. - Framework-agnostic (React, Vue, Angular, plain HTML…).
- Isolated via Shadow DOM: your site’s CSS can’t affect the modal, and the modal can’t affect yours.
- Themeable (light/dark + colors) and translatable (pt/en, or your own strings).
Try the playground
Generate a token, pick the options and open the connector live at
https://app.z-api.io/demo.html.The SDK covers the same scenarios as the Z-API panel: QR code, phone number,
passkey authentication (extension) and migrating an already-connected WhatsApp
Web session.
How it works
Integration has three parts: your backend generates a session token, your site loads the SDK and opens the connector with that token.1
Your backend generates the token
Your server calls Z-API (with your Client-Token) and gets a short, disposable session token. See generate the SDK token.
2
Your site loads the SDK
Add the
<script> tag that exposes window.ZAPIConnector.3
Your site opens the connector
Call
ZAPIConnector.open({ token }) with the token returned by the backend.1. Generate the token (on your backend)
The one talking to Z-API is your backend, because this call uses your Client-Token, which must never reach the browser.token to your frontend as-is. Full endpoint reference: Generate the SDK token.
2. Load the SDK
Add the<script> tag to your page. This URL always serves the latest version — you don’t need to update anything when we ship fixes and improvements.
window.ZAPIConnector globally.
3. Open the connector
When the customer clicks connect, fetch the token from your backend and callopen(). It returns a Promise<boolean> that stays pending until the modal closes and resolves true if the channel connected:
Options
ZAPIConnector.open(options) accepts:
Themes
Pass a mode ("light" or "dark"), or a ThemeOptions object to override specific colors per mode:
ThemeColors, all optional):
Language
Built-in languages:pt and en (detected from navigator.language). Force one with locale:
messages — a partial map merged over the selected locale. Pass only the keys you want to change:
Connection methods
By default the modal shows QR code, phone number and the migration link. Usemethods to show only what you want:
When only one method is enabled, the tabs are hidden (it goes straight to it).
If you disable QR and phone at the same time, the SDK re-enables both so the
modal is never left without a way to connect.
Message queue
An instance may have messages in the queue (piled up while it was disconnected). On connect, they’re all sent at once. That’s why, before connecting, the modal shows how many messages are queued and offers a clear option — avoiding a burst of messages the moment it connects. The count refreshes automatically every 10 seconds while the modal is open. To hide this notice, passshowQueue: false:
Expired instance
If the instance’s usage period ends, WhatsApp stops accepting the connection. In that case, instead of a QR code that won’t load, the modal shows an expired instance screen. Re-subscribing is a backend action (billing), so the “Subscribe again” button only appears if you pass anonSubscribe callback. When clicked, the modal calls your callback — where you kick off your subscription flow (call your backend, redirect to your pricing page, etc.):
onSubscribe, the screen shows only the expiration message. In both cases, the status event fires with "expired". If the instance is re-subscribed while the modal is still open, it reconnects on its own.
Events
Track the connection lifecycle withon / off:
Methods
Messages
Every string in the modal can be overridden viamessages. Below, each key, its default English value and what it’s for. Pass only the keys you want to change.