Getting started
Introduction
wapi-cloud is a promise-based, fully-typed Node.js wrapper for integrating the WhatsApp Cloud API (Meta Graph API) into your applications.
Most Graph API wrappers hand you raw HTTP responses and let you figure out the rest — inconsistent error shapes, no types, and a pagination scheme you re-implement in every project. wapi-cloud wraps the full WhatsApp Cloud API surface — messages, templates, media, contacts, catalogs, products, commerce settings, flows, QR codes, analytics, embedded signup, and account management — behind a single typed client that never throws.
Why wapi-cloud
- Fully typed. First-class TypeScript support, with error checks that narrow the response type correctly without type casts.
- Never throws. Every call resolves to a consistent
{ data, error }result, Supabase-style. - Batteries included. Messages, templates, media, contacts, catalogs, products, commerce settings, flows, QR codes, analytics, embedded signup, and webhooks in one unified client.
- Webhook helpers. Signature verification, event parsing, typed event dispatchers, and an Express one-liner.
- Auto-pagination.
for awaitover any list endpoint. - Tree-shakeable. Ships as ESM + CJS with
.d.tsviatsup.
A 30-second look
import { Whatsapp } from "wapi-cloud";
const whatsapp = new Whatsapp({
accessToken: process.env.WA_TOKEN!,
phoneNumberId: process.env.WA_PHONE_ID!,
businessAccountId: process.env.WA_WABA_ID!, // for templates/flows/analytics
appSecret: process.env.WA_APP_SECRET!, // for webhook signatures
});
const { data, error } = await whatsapp.messages.sendText(
"15551234567",
{ body: "Hello from wapi-cloud!" }
);
if (error) {
console.error(error.code, error.type, error.message);
} else {
console.log("Sent message ID:", data.messageId);
console.log("Recipient WA ID:", data.waId);
}Module Surface
The SDK exposes 14 dedicated sub-modules organized cleanly by functionality:
whatsapp.messagesSend text, media, templates, interactive buttons/lists/CTA, carousels, contacts, location, reactions, and flows.
whatsapp.templatesCreate, list, auto-paginate, get, update and delete message templates including carousels and SPM templates.
whatsapp.mediaUpload media files, retrieve metadata with temp download URLs, download raw binary data, and delete assets.
whatsapp.contactsCheck WhatsApp registration validity for phone numbers, block users, unblock users, and list blocked contacts.
whatsapp.phoneNumbersList, get, register with 2FA PIN, deregister, request SMS/voice verification codes, and verify phone numbers.
whatsapp.businessProfileRead and update your WhatsApp Business profile details: about, address, description, email, websites, industry, and picture.
whatsapp.twoStepVerificationSet or update the 6-digit PIN used to re-register and secure a phone number on WhatsApp Cloud API.
whatsapp.catalogsList Meta product catalogs, look up catalog details, verify WABA catalog connections, and send product messages.
whatsapp.productsList, get, create, update and delete catalog products with price, currency, availability, condition, and imagery.
whatsapp.commerceSettingsCheck and configure WhatsApp commerce settings: toggle catalog visibility and enable/disable the in-chat cart.
whatsapp.flowsCreate, list, update Flow JSON asset files, publish, deprecate, and delete native in-chat interactive WhatsApp Flows.
whatsapp.qrCodesCreate, list, get, update and delete deep link QR codes with pre-filled messages that launch a WhatsApp chat.
whatsapp.analyticsQuery messaging analytics, conversation volume, and pricing analytics for your WABA by date range and granularity.
whatsapp.embeddedSignupGenerate client-side onboarding login scripts, exchange OAuth code for system user tokens, and subscribe to WABAs.
Where to go next
Head to Installation to add the package, then Quick start to send your first message in a few minutes.