Send WhatsApp messages with PHP
Send WhatsApp texts, images and files from your PHP site or app, from your own number linked to WbizTool like WhatsApp Web. All it takes is PHP's cURL extension and one POST to a documented endpoint.
Free trial: 50 messages in any 30 days, no card.
How it works
Get your API key and link your number
Sign up, then link your WhatsApp number on the WhatsApp numbers page with a QR code or a pairing code, like WhatsApp Web. On Settings → API keys, create a key and copy your Client ID (the API keys guide below shows where). The ID on the number's card (such as ID 678) is your
whatsapp_client.Build the request
Put
client_id,api_key,whatsapp_client, the phone number andmsgin an array. Send it as JSON with PHP's cURL extension – or with any HTTP client you already use, with the same fields.Send the message
POST it to
https://wbiztool.com/api/v1/send_msg/. A reply with"status": 1and amsg_idmeans the message is queued on your number.Check that it went out
Pass a
webhookURL to be told when the message is sent or fails, or ask the Message status endpoint with themsg_id.
PHP code examples
<?php
$payload = [
'client_id' => 12345,
'api_key' => 'YOUR_API_KEY',
'whatsapp_client' => 678,
'msg_type' => 0,
'country_code' => '91',
'phone' => '9876543210',
'msg' => 'Hi Aman, your order #4821 has shipped and will arrive on Thursday.',
];
$ch = curl_init('https://wbiztool.com/api/v1/send_msg/');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (($result['status'] ?? 0) === 1) {
echo 'Queued with msg_id ' . $result['msg_id'];
} else {
echo 'Failed: ' . ($result['message'] ?? 'no response');
}{"status": 1, "message": "Created", "msg_id": 9817263}<?php
$ch = curl_init('https://wbiztool.com/api/v1/send_msg/');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'client_id' => 12345,
'api_key' => 'YOUR_API_KEY',
'whatsapp_client' => 678,
'msg_type' => 1,
'country_code' => '91',
'phone' => '9876543210',
'img_url' => 'https://example.com/offers/diwali-sale.jpg',
'msg' => 'Our Diwali sale starts today 🎉',
]),
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);
curl_close($ch);<?php
$ch = curl_init('https://wbiztool.com/api/v1/send_msg/');
curl_setopt_array($ch, [
CURLOPT_POST => true,
// An array body (not json_encode) makes cURL send multipart/form-data.
CURLOPT_POSTFIELDS => [
'client_id' => 12345,
'api_key' => 'YOUR_API_KEY',
'whatsapp_client' => 678,
'msg_type' => 2,
'country_code' => '91',
'phone' => '9876543210',
'msg' => 'Your invoice for order #4821 is attached.',
'file_name' => 'invoice-4821.pdf',
'file' => new CURLFile('/path/to/invoice-4821.pdf', 'application/pdf', 'invoice-4821.pdf'),
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
]);
echo curl_exec($ch);
curl_close($ch);<?php
$payload = [
'client_id' => 12345,
'api_key' => 'YOUR_API_KEY',
'whatsapp_client' => 678,
'msg_type' => 0,
'country_code' => '91',
'phone' => '9876543210',
'msg' => 'Hi Aman, a reminder that your appointment is today at 11:30 AM.',
'date' => '24/12/2026',
'time' => '09:00',
'timezone' => 'Asia/Kolkata',
];
$ch = curl_init('https://wbiztool.com/api/v1/schedule_msg/');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (($result['status'] ?? 0) === 1) {
echo 'Scheduled with msg_id ' . $result['msg_id'];
} else {
echo 'Failed: ' . ($result['message'] ?? 'no message in response');
}<?php
$msgId = 9817263;
$payload = [
'client_id' => 12345,
'api_key' => 'YOUR_API_KEY',
];
$ch = curl_init("https://wbiztool.com/api/v1/message/status/{$msgId}/");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (($result['message'] ?? '') === 'Unknown message id') {
echo 'No message with this ID in your workspace';
} elseif (!isset($result['status_text'])) {
echo 'Request failed: ' . ($result['message'] ?? 'no message in response');
} elseif ($result['status'] === 1) {
echo 'Sent';
} elseif ($result['status'] === 2) {
echo 'Failed: ' . $result['error'];
} else {
echo 'Status: ' . $result['status_text'];
}<?php
// webhook.php – WbizTool posts form fields, so they arrive in $_POST.
$msgId = $_POST['msg_id'] ?? '';
$status = $_POST['status'] ?? ''; // SENT, FAILED, CANCELLED or EXPIRED
error_log("WbizTool message $msgId: $status");
http_response_code(200);What you can do
No library to install
The examples use only PHP's cURL extension. The API takes JSON, form fields, or multipart form data when you upload a file.
Texts, images and files
Set
msg_typeto 0 for text, 1 for an image or 2 for a file. Give a publicimg_urlorfile_url, or upload the file withCURLFile.Schedule for later
POST to
/api/v1/schedule_msg/withdate(dd/mm/yyyy),time(HH:MM) and atimezonesuch asAsia/KolkataorAmerica/New_York.Webhooks for every status
Pass
webhookand your script gets a form-encoded POST – read$_POST['msg_id']and$_POST['status'](SENT,FAILED,CANCELLEDorEXPIRED).On WordPress? Use the plugin
The WbizTool WordPress plugin sends WhatsApp messages for WooCommerce orders, WP Amelia bookings and Contact Form 7 forms without code.
Good to know
"status": 1means the message is queued, not delivered. Sent is the final success state; the API doesn't report whether the message was delivered or read.- Send message errors come back with HTTP 400 (429 at the daily limit); Schedule message errors usually come back with HTTP 200 and
"status": 0, so always decode the body and checkstatus. - For a file upload, pass an array to
CURLOPT_POSTFIELDS, notjson_encode, so cURL sendsmultipart/form-datawith the file in a field namedfile. - Keep the API key on your server, for example in an environment variable. Anyone who has it can send from your numbers, so never put it in browser JavaScript, a mobile app or code you publish.
- The free trial has 50 messages in any 30 days and 1 number, no card. Paid plans start at $25 a month in the US (your price is on Pricing) and send unlimited messages under fair use: up to 1,000 a day per number.
- Messages go out from your own WhatsApp number, so WhatsApp's own rules apply: message people who expect to hear from you.
Questions
- Is there a PHP SDK?
- There's no official PHP package, and you don't need one: each call is a single POST with the cURL extension, as shown above. Any PHP HTTP client works with the same URL and fields.
- How do I send an invoice PDF from PHP?
- Use
msg_type2. Either give a publicfile_url, or upload the file withnew CURLFile(...)in a field namedfile. Setfile_namewith its extension, such asinvoice-4821.pdf. - How do I know the message was sent?
- A reply with
"status": 1and amsg_idmeans it's queued. Pass awebhookURL to get a POST withSENT,FAILED,CANCELLEDorEXPIRED, or call the Message status endpoint with themsg_id. Sent is the final state: the API doesn't report delivered or read. - Which phone number format should I send?
- Send the number with its country code (919876543210), or without it (9876543210) together with
country_code(91). Spaces, +, dashes and brackets are removed for you, so +91 98765-43210 works too. - Do I need the WhatsApp Business API or Meta approval?
- No. WbizTool sends from your own WhatsApp or WhatsApp Business number, linked like WhatsApp Web. There's no Meta approval and no message templates to get approved.
- Does it cost per message?
- No. The free trial includes 50 messages in any 30 days. Paid plans send unlimited messages under fair use, up to 1,000 a day per number: Lite $25, Standard $59 and Advanced $149 a month in the US; Pricing shows your country's price.
Read the guides
- Send message API
- Schedule message API
- Message status API
- WordPress plugin
- API keys and Client ID
- Connect your WhatsApp number
Related
- WordPressWhatsApp messages for WooCommerce orders, Contact Form 7 and WP Amelia.
- cURLSend, schedule and track WhatsApp messages with one cURL command.
- PythonSend WhatsApp messages from Python with the official client or plain requests.
- Payment remindersMonthly or one-off payment reminders from your own number, with the invoice as a PDF.
Send your first automated WhatsApp message today
Create an account, scan the QR code and send a message in under five minutes.
Start freePaid plans start at $25 a month in the US. Pricing
