WhatsApp· 6 min read

Baileys and whatsapp-web.js vs the Cloud API


Baileys and whatsapp-web.js are open-source Node.js libraries that connect to WhatsApp Web as a linked device. The Cloud API is Meta’s own API, governed by the WhatsApp Business Platform terms. Baileys talks to WhatsApp Web over WebSockets without a browser, while whatsapp-web.js drives WhatsApp Web inside a browser through Puppeteer. Both READMEs say the projects are not affiliated with WhatsApp. With either library, you store the session, link the device and absorb breaking changes yourself. The Cloud API asks instead for a business portfolio, approved templates outside the 24-hour window and a fee per delivered message.

The three side by side

Axis Baileys whatsapp-web.js Cloud API
What it is “a WebSockets-based TypeScript library for interacting with the WhatsApp Web API” “A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app” Meta’s API that “enables you to send messages and receive webhooks”
How it connects WebSockets, no Selenium or browser. Link by QR code or pairing code. Puppeteer runs WhatsApp Web in a managed browser instance. Link by QR code. Access token from a Meta app in a business portfolio. Webhooks to your endpoint.
Runtime Node.js >=20.0.0 (engines in package.json) Node.js v18.0.0 or higher (README) Not tied to a library
License MIT Apache-2.0 Governed by the WhatsApp Terms for WhatsApp Business Platform
Version v7.0.0-rc14, marked Latest on GitHub (accessed 2026-11-03) v1.34.8, marked Latest (released 2026-11-12, accessed 2026-11-24) Not applicable
Session storage You write the auth state store NoAuth (default), LocalAuth or RemoteAuth No session; an access token
Cost from Meta Not on Meta’s pricing page Not on Meta’s pricing page Per delivered message, by category and recipient country

Sources: the Baileys repository and whatsapp-web.js repository READMEs, package.json files and releases pages, and Meta’s get started and pricing pages, all accessed 2026-11-03. Meta’s pricing page covers the Cloud API and the Marketing Messages API only.

What Baileys is

“Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API” (Baileys README). It “does not require Selenium or any other browser”, and it “supports interacting with the multi-device & web versions of WhatsApp.” Its package.json lists ws, protobufjs and libsignal among the dependencies. The README installs it with this line:

yarn add @whiskeysockets/baileys

You link a number by scanning a QR code printed in the terminal, or with a pairing code. The README is explicit about the second: “Pairing Code isn’t Mobile API, it’s a method to connect Whatsapp Web without QR-CODE.”

Session persistence is your code. The README flags useMultiFileAuthState as IMPORTANT. The function saves the auth state in a single folder and is meant as a guide. For production systems, the README points to an auth store backed by a SQL or NoSQL database that you write.

Upgrading to version 7 means migration work. “As of 7.0.0, multiple breaking changes were introduced into the library”, and the README links a migration guide at whiskey.so/migrate-latest. The README also names https://baileys.wiki as its new guide.

What whatsapp-web.js is

whatsapp-web.js is “A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app” (whatsapp-web.js repository). The README says it “uses Puppeteer to access WhatsApp Web’s internal functions and runs them in a managed browser instance”. Its package.json pins puppeteer 24.38.0, so every running client is a browser process on your server.

npm install whatsapp-web.js

Session handling is a choice of auth strategy (authentication guide). NoAuth is the default, and “It does not provide any means of saving and restoring sessions”, so you scan the QR code again after every restart. LocalAuth writes to .wwebjs_auth, and “LocalAuth requires a persistent filesystem to be able to restore sessions.” RemoteAuth saves to MongoDB or S3 and “takes about 1 minute to successfully save the WhatsApp session into the remote database”, signaled by the remote_session_saved event.

On a headless server, the guide has you pass Puppeteer’s --no-sandbox flag, plus --disable-setuid-sandbox when the process runs as root.

What the maintainers say about WhatsApp’s terms

Both READMEs open their disclaimers with the same sentence.

“This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates.”

Baileys continues: “The maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp.” It asks users to take “personal responsibility” and adds “Use at your own discretion. Do not spam people with this.”

The whatsapp-web.js disclaimer adds two sentences about blocking. “WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn’t be considered totally safe.” And: “Also it is not guaranteed you will not be blocked by using this method.”

The terms that apply to the number

A library session is a linked device on an existing WhatsApp account, so that account’s terms apply. Neither WhatsApp document names Baileys, whatsapp-web.js or unofficial clients.

On a Business app number, the WhatsApp Terms for WhatsApp Business App (effective 2026-09-23) apply. Section 5 says Company must not “develop or use any applications that interact with our Business App Services without our prior written consent”. The same section bars reverse engineering and building “software or APIs that function substantially the same as our Business App Services”. Section 6 gives WhatsApp “the right to limit, throttle, suspend, or terminate Company’s account”.

On a consumer number, WhatsApp’s Terms of Service apply (non-EEA version, effective 2021-01-04). Acceptable use excludes “auto-messaging, auto-dialing, and the like” and “any non-personal use of our Services unless otherwise authorized by us.” The harm section bars reverse engineering. It also bars creating software or APIs “that function substantially the same as our Services” and offering them “for use by third parties in an unauthorized manner”. WhatsApp “may take action with respect to your account, including disabling or suspending your account”.

What you operate yourself

The session store comes first, in the forms described above. Without a saved session, you link the device again by QR code or pairing code from the phone.

The phone stays in the loop. WhatsApp’s FAQ caps a primary phone at four linked devices (second phone FAQ). Companion phones “will be logged out if you don’t use WhatsApp on your primary phone for over 14 days”. The READMEs do not say how a library session counts against that cap. Daily drops have their own causes, covered in why a QR-connected number disconnects every day.

Updates are yours too. Baileys 7.0.0 shipped breaking changes, and whatsapp-web.js depends on a pinned Puppeteer release. Identifier formats are part of the same upkeep, and @lid vs JID covers the group identifiers you will parse.

What the Cloud API asks for instead

The Cloud API starts in a business portfolio, with a temporary access token and a hello_world template as the first send (get started). You “set up a webhook endpoint in order to receive notifications about message statuses.”

Without coexistence, the number has to leave the app. “To use an existing WhatsApp phone number with Cloud API, you must first delete your WhatsApp account.” After that, “your existing messaging history will be lost” (migrate an existing number). Coexistence through a partner keeps it in the Business app as well, as described in Business app coexistence with the Cloud API.

The contract is the WhatsApp Terms for WhatsApp Business Platform, which “incorporate by reference the WhatsApp Business Messaging Policy”. Outside the 24-hour window, “you can only send pre-approved template messages” (send messages guide). Meta “charges on a per-message basis” and only “when a message is delivered”, at a rate set by category and the recipient’s country calling code.

Choosing between them

A library fits when you want to run the WhatsApp Web session in your own code. You accept the terms above and the maintainers’ warnings, host the session store and track releases. The Cloud API fits when you want Meta’s Platform terms, templates and a per-message bill instead of a linked device. QR connection vs Meta’s official API compares the two on the same axes. Z-API Omni offers the QR connection and Meta’s official API in the same account (View documentation).

Z-API Omni team