Skip to content

Configuration ​

WA Gateway is configured with environment variables, set in docker-compose.yaml under environment. All of them are optional.

VariableDefaultDescription
PORT5001HTTP port of the API and dashboard.
DATABASE_URL(empty)Postgres connection URL, e.g. postgres://user:pass@host:5432/db. Empty means SQLite at DATA_DIR/database.db.
DATA_DIR./dataWhere the SQLite database and inbox media are stored.
MEDIA_DIR./mediaWhere media of incoming messages is saved for webhooks. Served publicly at /media/FILE_NAME.
S3_BUCKET(empty)Store media in this S3-compatible bucket instead of on disk. See S3 storage.
S3_ENDPOINT(empty)Bucket endpoint, e.g. https://<account>.r2.cloudflarestorage.com or http://minio:9000. Empty means AWS S3.
S3_REGIONus-east-1Bucket region.
S3_ACCESS_KEY_ID(empty)Access key; required when S3_BUCKET is set.
S3_SECRET_ACCESS_KEY(empty)Secret key; required when S3_BUCKET is set.
HISTORY_SYNC_DAYS7Days of chat history imported into the inbox when a number is linked. 0 imports nothing.
INBOX_READ_RECEIPTSfalseWhen true, opening a chat in the inbox sends blue ticks to the sender.
UPDATE_CHECKtrueChecks GitHub twice a day for a newer stable release and tells admins in the dashboard. false turns it off.
KEY(empty)A fixed API key, accepted next to keys created in the dashboard. Kept for v4 setups; prefer dashboard keys.
WEBHOOK_BASE_URL(empty)The v4-style global webhook. See Legacy webhook.

Example:

yaml
services:
  wa-gateway:
    image: mimamch/wa-gateway:latest
    environment:
      - HISTORY_SYNC_DAYS=30
      - INBOX_READ_RECEIPTS=true

Everything else (numbers, users, API keys, webhooks) is managed in the dashboard and stored in the database.

Data on disk ​

PathContents
data/database.dbSQLite database: users, API keys, webhooks, chats, messages and the linked numbers' credentials.
data/inbox-media/Photos, videos and documents opened or sent in the inbox.
media/Media of incoming messages, saved for webhooks and served at /media/.

Media is public

Files in media/ can be downloaded by anyone who knows the file name (it is the message ID). Don't expose the gateway to the internet if that's a problem for you, or clean the folder regularly. Inbox media in data/inbox-media/ needs a dashboard login.

S3 storage ​

Set S3_BUCKET to keep media in any S3-compatible storage (AWS S3, Cloudflare R2, MinIO, Backblaze B2, …) instead of the media/ and data/inbox-media/ folders:

yaml
    environment:
      - S3_BUCKET=wa-media
      - S3_ENDPOINT=https://<account>.r2.cloudflarestorage.com
      - S3_REGION=auto
      - S3_ACCESS_KEY_ID=...
      - S3_SECRET_ACCESS_KEY=...

Webhook media goes to media/<file> in the bucket, inbox media to inbox-media/<session>/<id>. Keep the bucket private: the gateway still serves webhook media at /media/FILE_NAME and inbox media behind the dashboard login, so URLs in webhook payloads don't change.

Switching an existing install to S3 ​

Media saved on disk before switching keeps working: when a file isn't in the bucket, the gateway reads it from media/ or data/inbox-media/, so keep those volumes mounted. To move everything into the bucket and free the disk, copy the folders once, then remove them:

sh
aws s3 sync ./media s3://wa-media/media --endpoint-url $S3_ENDPOINT
aws s3 sync ./data/inbox-media s3://wa-media/inbox-media --endpoint-url $S3_ENDPOINT

Switching back from S3 to disk doesn't read the bucket: copy the files back the other way first.

Uses the unofficial WhatsApp Web protocol. Not affiliated with WhatsApp or Meta.