Once you have completed the one-time pairing step, WhatsApp MCP API saves the full Chrome user profile — including the WhatsApp Web session credentials — to a local directory calledDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/jihvijhojhviihogyuvi/whatsapp-api/llms.txt
Use this file to discover all available pages before exploring further.
.wwebjs_auth/session-default. Every subsequent server restart loads this saved profile and reconnects to WhatsApp automatically, without requiring a new QR scan or pairing code.
Session Storage Location
The session directory is created relative to the project root by default, but can be relocated using an environment variable:| Setting | Value |
|---|---|
| Default path | .wwebjs_auth/session-default/ (relative to the project root) |
| Environment variable | WHATSAPP_AUTH_DIR — overrides the base .wwebjs_auth directory |
.wwebjs_auth folder is intentionally excluded from version control (git-ignored) because it contains sensitive Linked Device credentials that are equivalent to a logged-in WhatsApp session.
Set
WHATSAPP_AUTH_DIR to an absolute path to change where sessions are stored — for example, when running multiple isolated server instances side by side, each pointed at a different auth directory and a different phone number.Auto-Reconnect
When the server starts and.wwebjs_auth/session-default already exists, the Client is initialized with a LocalAuth strategy that loads the saved Chromium profile. Chrome opens the saved session, WhatsApp Web recognizes the device credentials, and the client state transitions through:
state reaches "ready", which you can verify with:
Backing Up the Session
Because the session is a plain directory on disk, you can back it up and restore it like any other folder: To back up:- Copy your backed-up
.wwebjs_authfolder to the project root (or whereverWHATSAPP_AUTH_DIRpoints). - Start the server normally with
npm start. - The session auto-reconnects without re-pairing.
Resetting the Session / Logging Out
API logout
The cleanest way to end a session is through the logout endpoint. This callsclient.logout() followed by client.destroy(), revokes the linked device credential with WhatsApp, nulls the client instance, resets state to "stopped", and clears both the pending QR code and the cached account info (wid, pushname, platform):
"stopped". You can then re-pair using the pairing code flow.
Manual reset
If the server is not running, or if the session is corrupted, delete the auth directory directly and restart:Troubleshooting
Server stuck in 'starting' state
Server stuck in 'starting' state
Chrome may not be found at the configured path. Check the value of You can also confirm the configured path by calling
WHATSAPP_CHROME_EXECUTABLE — it defaults to the Windows path C:\Program Files\Google\Chrome\Application\chrome.exe. On Linux or macOS, set the variable to the correct binary location:GET /api/status and checking the chrome_executable field in the response.Auth failure after restart
Auth failure after restart
A saved session can become stale if the linked device was removed from WhatsApp on the phone, or if too much time passed since the last connection. The
state will be "auth_failure" and last_error will contain a reason string.To recover, log out cleanly and re-pair:'not ready yet' errors on API calls
'not ready yet' errors on API calls
Any messaging or chat endpoint called before the client reaches
"ready" will return an error. The client may still be authenticating — especially on first launch when Chrome is starting up.Poll GET /api/status and wait until state is "ready" before issuing other API calls:Headless Chrome on Linux
Headless Chrome on Linux
By default If you still encounter display errors, ensure a virtual framebuffer (e.g.,
WHATSAPP_HEADLESS is false, which means Chrome tries to open a visible window. On a headless Linux server with no display, this will fail.Set WHATSAPP_HEADLESS=true to run Chrome in headless mode:Xvfb) is running, or use a Docker image that includes all Chromium dependencies. Also confirm that the --disable-dev-shm-usage and --disable-gpu flags are active — they are included in the server’s Puppeteer configuration by default.