Skip to content
Wbiztool

WhatsApp accounts API

Connect a WhatsApp number (API)

Start connecting a WhatsApp number to your workspace from your own app. Wbiztool opens a new WhatsApp session and sends the QR code to your webhook URL. Show it to the owner of the phone, they scan it from WhatsApp, and the number is ready to send messages.

Linking your own number by hand? Follow Connect your WhatsApp number.

POSThttps://wbiztool.com/api/v1/whatsapp/connect/

Body: JSON or form fields

POST /api/v1/whatsapp-client/create/ is an identical alias: it runs the same code and returns the same responses. Both paths keep working.

How connecting works#

The API call only starts the connection. The QR code arrives later, at your webhook URL.

  1. Call the connect API

    Send the phone number and your webhook_url. The response gives you a whatsapp_client_id. Save it.

  2. Receive the QR code

    Your webhook receives status=qr_generated with the QR image in qr_image. Show that image to the person who owns the phone. The QR code is sent again every several seconds while Wbiztool waits for a scan, so always show the latest one. The person has about two minutes to scan. After that, or if WhatsApp asks to reload the code, you receive not_connected; call the API again to get a new code.

  3. Scan it from WhatsApp

    On the phone, open WhatsApp → Linked devicesLink a device and scan the code.

  4. Get the result

    Your webhook receives status=connected when the number is linked, or status=not_connected if the code wasn't scanned in time or the connection failed. The connected event can arrive a few seconds before Connection status returns Connected. Reply to the webhook first, then poll Connection status every few seconds for up to a minute. Don't check it once from inside your webhook handler.

Quick example#

curl -X POST https://wbiztool.com/api/v1/whatsapp/connect/ \
  -H "Content-Type: application/json" \
  -d '{
    "client_id": 12345,
    "api_key": "YOUR_API_KEY",
    "whatsapp_number": "919876543210",
    "webhook_url": "https://example.com/wbiztool/connect-events?token=LONG_RANDOM_SECRET"
  }'

Replace 12345 and YOUR_API_KEY with your own values. See Authentication for where to find them.

Request parameters#

client_idintegerrequired

Your API Client ID from Settings → API keys.

api_keystringrequired

Your API key from the same page. The number is added to the workspace this key was created in.

whatsapp_numberstringrequired

The WhatsApp number to connect, with country code, such as 919876543210. It's saved exactly as you send it (up to 20 characters), so send digits only, without +, spaces or dashes. Longer values fail with HTTP 500. The same number written differently counts as a different number.

webhook_urlstringRequired to receive the QR code

Your http or https URL that receives the QR code and connection updates, up to 250 characters (longer URLs fail with HTTP 500). The API accepts a request without it, but then nothing is sent to you and you have no way to get the QR code through the API. See Webhook events.

Using the official clients#

The Python client calls /api/v1/whatsapp-client/create/ for you.

Python
from wbiztool_client import WbizToolClient

client = WbizToolClient(api_key="YOUR_API_KEY", client_id=12345)

result = client.create_whatsapp_client(
    whatsapp_number="919876543210",
    webhook_url="https://example.com/wbiztool/connect-events?token=LONG_RANDOM_SECRET",
)
print(result)

The Python client raises requests.exceptions.HTTPError when the API returns HTTP 400 or 403, so wrap the call in try/except.

Response#

When the connection request is created, the API returns HTTP 200:

{
  "message": "Whatsapp Client Created",
  "whatsapp_client_id": 678,
  "status": 1
}
FieldTypeDescription
statusinteger1 if the connection request was created, 0 if it failed.
messagestringWhatsapp Client Created on success, otherwise the error.
whatsapp_client_idintegerID of the WhatsApp number. Use it as whatsapp_client in other API calls. Only present on success.

"status": 1 means the request was created, not that the number is connected. If you call the API again for a number that was added before but isn't connected, you get the same whatsapp_client_id back and a new connection attempt starts.

Errors#

MessageHTTPHow to fix it
whatsapp_number cant be null200Send whatsapp_number. This is checked first, so it also appears when the JSON body is invalid.
Auth Error200Send both client_id and api_key.
Invalid Client Id403Send client_id as a whole number, such as 12345.
Auth Error: invalid api key400Check the key exists, hasn't been deleted and belongs to this client_id.
Higher Subscription Required200Your plan doesn't include this API. Upgrade your plan.
WhatsApp Account Limit Reached. Upgrade your account to get more whatsapp limit200You already have as many connected numbers as your plan allows. Disconnect one or upgrade.
Already Connected With Given Number200This number is already connected in this workspace. Nothing to do. If you're already at your plan's number limit, you get WhatsApp Account Limit Reached instead, even for a number that's already connected.

A request that isn't a POST returns an empty object {} with HTTP 200.

If the same account owner already added this number in a different workspace, the request can fail with HTTP 500. Connect the number from WhatsApp settings in the workspace you want, or contact support.

Webhook events#

Wbiztool sends a POST to your webhook_url at each step. The body is form-encoded (application/x-www-form-urlencoded), not JSON.

QR code ready (sent again every several seconds while waiting for a scan, often with the same URL):

status=qr_generated&whatsapp_client_id=678&qr_image=...

Number connected (can be sent more than once for the same connection):

status=connected&whatsapp_client_id=678

Connection failed, for example because the QR code wasn't scanned in time:

status=not_connected&whatsapp_client_id=678
FieldValues
statusqr_generated, connected or not_connected
whatsapp_client_idThe whatsapp_client_id returned by the API.
qr_imageOnly with qr_generated. Either a data: URL containing the image as base64, or an https URL of the image. Handle both. The https URL stays the same for every refresh of the same number, while the image behind it changes. Add a cache-busting query when you display it (for example ?t=<timestamp>), or the browser may keep showing an expired code.

Your URL must be publicly reachable and should answer within a few seconds. Wbiztool waits for your reply with no timeout. If your server can't be reached, the connection attempt can stop before the number is saved as connected. Any HTTP status code is accepted. Failed deliveries aren't retried, and nothing is sent if the number disconnects later on. To follow a number after it's connected, poll Connection status.

Polling instead of webhooks#

If your server can't receive webhooks, you still need the webhook to get the QR code, but you don't have to rely on it for the result. After the QR code is scanned, call Connection status with the whatsapp_client_id every few seconds until it returns Connected. List accounts shows the same thing for all your numbers.

Tips#

  • Handle duplicate events: connected can arrive twice. Make your handler safe to run more than once.
  • Show the newest QR code: replace the image each time a new qr_generated event arrives, adding a cache-busting query to an https URL. Older codes stop working.
  • Scan within about two minutes: after that you get not_connected. Call the API again for a new code.
  • No QR code after 10 minutes? The request expired. Call the API again.
  • Connecting from the dashboard is simpler when you're linking your own number. Use WhatsApp settings and scan the code there.