Pair Account
wa_pair_accountBegin linking a new WhatsApp account — or a Telegram account, with network set to telegram. For WhatsApp there are two ways to link and the right one depends on the user's devices, so ASK FIRST: if they can scan a QR code from another screen (a second phone, or this computer's screen) using the WhatsApp app on their phone, call this with no phone and show the returned QR PNG; if they only have the one phone that runs WhatsApp — it cannot scan its own screen — pass phone in international format to get an 8-character code they type on that phone instead. A Telegram account links by QR only, scanned from Telegram → Settings → Devices → Link Desktop Device; if it has two-step verification the state becomes password_needed and the user enters their cloud password on the console's pairing page (never through a tool). Then poll wa_pair_status with the returned pair_id: a QR re-arms about every 20 seconds (show the newest each time), a phone code lasts a few minutes, and either way the state turns "paired" once it is linked. Pass import_history to choose whether a WhatsApp pairing loads the phone's recent messages as history.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phone | No | link by phone-number code instead of a QR: the number to link, in international format with its country code (for example +52 998 123 4567). WhatsApp on that phone is asked to accept an 8-character code, returned as pair_code. Use it when the user has only the one phone that runs WhatsApp and cannot scan a QR from another screen (WhatsApp only) | |
| network | No | the messaging network of the account to link: whatsapp (the default) or telegram. A Telegram account links by QR only: the user scans it from Telegram → Settings → Devices → Link Desktop Device. Telegram accounts must be enabled for the workspace, or the call is refused | |
| import_history | No | import the phone's recent message history (about two months) as read-only history for this pairing; omit to use the workspace default (WhatsApp only) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| state | Yes | starting, qr, code, password_needed (a Telegram account with two-step verification: the user must enter their cloud password on the console's pairing page — never ask for it here), paired or failed | |
| network | No | the messaging network the pairing links on: whatsapp or telegram | |
| pair_id | No | pass this to wa_pair_status to follow the pairing | |
| refusal | No | present only when pairing could not be started | |
| pair_code | No | the 8-character code the user types on their phone (phone-number pairing only) | |
| expires_at | No | when pair_code stops working, RFC 3339 (phone-number pairing only) | |
| needs_plan | No | true when the linked number has no plan yet and will not run until the user buys one in the console | |
| instructions | No | what to tell the user to do | |
| qr_png_base64 | No | a PNG image of the QR code, base64 encoded — display this to the user |