This is a standalone Express-based API server that uses the whatsapp-web.js client.
...
-
Open a terminal in this folder.
-
Update
.envwith your custom credentials (optional):
# Edit .env to change:
# - UI_CREDENTIALS (username:password for web UI login)
# - POSTGRES_PASSWORD (database password)
# - PGADMIN_PASSWORD (pgAdmin login password)
# - SESSION_SECRET (change to a strong random string in production)
# - DATABASE_URL (already configured for Docker)
cat .env- Start all services (API, PostgreSQL, pgAdmin, Redis):
docker-compose up -d...
If you had an existing whatsapp_messages.db file:
- Place it in the root folder
- Run
docker-compose up -d - Server will automatically migrate all data to PostgreSQL and remove the SQLite file
...
Quick start
-
Open a terminal in this folder.
-
Install dependencies:
npm install- Start the server:
npm start- Open
http://localhost:3000/eventsin a browser or usecurlto receive events.
The whatsapp-web.js client depends on Puppeteer.
If you want to avoid Chromium download (you have a compatible Chrome/Chromium installed), skip download and provide an executable path when running the server:
# skip chromium download during install
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm install puppeteer --save
# start server while pointing to an existing Chrome binary (macOS example)
PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
node server.js...
Run the server
node server.js
# or
npm start...
If you see this error:
Error: Cannot find module 'better-sqlite3'
Require stack:
- .../server.js
You need to install dependencies:
npm installThen start the server:
npm start- Set Status:
http://localhost:3000/status?client=default&api_key=YOUR_API_KEY - Block Contact:
http://localhost:3000/contact/{CONTACT_ID}/block?client=default&api_key=YOUR_API_KEY - Unblock Contact:
http://localhost:3000/contact/{CONTACT_ID}/unblock?client=default&api_key=YOUR_API_KEY - Create Channel:
http://localhost:3000/channel/create?client=default&api_key=YOUR_API_KEY - Subscribe Channel:
http://localhost:3000/channel/{CHANNEL_ID@newsletter}/subscribe?client=default&api_key=YOUR_API_KEY - Unsubscribe Channel:
http://localhost:3000/channel/{CHANNEL_ID@newsletter}/unsubscribe?client=default&api_key=YOUR_API_KEY - Search Channels:
http://localhost:3000/channel/search?client=default&api_key=YOUR_API_KEY
Replace placeholders:
{CONTACT_ID}: e.g.6281234@c.us{CHANNEL_ID@newsletter}: full channel id ending with@newsletter
See detailed curl examples in sections above.
Docker eliminates the need to compile native modules on your local system. The image is built for both arm64 (Apple Silicon) and amd64 (Intel) architectures.
- Docker and Docker Compose installed
- Copy the example
.envfile:
cp docker.env .env- Edit
.envand set your credentials (optional, but recommended for production):
UI_CREDENTIALS=admin:yourpassword
SESSION_SECRET=your-secret-key-change-this- Start the services (API server + Redis):
docker-compose up -d- View logs:
docker-compose logs -f api-
Open the UI: http://localhost:3000/
-
Stop the services:
docker-compose downIf you want to build the image without docker-compose:
docker build -t whatsapp-api-server:latest .Run the container:
docker run -d \
--name whatsapp-api \
-p 3000:3000 \
-e UI_CREDENTIALS=admin:password \
-e SESSION_SECRET=your-secret-key \
-v $(pwd)/sessions:/app/sessions \
-v $(pwd)/data:/app/data \
whatsapp-api-server:latestWhen running in Docker, these environment variables are supported:
UI_CREDENTIALS=username:password— enable login for web UISESSION_SECRET=your-secret— session cookie secret (recommended to change)REDIS_URL=redis://redis:6379— Redis URL (auto-detected in docker-compose)RATE_LIMIT_PER_MINUTE=120— requests per minute per API keyNODE_ENV=production— set to production
The docker-compose setup creates volumes:
./sessions/— stores WhatsApp session data (LocalAuth)./data/— stores SQLite database (whatsapp_messages.db)redis-data— stores Redis session data
These volumes persist even after containers are stopped/removed.
The docker-compose setup uses a bridge network (whatsapp-network) so the API server can communicate with Redis. The API is accessible at http://localhost:3000 on your host machine.
The Dockerfile uses a multi-stage build and Alpine Linux for minimal image size. It works on:
- Apple Silicon (M1/M2/M3, arm64)
- Intel Macs and Linux (amd64)
- Other architectures supported by node:20-alpine
To build for a specific architecture:
docker buildx build --platform linux/amd64 -t whatsapp-api-server:amd64 .
docker buildx build --platform linux/arm64 -t whatsapp-api-server:arm64 .