Skip to main content

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 — exposes window.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.
curl --location 'https://api.z-api.io/instances/{instanceId}/token/{instanceToken}/sdk-connector-token' \
--header 'Client-Token: YOUR_CLIENT_TOKEN'
Response:
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Return that token to your frontend as-is. Full endpoint reference: Generate the SDK token.
The token is generated by your backend and is single-use for the connector. Never expose your Client-Token or the instance credentials (instanceId and token) in the frontend.

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.
<script src="https://app.z-api.io/sdk.js" async></script>
This exposes window.ZAPIConnector globally.

3. Open the connector

When the customer clicks connect, fetch the token from your backend and call open(). It returns a Promise<boolean> that stays pending until the modal closes and resolves true if the channel connected:
async function connect(instanceId) {
  const { token } = await fetch(`/sdk-token/${instanceId}`).then((r) =>
    r.json(),
  );

  const connected = await ZAPIConnector.open({ token });
  if (connected) {
    refreshInstances();
  }
}

Options

ZAPIConnector.open(options) accepts:
OptionTypeDescription
tokenstring (required)Session token returned by your backend. Pass it as-is — the SDK picks the connection experience from it.
theme"light" | "dark" | ThemeOptionsColor theme. Default: "light". See Themes.
locale"pt" | "en" | stringUI language. Auto-detected from the browser when omitted.
messagesPartial<Messages>Override individual strings or translate to another language. See Messages.
methods{ qr?, phone?, migrate? }Which connection options to show. Each is true by default. See Connection methods.
containerstring | HTMLElementWhere to mount the modal. Default: document.body.

Themes

Pass a mode ("light" or "dark"), or a ThemeOptions object to override specific colors per mode:
ZAPIConnector.open({
  token,
  theme: {
    mode: "dark",
    light: { accent: "#25d366" },
    dark: { accent: "#00a884", surface: "#111b21" },
  },
});
Color tokens (ThemeColors, all optional):
TokenDescription
overlayDimmed backdrop behind the modal
surfaceModal card background
surfaceAltSecondary background (tabs, fields, boxes)
textPrimary text color
textMutedSecondary text color
borderBorder color
accentAccent color (buttons, links, highlights)
accentContrastText color on top of the accent color

Language

Built-in languages: pt and en (detected from navigator.language). Force one with locale:
ZAPIConnector.open({ token, locale: "en" });
To tweak wording or translate to a non-built-in language, use messages — a partial map merged over the selected locale. Pass only the keys you want to change:
ZAPIConnector.open({
  token,
  messages: {
    title: "Connect your number",
    subtitle: "Point your WhatsApp camera at the code.",
  },
});

Connection methods

By default the modal shows QR code, phone number and the migration link. Use methods to show only what you want:
ZAPIConnector.open({ token, methods: { phone: false, migrate: false } });
KeyDescription
qrQR code tab. Default true.
phonePhone number tab. Default true.
migrateLink to migrate an existing WhatsApp Web session. Default true.
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.

Events

Track the connection lifecycle with on / off:
ZAPIConnector.on("connected", () => refreshInstances());
ZAPIConnector.on("status", ({ status }) => console.log(status));

ZAPIConnector.off("connected", handler);
EventPayloadFired when
connected{ phone? }the channel connected
disconnected{ reason? }it dropped or was disconnected
qr{ base64 }a new QR code was rendered
status{ status }status changed ("qr", "connected" or "disconnected")
error{ error }an error occurred
closethe user closed the modal

Methods

MethodReturnsDescription
open(options)Promise<boolean>Opens the modal; resolves when it closes (true if connected).
close()voidCloses the modal programmatically.
on(event, handler)voidSubscribe to an event.
off(event, handler)voidUnsubscribe.

Messages

Every string in the modal can be overridden via messages. Below, each key, its default English value and what it’s for. Pass only the keys you want to change.

Home screen and QR code

