Getting Started
WA-RS is a multi-session WhatsApp REST API gateway built with Rust. It provides a simple HTTP interface to interact with WhatsApp Web.
Features
- Multi-session support — Manage multiple WhatsApp accounts
- QR Code and Pair Code authentication — Connect via QR scan or phone number
- Send messages — Text, image, video, audio, document, sticker, location, contact
- Interactive messages — Polls, buttons, lists, payments, newsletters
- Webhook support — Receive events with HMAC-SHA256 signatures
- NATS JetStream — Optional durable event streaming and outbound message queue
- JWT authentication — Secure API access
- Multi-database support — PostgreSQL or MySQL via
DATABASE_URL - CLI arguments — Configure token, database, and port from command line
- Swagger UI — Interactive API documentation
Quick Start
With MySQL
./wa-rs --token mysecrettoken --db mysql://user:pass@localhost:3306/wars
With PostgreSQL
./wa-rs --token mysecrettoken --db postgres://user:pass@localhost:5432/wagateway
# Test it
curl -H "Authorization: Bearer mysecrettoken" http://localhost:3451/health
Using Docker Compose
git clone https://github.com/fdciabdul/wa-rs.git
cd wa-rs
# Create .env
cat > .env << 'EOF'
DATABASE_URL=mysql://user:pass@host:3306/wars
SUPERADMIN_TOKEN=mysecrettoken
EOF
docker compose up -d
Build from Source
-
Requirements
- Rust nightly
- PostgreSQL 14+ or MySQL 8+
-
Clone and build
git clone https://github.com/fdciabdul/wa-rs.git
cd wa-rs
rustup default nightly
cargo build --release -
Run
# With MySQL
./target/release/wa-rs --token mysecrettoken --db mysql://user:pass@localhost/mydb
# With PostgreSQL
./target/release/wa-rs --token mysecrettoken --db postgres://user:pass@localhost/wagateway
# With .env file
cp .env.example .env
# Edit .env with your settings
./target/release/wa-rs
CLI Options
Usage: wa-rs [OPTIONS]
Options:
-t, --token <TOKEN> Set superadmin token
-d, --db <URL> Set database URL (postgres/mysql)
-p, --port <PORT> Set server port (default: 3451)
-h, --help Show help
CLI arguments override .env values.
Access Points
After starting the server:
| Endpoint | Description |
|---|---|
http://localhost:3451/health | Health Check |
http://localhost:3451/swagger-ui | Swagger UI Documentation |
http://localhost:3451/api/v1/sessions | Sessions API |
http://localhost:3451/api/v1/nats/status | NATS Status (if enabled) |
Next Steps
- Installation Guide — Detailed setup for Docker, Linux, Windows
- Authentication — Token setup and API authentication
- API Reference — Complete API documentation
- Webhooks — Real-time event notifications
- NATS JetStream — Event streaming and outbound messaging