BOOKBEYWhatsApp API

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.

HTTPerror codeMeaning & fix
401unauthorized / invalid_api_keyKey missing, wrong, or revoked. Re-copy it from API Keys.
402no_active_planNo active plan on the account. Buy or renew a plan.
403account_suspendedAccount suspended. Contact support / clear dues.
422invalid_jsonBody was not valid JSON. Check Content-Type and payload.
422invalid_numberDestination number malformed. Use country code + number, digits only.
429quota_exceeded / rate_limitedMonthly quota used up, or sending too fast. Check status.php; retry with backoff.
500server_errorTransient 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_ESM or import errors: the SDK is CommonJS; use require(), or import { BookbeyWhatsApp } from 'bookbey-whatsapp' with esModuleInterop.
  • Unhandled promise rejection: always await inside a try/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.