WhatsApp accounts API
List connected WhatsApp numbers API
Get the WhatsApp numbers in your workspace that are connected right now. Use it to let users pick which number to send from, or to find the whatsapp_client ID for other API calls.
https://wbiztool.com/api/v1/whatsapp-client/list/Body: JSON or form fields
Only connected numbers are returned. To also see numbers that are disconnected, use List accounts.
Quick example#
curl -X POST https://wbiztool.com/api/v1/whatsapp-client/list/ \
-H "Content-Type: application/json" \
-d '{
"client_id": 12345,
"api_key": "YOUR_API_KEY"
}'import requests
response = requests.post(
"https://wbiztool.com/api/v1/whatsapp-client/list/",
json={
"client_id": 12345,
"api_key": "YOUR_API_KEY",
},
timeout=30,
)
result = response.json() # read the body even when the HTTP code is 400 or 403
if result.get("status") == 1:
for number in result["whatsapp_clients"]:
print(number["whatsapp_client_id"], number["whatsapp_client_number"])
else:
print("Failed:", result.get("message"))// Node.js 18+ (built-in fetch). Save as .mjs to use top-level await.
const response = await fetch("https://wbiztool.com/api/v1/whatsapp-client/list/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
client_id: 12345,
api_key: "YOUR_API_KEY",
}),
});
const result = await response.json(); // read the body even when the HTTP code is 400 or 403
if (result.status === 1) {
for (const number of result.whatsapp_clients) {
console.log(number.whatsapp_client_id, number.whatsapp_client_number);
}
} else {
console.error("Failed:", result.message);
}<?php
$payload = [
'client_id' => 12345,
'api_key' => 'YOUR_API_KEY',
];
$ch = curl_init('https://wbiztool.com/api/v1/whatsapp-client/list/');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (($result['status'] ?? 0) === 1) {
foreach ($result['whatsapp_clients'] as $number) {
echo $number['whatsapp_client_id'] . ' ' . $number['whatsapp_client_number'] . PHP_EOL;
}
} else {
echo 'Failed: ' . ($result['message'] ?? 'no response');
}Replace 12345 and YOUR_API_KEY with your own values. See Authentication for where to find them.
Request parameters#
client_idintegerrequiredYour API Client ID from Settings → API keys.
api_keystringrequiredYour API key from the same page. The list is for the workspace this key was created in.
Using the official clients#
The Python client calls this endpoint for you.
from wbiztool_client import WbizToolClient
client = WbizToolClient(api_key="YOUR_API_KEY", client_id=12345)
result = client.list_whatsapp_clients()
for number in result.get("whatsapp_clients", []):
print(number["whatsapp_client_id"], number["whatsapp_client_number"])The Python client raises requests.exceptions.HTTPError when the API returns HTTP 400 or 403, so wrap the call in try/except.
The Node.js client's getWhatsAppClients() calls an address that doesn't exist and fails with a 404. Use fetch as in the Quick example.
Response#
A successful request returns HTTP 200:
{
"message": "okay",
"whatsapp_clients": [
{
"id": 678,
"whatsapp_client_id": 678,
"whatsapp_client_number": "919876543210",
"is_connected": true
}
],
"status": 1
}
| Field | Type | Description |
|---|---|---|
status | integer | 1 on success, 0 if the request failed. |
message | string | okay on success, otherwise the error. |
whatsapp_clients | array | Your connected numbers. Empty if none are connected. Only present on success. |
whatsapp_clients[].whatsapp_client_id | integer | The number's ID. Pass it as whatsapp_client in other API calls. |
whatsapp_clients[].id | integer | Same value as whatsapp_client_id. |
whatsapp_clients[].whatsapp_client_number | string | The phone number as it was saved when the number was added. |
whatsapp_clients[].is_connected | boolean | Always true, because only connected numbers are listed. |
The list isn't sorted in any guaranteed order. Sort by whatsapp_client_id if order matters.
Errors#
| Message | HTTP | How to fix it |
|---|---|---|
Auth Error | 200 | Send both client_id and api_key in a POST body, as valid JSON or form fields. |
Invalid Client Id | 403 | Send client_id as a whole number, such as 12345. |
Auth Error: invalid api key | 400 | Check the key exists, hasn't been deleted and belongs to this client_id. |
A request that isn't a POST returns an empty object {}. An unexpected server problem returns HTTP 500 with an HTML body, so check that the response is JSON before reading status.
Tips#
- Empty list:
"whatsapp_clients": []means no number is connected in this workspace. Connect one in WhatsApp settings or with Connect a number. - Several workspaces: the API key decides which workspace is listed. Use a key created in the workspace you want.
- One number only: to check a single number, use Connection status.