KeyDefaultDescription
titleConnect your WhatsAppModal title
subtitleScan the QR code with your phone to connect.Subtitle below the title
step1Open WhatsApp on your phoneQR instructions step 1
step2Tap Settings, then Linked devicesQR instructions step 2
step3Tap Link a device and scan this codeQR instructions step 3
qrLoadingGenerating QR code…Text while the QR loads
qrErrorCould not load the QR code. Please try again.Error loading the QR
closeCloseClose button label (aria)
tabQrQR codeQR code tab label
tabPhonePhone numberPhone number tab label

Phone connection (web)

KeyDefaultDescription
phoneHintEnter your WhatsApp number to receive a pairing code.Phone tab instruction
countrySearchSearch countryCountry search placeholder
phonePlaceholderPhone numberPhone field placeholder
submitContinueButton to generate the code
phoneSendingGenerating code…Button state while generating
codeHintEnter this code in WhatsApp:Instruction above the pairing code
codeStep3Tap Link with phone number and enter the codeStep to enter the code in WhatsApp
codeBackUse another numberBack to enter a different number

Phone connection flow (mobile instances)

KeyDefaultDescription
mVerifyingChecking number…Verifying the entered number
mMethodHintHow do you want to receive the code?Choose the code delivery method
mSmsSMSReceive via SMS
mCallCallReceive via call
mWhatsappWhatsAppReceive via WhatsApp
mSendingSending…Sending the code
mCodeHintEnter the code you receivedPrompt to enter the received code
mWaOldHintOpen WhatsApp on your phone — you’ll receive the code there. Enter it below.WhatsApp method instruction
mConfirmConfirmConfirm the code
mConfirmingConfirming…State while confirming
mCaptchaHintType the characters in the imageCaptcha instruction
mSecurityHintEnter your PIN (two-step verification)Two-step PIN instruction
mForgotPinForgot PINPIN recovery link
mConfirmOnPhoneConfirm on your phone, then tap ConfirmConfirmation on the device
mErrorSomething went wrong. Please try again.Generic error
mWrongCodeWrong code. Try again.Wrong code entered
mBlockedThis number is blocked by WhatsApp.Number blocked
mUnblockRequest unblockButton to request unblock
mNoRoutesWe couldn’t send the code right now. Check the number and try another method.No delivery route available
mRateLimitToo many attempts. Please wait before trying again.Attempt limit reached
mBannedThis number is banned.Number banned
mBannedTextDescribe why this number should be unbanned:Appeal form text
mSendSendSend the appeal
mInReviewYour appeal is under review by WhatsApp.Appeal under review
mPinSentWe’ve sent PIN recovery instructions.Recovery instructions sent
mPhoneOfflinePhone offline — messages may be delayed.Phone offline warning

Session migration

KeyDefaultDescription
migrateOrorSeparator before the migration link
migrateLinkClick here to migrate an already-connected WhatsApp Web sessionButton that opens the migration flow
migrateHintMigrate your WhatsApp Web session with the extension. Use this code:Migration screen instruction
migrateStep1Install the Z-API Connector extensionMigration step 1
migrateStep2Open web.whatsapp.com already connected on your computerMigration step 2
migrateStep3Open the extension and enter the code aboveMigration step 3
migrateBackBackBack from the migration screen

Connected

KeyDefaultDescription
connectedTitleConnectedSuccess screen title
disconnectDisconnectButton to disconnect the instance
disconnectingDisconnecting…State while disconnecting

Passkey authentication (extension)

KeyDefaultDescription
challengeTextConfirm the authentication on your device to connect this instance.Authentication screen instruction
challengeButtonResolve authenticationButton to resolve authentication
challengeSolvingAuthenticating…State while authenticating
challengeCancelCancelCancel authentication
installTitlePasskey authenticationExtension install screen title
installTextThe extension confirms your biometrics on this device to connect.Extension description
installStep1Install the extension and add it to your browserInstall step 1
installStep2Come back to this window — it continues automaticallyInstall step 2
installButtonInstall extensionGeneric install button
installChromeInstall on ChromeInstall-on-Chrome button
installFirefoxInstall on FirefoxInstall-on-Firefox button
unsupportedBrowserOpen this page in Chrome or Firefox to connect with a passkey.Warning on an unsupported browser

Try the playground

Open the SDK playground to generate a token, adjust theme, language and methods, and see the real connector in action.