Link WhatsApp with a code
Link the user's WhatsApp to WhatSync without the website, or link it again after the phone was logged out.
- Key permissions
- Read chats and messages + Change saved chats and filters
- Authentication
Authorization: Bearer $WHATSYNC_API_KEY
How keys work
How it works
- Ask the user for their WhatsApp number with country code, then call this: WhatsApp sends a notification to that phone and the result has an 8-character
pairing_codethe user types on the phone (Linked devices, Link a device, Link with phone number instead). - Then call
check_whatsapp_link. - Codes are limited per account and per phone; never call it in a loop.
Body parameters
idempotencyKeystringbody or headerA fresh random UUID for each new action; never build it from dates, names, counters or step numbers, which repeat across runs. Reuse it exactly only to retry the same action.
phoneNumberstringrequiredThe WhatsApp number to link, in international format with country code, such as +919876543210
fromNumberstringoptionalWhich of the account's WhatsApp numbers acts, with country code, as listed in whatsapp_numbers from get_account_context. Only matters when the account has several numbers. Omit for the account's first number.
Conditions and pagination
- Use a unique idempotency key for each intended action. Reuse the same key and exactly the same input on a retry. The body key takes precedence over Idempotency-Key.
Response
The response wraps tool-specific data in result. Save operation_id and inspect get_operation with operationId if the outcome is uncertain. completed means the operation completed; it does not prove message delivery or Meta approval. An uncertain operation returns HTTP 409 with error.operation_id.
Every response includes X-Request-Id. Errors use the shared error format and retry rules.
Schemas
Input JSON Schema
{
"type": "object",
"properties": {
"idempotencyKey": {
"type": "string",
"pattern": "^[A-Za-z0-9._:-]{8,128}$",
"description": "A fresh random UUID for each new action; never build it from dates, names, counters or step numbers, which repeat across runs. Reuse it exactly only to retry the same action."
},
"phoneNumber": {
"type": "string",
"minLength": 7,
"maxLength": 30,
"description": "The WhatsApp number to link, in international format with country code, such as +919876543210"
},
"fromNumber": {
"type": "string",
"minLength": 7,
"maxLength": 30,
"description": "Which of the account's WhatsApp numbers acts, with country code, as listed in whatsapp_numbers from get_account_context. Only matters when the account has several numbers. Omit for the account's first number."
}
},
"required": [
"idempotencyKey",
"phoneNumber"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}Response JSON Schema
{
"type": "object",
"properties": {
"operation_id": {
"type": "string",
"format": "uuid"
},
"status": {
"type": "string",
"enum": [
"completed"
]
},
"replayed": {
"type": "boolean"
},
"result": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"code_ready",
"already_linked",
"reconnecting",
"paused",
"linking",
"no_code"
]
},
"pairing_code": {
"type": "string"
},
"expires_at": {
"type": [
"string",
"null"
]
},
"steps": {
"type": "array",
"items": {
"type": "string"
}
},
"phone_number": {
"type": [
"string",
"null"
]
},
"dashboard_link": {
"type": "string"
},
"note": {
"type": "string"
}
},
"required": [],
"additionalProperties": true
},
"note": {
"type": [
"string",
"null"
]
}
},
"required": [
"operation_id",
"status",
"result"
],
"additionalProperties": true
}