概要
Webダッシュボードを備えた、セルフホスト型のマルチセッション WhatsApp ゲートウェイです。Dockerでセットアップし、ブラウザーでアカウントを作成して電話番号を連携すると、シンプルな HTTP API でメッセージを送信できます。
システム・インフラ計測したスター増加
- 24時間
- 0
- 7日間
- +3
- 15日間
- +3
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルWA Gateway | A self-hosted open-source WA Gateway Multi Session
A self-hosted, multi-session WhatsApp gateway with a web dashboard. Set it up with Docker, create your account in the browser, link your numbers, and send messages over a simple HTTP API.
📖 Documentation, screenshots and tutorials: mimamch.github.io/wa-gateway

- Multi-device, multi-session (many phone numbers on one server)
- Web dashboard: link numbers by QR code or pairing code, manage users and API keys
- Shared inbox: read and reply to chats from the browser, in real time
- Team accounts with roles (owner, admin, member)
- SQLite out of the box, or Postgres
- Send text, images, videos, documents, audio, stickers and polls
- Webhooks for incoming messages and session status, with a live event monitor
- Message history API and an audit log of who changed what
📌 Also see: wa-multi-session
⚠️ This uses the unofficial WhatsApp Web protocol (Baileys). Sending bulk or unsolicited messages can get your number banned.
Need the official WhatsApp Business API instead?
WA Gateway links your number as a device, like WhatsApp Web: free and self-hosted, but unofficial. If WhatsApp is a core channel for your business, Notizy (an official Meta partner) runs on the official WhatsApp Business API and adds:
- AI agent that answers customer chats and phone calls 24/7 from your own knowledge base, and hands over to your team when needed
- One inbox for WhatsApp, Instagram and Messenger
- Broadcasts with sent, delivered and read status
- API and integrations (Shopify, Google Sheets, Zapier, HubSpot, payment gateways and more)
| WA Gateway | Notizy | |
|---|---|---|
| WhatsApp connection | Unofficial (linked device) | Official WhatsApp Business API |
| Hosting | Your server | Managed cloud |
| Price | Free, open source | Paid plans, free trial |
| Best for | Developers, internal tools, small volumes | Businesses that rely on WhatsApp for sales and support |
Installation
You need Docker with Docker Compose (install Docker).
1. Create a folder
mkdir -p ~/app/wa-gateway && cd ~/app/wa-gateway
2. Create docker-compose.yaml
services:
wa-gateway:
image: mimamch/wa-gateway:latest
restart: unless-stopped
ports:
- "5001:5001"
volumes:
- ./data:/app/data
- ./media:/app/media
Optional settings (Postgres, history sync, …) are listed under Configuration.
The image is also on GitHub: ghcr.io/mimamch/wa-gateway. Use :5 to stay on v5 (:5.0 or :5.0.0 to pin further) instead of :latest.
3. Start it
docker compose up -d
4. Open the dashboard
Go to http://localhost:5001 (or your server's IP/domain).
- Create the owner account. The first visit asks for a name, email and password.
- Add a session. Open Sessions → Add session, then scan the QR code in WhatsApp → Linked devices, or choose Pairing code and enter the code on your phone.
- Create an API key. Open API Keys → New key and copy it. It is shown only once.
5. Send your first message
curl -X POST http://localhost:5001/message/send-text \
-H "key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{"session": "SESSION_ID", "to": "628123456789", "text": "Hello"}'
Configuration
| Variable | Default | Description |
|---|---|---|
PORT |
5001 |
HTTP port |
DATABASE_URL |
(empty) | postgres://user:pass@host:5432/db. Empty means SQLite at ./data/database.db |
DATA_DIR |
./data |
Where the SQLite database lives |
MEDIA_DIR |
./media |
Where media received for webhooks is saved |
WEBHOOK_BASE_URL |
(empty) | Webhook base URL (see below) |
KEY |
(empty) | v4-style API key, still accepted alongside dashboard keys |
HISTORY_SYNC_DAYS |
7 |
Inbox: days of chat history imported when a number is linked (0 = none) |
INBOX_READ_RECEIPTS |
false |
Inbox: send blue ticks to the sender when a chat is opened in the dashboard |
To use Postgres, add a postgres service to your compose file (see docker-compose.yaml) and set DATABASE_URL. Tables are created automatically on start.
API Reference
Every request needs an API key in the key header (or x-api-key, or ?key= query).
Interactive docs with every field and example are served by the gateway at /docs (OpenAPI document at /openapi.json).
Sessions
| Method | Endpoint | Description |
|---|---|---|
GET |
/session |
List sessions and their status |
POST |
/session/start |
Body { "session": "NAME" }. Returns { qr } to scan |
GET |
/session/start?session=NAME |
Same, but returns an HTML page with the QR image |
GET |
/session/:session |
Session details (docs) |
DELETE |
/session/:session |
Log out and delete (docs) |
GET |
/session/logout?session=NAME |
Same as delete |
Messages
All message endpoints take session, to (phone number like 628123456789, or a group id) and optional is_group: true. Media URLs must be public http(s) URLs.
| Endpoint | Extra body fields |
|---|---|
POST /message/send-text |
text |
POST /message/send-image |
text (caption), image_url |
POST /message/send-video |
video_url, text (optional caption) |
POST /message/send-document |
text (caption), document_url, document_name (with extension) |
POST /message/send-sticker |
image_url |
POST /message/send-audio |
audio_url, as_voice_note (optional boolean) |
POST /message/send-poll |
name, options (2 to 12 strings), selectable_count (optional) |
History
Chats and messages the gateway has stored (the same data as the Inbox):
| Method | Endpoint | Query |
|---|---|---|
GET |
/session/:session/chats |
q (search), filter, limit, before |
GET |
/session/:session/chats/:chat/messages |
limit (default 50, max 500), before |
GET |
/session/:session/chats/:chat/messages/:id/media |
Downloads the photo/video/audio/document |
Each message has quoted (the message it replies to), location, contacts and poll (with vote counts) when present, otherwise null. :chat is a phone number (628123456789) or a full JID (groups: 1203630…@g.us). Chats come back most recent first (pinned chats first), with a next_before cursor for the next page; filter is all (default, without archived chats), unread, groups or archived. Messages come back oldest to newest with a next_before id: pass it as before to get the page before it (null when there is none).
Profile
POST /profile with { "session": "NAME", "target": "[email protected]" } returns the profile picture URL and status.
Inbox
Inbox in the dashboard shows each session's chats like WhatsApp Web: search, unread counts, text, photos, videos, voice notes, documents, reactions, edits and deleted messages, with delivered/read ticks on your replies. New messages appear live.
- Every team member (any role) can read and reply.
- Start a chat with any number (✎ next to the search box). On a message: reply with a quote, react, copy, edit your own text messages (within 15 minutes) or delete them for everyone (within 2 days).
- Filter chats by unread, groups or archived. Pinned and archived chats follow the phone. The list loads more as you scroll.
- Click a chat's name for its info: about text or group description and members, and all photos, videos and documents shared in it.
- See when someone is typing or recording, and when they're online. To receive this, the number shows as online while someone has a chat open in the inbox, the same as WhatsApp Web.
- Locations, contact cards and polls (with live vote counts) are shown as cards. Contact pictures come from WhatsApp when the contact's privacy settings allow it.
- Attach photos, videos, audio or documents (up to 64 MB) with the paperclip, by pasting, or by dropping a file on the chat. Photos and videos go out with the typed text as caption.
- When a number is linked, the last
HISTORY_SYNC_DAYSdays of history are imported. After that, everything the session sends or receives is stored. - Media is downloaded from WhatsApp the first time someone opens it and kept in
./data/inbox-media. - Opening a chat does not send read receipts unless
INBOX_READ_RECEIPTS=true. - Deleting a session also deletes its stored chats.
Audit log
Admins can see Audit log in the dashboard: sign-ins (including failed ones), and who created or deleted sessions, users, API keys and webhooks, with the IP address. Actions done through the API are recorded under the API key's name.
Webhooks
Add webhooks in the dashboard under Webhooks. Each one has a URL, a session (or all sessions) and the events it wants:
| Event | When |
|---|---|
message.received |
A message arrives (media is downloaded and linked) |
message.sent |
A message is sent from the API or from the phone |
message.status |
A sent message is delivered / read |
session.status |
A session is connecting, connected or disconnected |
Every delivery is a JSON POST:
{
"event": "message.received",
"session": "sales-team",
"timestamp": "2026-12-01T10:21:00.000Z",
"data": { "id": "3EB0…", "chat": "[email protected]", "from": "[email protected]", "type": "text", "text": "Halo", "media": null }
}
- Verify it:
x-wag-signatureissha256=+ HMAC-SHA256 of the raw body with the webhook's signing secret (shown in the dashboard). - Retries: reply with a 2xx within 10 seconds. Otherwise the delivery is retried after 10s, 30s, 2m, 10m and 30m.
- Delivery log: the last 7 days of deliveries, with payload and response, are visible in the dashboard and can be resent.
from/chat can be a …@lid id on newer WhatsApp accounts. When it is, from_alt/chat_alt carry the phone-number JID if WhatsApp provides it. Media files are saved to ./media and served at /media/FILE_NAME.
Events in the dashboard shows the same payloads live as they happen, across all sessions, so you can see what your webhook will receive without a receiver. It keeps the last 200 events in memory.
Legacy webhook (v4)
WEBHOOK_BASE_URL still works: the gateway POSTs { "session", "status" } to {WEBHOOK_BASE_URL}/session and { "session", "from", "from_alt", "message", "media": { "image", "video", "document", "audio" } } to {WEBHOOK_BASE_URL}/message, without retries.
Upgrading
cd ~/app/wa-gateway
docker compose pull
docker compose up -d
From v4
- Add the
./datavolume. To keep your linked numbers, also keep the./wa_credentials:/app/wa_credentialsvolume for the first start: v4 sessions are imported automatically. Sessions stored in Redis (REDIS_URL) are not imported and must be linked again. - The dashboard now uses accounts. On first visit you create the owner account.
- The API always requires a key now. In v4 an empty
KEYleft the API open. SetKEYor create a key in the dashboard. - Legacy webhook payloads gained
from_alt. Document webhooks now include the file extension inmedia.document. - Media URLs (
image_url,document_url, …) must behttp(s)URLs. Local file paths are rejected, since they let API callers read files from the server.
Development
Requires Node.js 24+ and pnpm.
pnpm install
pnpm dev # API on :5001, dashboard with hot reload on http://localhost:5173
pnpm test # unit tests
pnpm typecheck
pnpm docs:dev # documentation site (VitePress) on http://localhost:5173/wa-gateway/
The repo is a pnpm monorepo: apps/server (Hono + Baileys + Kysely, run directly by Node, no build step) and apps/web (React + Vite dashboard, served by the server in production). The documentation site lives in docs and is published to GitHub Pages on every push to master. The dashboard uses shadcn/ui; add components with pnpm dlx shadcn@latest add <name> inside apps/web.
Need Help?
Get in touch with me via email 📧 [email protected]
関連プロジェクトを探す
読み込み中…