PHP SDK
Overview
The PHP SDK is a single, dependency-free class that wraps the BOOKBEY WhatsApp API. It runs on any PHP 7.4–8.3 host and needs only the cURL extension (bundled with virtually every PHP install).
Requirements
- PHP 7.4 or newer (a PHP 8.0+ build is also included)
- cURL extension enabled
- Outbound HTTPS to
https://bookbey.com - An API key and an active plan
Download
Get it from Client area → Downloads → PHP SDK. The zip contains two builds: BookbeyWhatsApp.74.php (universal, 7.4–8.3) and BookbeyWhatsApp.82.php (8.0+). Use the universal build unless you have a reason not to.
Installation
Copy the chosen file into your project (e.g. lib/BookbeyWhatsApp.php) and require it:
require __DIR__.'/lib/BookbeyWhatsApp.php';
If you use Composer, drop it under your autoloaded path or add a classmap entry — no external packages are pulled in.
Authentication
Every request must carry your API key. Both header forms are accepted — use either one:
Authorization: Bearer YOUR_API_KEY # or X-API-Key: YOUR_API_KEY
Keys are issued per client in Client area → API Keys, are scoped to your account, and are stored only as hashes. Your API base URL is https://bookbey.com/public/api.
Quick start
$wa = new BookbeyWhatsApp('YOUR_API_KEY', 'https://bookbey.com/public/api');
$res = $wa->sendText('9198XXXXXXXX', 'Hello from BOOKBEY!');
if (!empty($res['ok'])) {
echo "sent, id=".$res['id'].", remaining=".$res['remaining'];
} else {
echo "failed: ".$res['error'];
} Method reference
Every method returns the decoded API response as an array.
sendText($to, $text) sendImage($to, $url, $caption = '') sendDocument($to, $url, $filename = '', $caption = '') sendDocumentData($to, $base64, $filename, $caption = '') // no hosting needed sendDocumentFile($to, $path, $filename = '', $caption = '') // reads a local file sendTemplate($to, $template, array $params = [], $lang = 'en_US') send(array $payload) // low-level escape hatch status() // plan + quota verify() // bool: key + number live?
Phone number format
Phone numbers are digits only, in international format without a leading + or spaces — country code followed by the number, e.g. 9198XXXXXXXX for India. Modules that take orders will prefix a configurable default country code to any local number that is missing one.
Templates
Approved Cloud API templates are sent by name with ordered variables:
$wa->sendTemplate('9198XXXXXXXX', 'invoice_due', ['John','INV-1001','500'], 'en_US');The params array fills the template's {{1}}, {{2}}… placeholders in order.
Status & quota
Check your plan and remaining quota at any time:
curl https://bookbey.com/public/api/status.php -H "X-API-Key: YOUR_API_KEY"
=> {"ok":true,"plan":"Basic","limit":2000,"used":3,"remaining":1997} Error handling
Errors are returned as JSON with ok:false, a machine-readable error code and a human message. The HTTP status reflects the error class.
| HTTP | error code | Meaning & fix |
|---|---|---|
| 401 | unauthorized / invalid_api_key | Key missing, wrong, or revoked. Re-copy it from API Keys. |
| 402 | no_active_plan | No active plan on the account. Buy or renew a plan. |
| 403 | account_suspended | Account suspended. Contact support / clear dues. |
| 422 | invalid_json | Body was not valid JSON. Check Content-Type and payload. |
| 422 | invalid_number | Destination number malformed. Use country code + number, digits only. |
| 429 | quota_exceeded / rate_limited | Monthly quota used up, or sending too fast. Check status.php; retry with backoff. |
| 500 | server_error | Transient server error. Retry; if it persists, contact support. |
Troubleshooting
- Nothing happens /
network_error: your server can't reach https://bookbey.com. Check outbound HTTPS and firewall/proxy. invalid_api_key: re-copy the key; make sure you didn't include surrounding spaces.quota_exceeded: callstatus()to see remaining; upgrade the plan or wait for the reset.- Call succeeds but no WhatsApp arrives: verify the number is on WhatsApp and in the correct country-code format; check Client area → Logs for the delivery record.
- cURL SSL errors: update your CA bundle (
curl.cainfoin php.ini).
FAQ
Does it need Composer? No. Can I send PDFs without hosting them? Yes — use sendDocumentData() with base64. Is it thread-safe? Each call is an independent HTTPS request; create one instance and reuse it freely.
Need help? Open a ticket from Client area → Support. Your API base URL is https://bookbey.com/public/api.