Configuration
WA Gateway is configured with environment variables, set in docker-compose.yaml under environment. All of them are optional.
| Variable | Default | Description |
|---|---|---|
PORT | 5001 | HTTP 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 | ./data | Where the SQLite database and inbox media are stored. |
MEDIA_DIR | ./media | Where 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_REGION | us-east-1 | Bucket 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_DAYS | 7 | Days of chat history imported into the inbox when a number is linked. 0 imports nothing. |
INBOX_READ_RECEIPTS | false | When true, opening a chat in the inbox sends blue ticks to the sender. |
UPDATE_CHECK | true | Checks 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:
services:
wa-gateway:
image: mimamch/wa-gateway:latest
environment:
- HISTORY_SYNC_DAYS=30
- INBOX_READ_RECEIPTS=trueEverything else (numbers, users, API keys, webhooks) is managed in the dashboard and stored in the database.
Data on disk
| Path | Contents |
|---|---|
data/database.db | SQLite 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:
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:
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_ENDPOINTSwitching back from S3 to disk doesn't read the bucket: copy the files back the other way first.