Understanding WhatsApp's Multi-Device Protocol
How WhatsApp's multi-device architecture lets companion devices run without the phone online, why it's Signal-based, and how it pushed Baileys and whatsmeow to native sockets.
- WhatsApp's multi-device design (revealed July 2021) lets up to 4 companion devices connect to servers independently, even when the primary phone is offline.
- Each device now holds its own identity key; the server keeps a per-account device list that senders fetch to encrypt messages.
- Encryption stays end-to-end via the Signal Protocol: 1:1 uses client-fanout (one ciphertext per device), groups use Sender Keys.
- Because the phone no longer needs to be online and the protocol is a binary Noise-based WebSocket, libraries like Baileys and whatsmeow dropped browser automation for native sockets.
- These libraries are unofficial and reverse-engineered; bulk or automated use violates WhatsApp's ToS and carries real ban risk. The Cloud API is the compliant path.
What the multi-device protocol actually changed
For years, WhatsApp Web was a clever illusion. Your phone was the only real client and the single source of truth; the browser tab or desktop app was essentially a remote display that relayed everything through the phone. Close the app, drain the battery, or lose signal on your phone, and every linked surface went dark. That coupling was simple but fragile, and it made the phone a permanent bottleneck.
WhatsApp's multi-device architecture, detailed publicly by Engineering at Meta in July 2021, broke that dependency. It allows up to four companion (non-phone) devices to connect to WhatsApp's servers independently. A linked desktop or web session can now send and receive messages even when the primary phone is completely offline. The phone is no longer a router for every message; it becomes one peer among several, albeit a privileged one that still authorizes new devices and seeds history.
The conceptual shift underneath is the important part for developers. WhatsApp moved from one identity key per user to a separate identity key per device. The server maintains a mapping from each account to a list of that account's authorized device identities. When you send a message, your client first fetches the recipient's current device list, then encrypts for every device on it. This per-device model is what makes independent operation possible, and it is the foundation everything else in this article is built on.
How companion devices are authorized
Adding a companion device is a mutual-trust handshake, not a simple password exchange. As described in WhatsApp's Security Whitepaper, scanning the QR code on web.whatsapp.com or the desktop app creates two cryptographic signatures. The primary device (your phone) produces an Account Signature by signing the new companion's public identity key. The companion, in turn, produces a Device Signature by signing the primary's public identity key. Only once both signatures exist can other clients trust the new device and establish encrypted sessions with it.
This bidirectional signing is what lets senders verify that a device legitimately belongs to an account, rather than being injected by a malicious server. WhatsApp layers a feature called Automatic Device Verification on top: your own devices can establish mutual trust without forcing you to re-check safety numbers every time you link something new. Full re-verification of security codes is only triggered when someone re-registers their entire account, which is the event that should genuinely make contacts cautious.
From a user-control standpoint, the account screen lists every linked device with last-active timestamps, and you can remotely log any of them out. Linking can also be gated behind device biometrics. For developers, the takeaway is that a library session is effectively just another companion device in this list, subject to the same visibility and remote-logout controls.
Encryption stays end-to-end: the Signal layer
A common misconception is that letting the phone go offline must weaken encryption, since the server now does more work. It does not. Multi-device is still built on the Signal Protocol, originally from Open Whisper Systems, combining X3DH key agreement with the Double Ratchet for forward secrecy. WhatsApp and its servers never hold plaintext. What changed is how many encrypted copies are produced, not whether plaintext leaks.
The mechanism differs by conversation type, and the terminology matters. One-to-one messages use client-fanout: the sending client encrypts and transmits the message N times, once for every device in both the sender's and the recipient's device lists, each over a pairwise Signal session. So a chat between two people who each have a phone and two companions can mean encrypting the same message several times over distinct sessions. Group messages instead use Signal's Sender Keys scheme, which is far more scalable: the sender encrypts the content once with a sender key, then distributes that key pairwise to participants, avoiding per-message quadratic blowup.
| Aspect | Client-fanout (1:1) | Sender Keys (groups) |
|---|---|---|
| Where used | Direct 1:1 chats | Group chats |
| Encryptions per message | One per device in both lists | Once per message, key shared pairwise |
| Scaling behavior | Grows with device count | Designed for many participants |
| Underlying primitive | Pairwise Signal session | Sender key over pairwise sessions |
Two more pieces complete the picture. When a device is first linked, the primary phone encrypts and transfers a bundle of recent message history, with the history-encryption key delivered over the existing end-to-end channel. Ongoing app state (contacts, chat archive, starred messages, mute settings, and similar metadata) syncs continuously through an end-to-end encrypted, server-stored encrypted copy, so a fresh companion can reconstruct your chat list without the phone being awake.
Why unofficial libraries moved to native sockets
Here is where the architecture reshaped a whole ecosystem of developer tooling. In the old web model, since the phone was the source of truth and the browser merely mirrored it, the easiest way to automate WhatsApp programmatically was to drive an actual browser. The whole field of WhatsApp Web reverse engineering grew up around this: libraries spun up headless Chromium through Puppeteer or Selenium, loaded web.whatsapp.com, and scripted the DOM. It worked, but it was heavy, brittle, and memory-hungry.
Multi-device removed the phone-online requirement, and the protocol itself is a binary WebSocket protocol to web.whatsapp.com that opens with a Noise-protocol handshake. That meant a library could stop pretending to be a browser and instead speak the protocol directly over a native WebSocket connection, presenting itself as a legitimate companion device. The practical gains are large: a native-socket client typically uses on the order of tens of megabytes of RAM and starts in under a second, whereas a Chromium-and-Puppeteer stack commonly consumes hundreds of megabytes — often roughly half a gigabyte once a page is loaded. These figures are rule-of-thumb ranges rather than published benchmarks, but the order-of-magnitude difference is well established: native sockets are dramatically more reliable and scalable server-side.
Both major libraries reflect this. Baileys (Node/TypeScript) and whatsmeow (Go) are pure protocol reimplementations, not browser drivers. They handle the Noise handshake, the device-identity dance, client-fanout, and Sender Keys themselves. That is a far more demanding engineering task than scripting a DOM, which is also why these projects break when WhatsApp adjusts the undocumented protocol and need frequent updates to keep working.
Baileys and whatsmeow: the two reference implementations
If you want to study a working multi-device client, these two open-source projects are the canonical references. Baileys is the dominant choice in the JavaScript world for an unofficial WhatsApp API, and whatsmeow is its Go counterpart, well known for powering the mautrix-whatsapp Matrix bridge.
| Detail | Baileys | whatsmeow |
|---|---|---|
| Language | Node / TypeScript | Go |
| Install / import | npm: baileys | go.mau.fi/whatsmeow |
| Repository | github.com/WhiskeySockets/Baileys | github.com/tulir/whatsmeow |
| License | MIT | MPL-2.0 |
| Maintainer | Rajeh (WhiskeySockets org) | tulir (Tulir Asokan) |
| Notable use | Large bot/automation ecosystem | mautrix-whatsapp bridge |
A few naming details trip people up. The current Baileys npm package is the unscoped baileys. It was previously published as @whiskeysockets/baileys, and the original package was @adiwajshing/baileys (original author Rajeh Taher, known as adiwajshing). Modern code should import from the unscoped name. At the time of writing, Baileys is working toward its v7.x line, which has been published as release candidates (for example, 7.0.0-rc tags) rather than a finalized stable release; 7.0.0 introduces several breaking changes and ships with a migration guide. Confirm the latest tag on the repository before pinning, since there have sometimes been notable gaps between releases, and treat the many third-party forks (baileys-x, Itsukichann/Baileys and others) with caution.
// Baileys v7 is ESM-only and targets Node 20+; this file must be an ES module
// (package.json "type": "module"), or top-level await and the default import will fail.
import makeWASocket, { useMultiFileAuthState } from 'baileys'
// Multi-device auth state persists per-device credentials,
// not a phone mirror. The socket connects as a companion device.
const { state, saveCreds } = await useMultiFileAuthState('auth')
const sock = makeWASocket({ auth: state })
sock.ev.on('creds.update', saveCreds)
sock.ev.on('connection.update', ({ qr }) => {
if (qr) console.log('Scan this QR with your phone to link the device')
})whatsmeow is actively maintained, with well over 1,500 commits, and implements the WhatsApp web multi-device API natively. Historically unimplemented areas have included calls and sending to broadcast lists, so verify feature coverage against the repo before committing to it. The Baileys release notes have claimed it is roughly three times faster than whatsmeow, but treat that as a maintainer benchmark rather than an independent result.
Limitations, ToS, and the compliant path
It is essential to be honest about what these tools are. Baileys and whatsmeow are unofficial, reverse-engineered libraries. They are not the WhatsApp Business Platform, and they are not sanctioned by Meta. The Baileys repository itself states it is not affiliated with or endorsed by WhatsApp, does not condone ToS violations, and discourages stalkerware and bulk or automated messaging.
WhatsApp's Terms of Service and Messaging Guidelines explicitly prohibit unofficial or modified clients, bulk messaging, auto-messaging, and auto-dialing. Ban risk is real and escalated through 2025. Meta uses automated detection across message volume and pattern anomalies, unusual sessions not tied to the official API, device fingerprinting, and network behavior, and reported banning over 6.8 million accounts tied to scam centers in the first half of 2025. Modified apps like GBWhatsApp and WhatsApp Plus routinely earn permanent bans, and grey-market bulk-sender APIs are actively targeted. On top of the policy risk, the protocol is undocumented and changes without notice, so these libraries break and require ongoing maintenance; their behavior is best-effort.
- For production business automation, use the official WhatsApp Business Platform (Cloud API or On-Premises API) with approved message templates and proper opt-in.
- Treat unofficial libraries as study material, personal tooling, or low-risk internal experiments, never as a bulk-outreach engine.
- If you only need to verify whether a number is on WhatsApp or fetch a public profile, use a dedicated API rather than running and maintaining a full multi-device session yourself.
That last point is where a lot of teams over-engineer. Standing up, persisting, and babysitting a companion-device session purely to answer 'is this number on WhatsApp?' or 'what is the public profile picture?' is a heavy way to get a light answer, and it inherits all the ToS and stability risk above.
Bringing it together
WhatsApp's multi-device protocol is a genuinely elegant piece of engineering. By giving each device its own identity key and a server-maintained device list, it let companions run independently without sacrificing end-to-end encryption. Client-fanout handles 1:1, Sender Keys handle groups, and a Noise-based binary WebSocket carries it all. That single design decision is what made the modern wave of native-socket libraries possible and rendered the old browser-automation approach largely obsolete.
For developers, the mental model is straightforward: understand the per-device identity system, respect the four-companion limit, and know that any unofficial client is just another companion bound by WhatsApp's rules. Build with that awareness, lean on the official Cloud API for anything at scale, and reach for a purpose-built lookup service when verification is all you actually need.
Frequently asked questions
Skip the companion-session lifecycle. Our hosted API checks whether a number is on WhatsApp and returns the public profile picture, display name, about text, and business flag in a single call.
Explore the APISources & further reading
- Engineering at Meta — How WhatsApp enables multi-device capability
- WhatsApp Encryption Overview (Security Whitepaper, PDF)
- Baileys repository (WhiskeySockets, MIT)
- whatsmeow repository (tulir, MPL-2.0)
- InfoQ — WhatsApp Adopts the Signal Protocol for Secure Multi-Device Communication
- WhatsApp Terms of Service
- Formal Analysis of Multi-Device Group Messaging in WhatsApp (IACR ePrint 2025/794)