Node.js SDK
Overview
A zero-dependency Node.js client for the BOOKBEY WhatsApp API. Promise-based, ships with TypeScript definitions, and works on Node 14+.
Requirements
- Node.js 14 or newer
- Outbound HTTPS to
https://bookbey.com - An API key and active plan
Download
Get it from Client area → Downloads → Node.js SDK. The zip contains src/index.js, TypeScript types, an example.js and a README.
Installation
Unzip into your project and install it as a local package, or require it directly:
npm install ./bookbey-whatsapp
# or copy the folder and: const { BookbeyWhatsApp } = require('./bookbey-whatsapp/src/index'); 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
const { BookbeyWhatsApp, BookbeyError } = require('bookbey-whatsapp');
const wa = new BookbeyWhatsApp('YOUR_API_KEY', 'https://bookbey.com/public/api');
(async () => {
try {
const r = await wa.sendText('9198XXXXXXXX', 'Hello from BOOKBEY!');
console.log('sent', r.id, 'remaining', r.remaining);
} catch (e) {
console.error(e.code, e.message); // BookbeyError
}
})(); Method reference
await wa.sendText(to, text) await wa.sendImage(to, url, caption?) await wa.sendDocument(to, url, filename?, caption?) await wa.sendDocumentData(to, base64, filename, caption?) await wa.sendTemplate(to, template, params?, lang?) await wa.send(payload) await wa.status() await wa.verify() // boolean
Each resolves to the API JSON and rejects with a BookbeyError (.code, .status, .message) on failure.
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.
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
Failed calls throw BookbeyError. Inspect err.code against the table below.
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
network_error/timeout: the host can't reach https://bookbey.com. Check egress and DNS.unauthorized: wrong/rotated key — re-copy from API Keys.ERR_REQUIRE_ESMor import errors: the SDK is CommonJS; userequire(), orimport { BookbeyWhatsApp } from 'bookbey-whatsapp'withesModuleInterop.- Unhandled promise rejection: always
awaitinside atry/catch.
FAQ
Any dependencies? None. TypeScript? Yes, types are bundled. Does it work in the browser? No — keep your API key server-side.
Need help? Open a ticket from Client area → Support. Your API base URL is https://bookbey.com/public/api.