Skip to content
WbizTool

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

  1. 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.

  2. Build the request

    Put client_id, api_key, whatsapp_client, the phone number and msg in an array. Send it as JSON with PHP's cURL extension – or with any HTTP client you already use, with the same fields.

  3. Send the message

    POST it to https://wbiztool.com/api/v1/send_msg/. A reply with "status": 1 and a msg_id means the message is queued on your number.

  4. Check that it went out

    Pass a webhook URL to be told when the message is sent or fails, or ask the Message status endpoint with the msg_id.

PHP code examples

Send a text
<?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');
}
Reply
{"status": 1, "message": "Created", "msg_id": 9817263}
Send an image from a URL
<?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);
Send a PDF (file upload)
<?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);
Schedule a message
<?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');
}
Check the message status
<?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'];
}
Receive the status webhook
<?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_type to 0 for text, 1 for an image or 2 for a file. Give a public img_url or file_url, or upload the file with CURLFile.

  • Schedule for later

    POST to /api/v1/schedule_msg/ with date (dd/mm/yyyy), time (HH:MM) and a timezone such as Asia/Kolkata or America/New_York.

  • Webhooks for every status

    Pass webhook and your script gets a form-encoded POST – read $_POST['msg_id'] and $_POST['status'] (SENT, FAILED, CANCELLED or EXPIRED).

  • 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": 1 means 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 check status.
  • For a file upload, pass an array to CURLOPT_POSTFIELDS, not json_encode, so cURL sends multipart/form-data with the file in a field named file.
  • 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_type 2. Either give a public file_url, or upload the file with new CURLFile(...) in a field named file. Set file_name with its extension, such as invoice-4821.pdf.
How do I know the message was sent?
A reply with "status": 1 and a msg_id means it's queued. Pass a webhook URL to get a POST with SENT, FAILED, CANCELLED or EXPIRED, or call the Message status endpoint with the msg_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

Related

Send your first automated WhatsApp message today

Create an account, scan the QR code and send a message in under five minutes.

Start free

Paid plans start at $25 a month in the US. Pricing