wamux-http

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0, MIT

README

wamux-http

An HTTP server that speaks the WAHA API on top of the wamux WhatsApp core. If you have software written against WAHA (n8n's WAHA nodes, scripts calling /api/sendText, webhook receivers) and want to run it on wamux, point it here instead and it keeps working.

Unofficial: wamux talks to WhatsApp through an unofficial library. Using it may break WhatsApp's terms of service and get an account banned.

Install

You need a running wamux daemon (its Unix socket) and this server with access to that socket. The easiest way is both as containers, with the reference compose.yaml: put a .env next to it with WAHA_API_KEY, then

docker compose up -d

The image comes in two variants, both FROM scratch (one static binary, no operating system), running as uid 10001 like the core so its socket opens:

Image Size
ghcr.io/llawli/wamux-http:v0.1.2 35 MB the binary alone
ghcr.io/llawli/wamux-http:v0.1.2-ffmpeg 440 MB plus ffmpeg and ffprobe

Without ffmpeg, convert: true on voice and video sends and the /media/convert routes answer an error, and voice notes and videos go out without waveform and duration (they still play). Pick the -ffmpeg variant if you send voice or video; the reference compose does.

Without containers, take the static binary from the releases (Linux x86_64, no libc needed), or build it:

go install github.com/LLawli/wamux-http/cmd/wamux-http@latest
WAHA_API_KEY=change-me WAMUX_HTTP_CORE_SOCKET=$HOME/.local/state/wamux/wamux.sock wamux-http

Conversion then uses ffmpeg, ffprobe and opustags from the PATH when they are installed.

Use

It is WAHA's API. Create and start a session, scan the QR, send a message:

curl -X POST localhost:3000/api/sessions -H 'X-Api-Key: change-me' \
  -H 'Content-Type: application/json' -d '{"name":"default","start":true}'
curl localhost:3000/api/default/auth/qr -H 'X-Api-Key: change-me' -o qr.png
curl -X POST localhost:3000/api/sendText -H 'X-Api-Key: change-me' \
  -H 'Content-Type: application/json' \
  -d '{"session":"default","chatId":"5511999999999@c.us","text":"hi"}'

Or open the panel at localhost:3000/dashboard, unlock it with the admin key, and pair, start and stop sessions, edit their webhooks and manage API keys there (WAHA_DASHBOARD_ENABLED=false turns it off).

WAHA's environment variables are read under their WAHA names (WAHA_API_KEY, WHATSAPP_HOOK_URL, WAHA_BASE_URL, PORT, ...). The server's own settings:

Variable Default
WAMUX_HTTP_CORE_SOCKET /run/wamux/wamux.sock the wamux daemon's socket
WAMUX_HTTP_DATABASE_URL sqlite://./wamux-http.db the store
WAMUX_HTTP_LISTEN :$PORT bind address
WAMUX_HTTP_EVENT_RETENTION 24h how long the event log keeps events
WAMUX_HTTP_WEBHOOK_TIMEOUT 30s one webhook attempt
WAMUX_HTTP_MEDIA_ALLOW_PRIVATE false let client URLs reach private addresses (trusted setups only)
WAMUX_HTTP_MEDIA_MAX_BYTES 100 MiB largest file fetched from a client URL
WAMUX_HTTP_MEDIA_FETCH_TIMEOUT 60s one fetch of a client URL

What is implemented and what answers 501: docs/coverage.md. Where this server knowingly differs from WAHA: docs/differences.md. How it is built: docs/architecture.md.

Deploy

bin/deploy builds the image from this checkout, pushes it to your registry and rolls compose.yaml on a host over ssh, with WAMUX_HTTP_IMAGE pointing at what it pushed; it reads config/deploy.env (copy config/deploy.env.example). docker build . makes the scratch image and docker build --target ffmpeg . the one with ffmpeg.

Releases: docs/releasing.md.

Develop

./scripts/ci.sh runs every gate (format, generated code, workflow lint, vet, lint, tests with the race detector, coverage document, vulnerabilities); CI runs the same script. Tests run against an in-process fake of the core. DASHBOARD_DEV=127.0.0.1:3199 go test ./internal/dashboard -run TestDevServer -v -timeout 0 runs the panel on that fake, with URLs that play the phone (scan the QR, log out). WAMUX_BIN=/path/to/wamux scripts/live-smoke.sh checks the server against a real wamux daemon with a throwaway store, up to a QR code from WhatsApp (no phone pairs).

License

Licensed under either of

at your option.

The binary links Go modules under their own licenses (BSD, MIT, ISC, Apache-2.0, MPL-2.0); THIRD-PARTY-LICENSES.md has their texts and where each one's source is, and ships in the tarball and in both images (/usr/local/share/doc/wamux-http). It also covers what the panel embeds: Datastar (MIT) and the IBM Plex fonts (SIL Open Font License 1.1).

The -ffmpeg image also carries ffmpeg 9.0.2 and ffprobe, GPL-3.0-or-later, as built by wader/static-ffmpeg. The image ships the GPL text and the license of every component they link (/usr/local/share/doc/ffmpeg), and their complete corresponding source is the static-ffmpeg-9.0.2-source release; packaging/ffmpeg has how it is collected and checked.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Directories

Path Synopsis
cmd
coverage command
Command coverage writes docs/coverage.md: which of WAHA's operations this edge implements and which answer 501, read from the routes the server actually registers.
Command coverage writes docs/coverage.md: which of WAHA's operations this edge implements and which answer 501, read from the routes the server actually registers.
wamux-http command
Command wamux-http serves WAHA's HTTP API on top of a wamux daemon.
Command wamux-http serves WAHA's HTTP API on top of a wamux daemon.
Package contract embeds the pinned WAHA OpenAPI document: the list of operations the edge answers, and the schemas its contract tests check responses against.
Package contract embeds the pinned WAHA OpenAPI document: the list of operations the edge answers, and the schemas its contract tests check responses against.
internal
app
Package app wires the edge together.
Package app wires the edge together.
config
Package config reads the edge's configuration from the environment.
Package config reads the edge's configuration from the environment.
core
Package core is the only package that speaks gRPC to the wamux daemon.
Package core is the only package that speaks gRPC to the wamux daemon.
dashboard
Package dashboard serves the web panel at /dashboard: pair sessions, start and stop them, edit their webhooks and metadata, and manage API keys.
Package dashboard serves the web panel at /dashboard: pair sessions, start and stop them, edit their webhooks and metadata, and manage API keys.
events
Package events publishes WAHA events: it builds the envelope, picks the webhooks that want the event and appends both to the store in one transaction.
Package events publishes WAHA events: it builds the envelope, picks the webhooks that want the event and appends both to the store in one transaction.
fakecore
Package fakecore is an in-process wamux daemon on a Unix socket, for tests.
Package fakecore is an in-process wamux daemon on a Unix socket, for tests.
httpapi
Package httpapi serves WAHA's HTTP API.
Package httpapi serves WAHA's HTTP API.
ingest
Package ingest turns the core's events for a session into WAHA: stored messages, chats and contacts, and published WAHA events.
Package ingest turns the core's events for a session into WAHA: stored messages, chats and contacts, and published WAHA events.
media
Package media moves files in and out of WhatsApp for the edge: it fetches the URLs clients send (behind an SSRF guard), converts voice and video with ffmpeg, and serves received media under /api/files, downloading it from the core on first request.
Package media moves files in and out of WhatsApp for the edge: it fetches the URLs clients send (behind an SSRF guard), converts voice and video with ffmpeg, and serves received media under /api/files, downloading it from the core on first request.
sessions
Package sessions runs WAHA sessions on wamux accounts.
Package sessions runs WAHA sessions on wamux accounts.
store
Package store is the edge's persistence, behind the Store interface.
Package store is the edge's persistence, behind the Store interface.
store/sqlite
Package sqlite implements store.Store on SQLite (modernc.org/sqlite, no cgo).
Package sqlite implements store.Store on SQLite (modernc.org/sqlite, no cgo).
store/storetest
Package storetest is the conformance suite every store engine must pass.
Package storetest is the conformance suite every store engine must pass.
testenv
Package testenv runs the whole edge for integration tests: a fake core on a Unix socket, a SQLite store in a temp dir, the background loops and the HTTP API on an httptest server.
Package testenv runs the whole edge for integration tests: a fake core on a Unix socket, a SQLite store in a temp dir, the background loops and the HTTP API on an httptest server.
waha
Package waha holds WAHA's data model: ids, message and event payloads.
Package waha holds WAHA's data model: ids, message and event payloads.
webhooks
Package webhooks delivers the outbox: every process claims due deliveries from the store, sends them the way WAHA does (headers, HMAC, retries) and records the outcome.
Package webhooks delivers the outbox: every process claims due deliveries from the store, sends them the way WAHA does (headers, HMAC, retries) and records the outcome.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL