A self-hosted REST API that connects to your personal WhatsApp account, allowing you to send and receive messages programmatically from your own phone number. This solution uses the powerful aldinokemal/go-whatsapp-web-multidevice implementation with Docker containerization and Cloudflare Tunnel integration for worldwide accessibility.
Repository: Advanced WhatsApp Private API
Transform your private WhatsApp number into a programmable API:
- N8N Automation: Monitor incoming WhatsApp messages and send automated responses from your private number
- Workflow Integration: Connect email notifications, CRM updates, or any workflow to send WhatsApp messages
- Server Monitoring: Get alerts and status updates directly on your personal WhatsApp
- Custom Notifications: Send automated messages from your own number for home automation, reminders, or alerts
- Script Integration: Any application that can make HTTP requests can send WhatsApp messages from your private number
- Multi-Device Support: Run multiple WhatsApp numbers simultaneously on different endpoints
Global Access: Cloudflare Tunnel enables secure worldwide API access while maintaining control through IP-based or email-based access policies.
Session Persistence: WhatsApp connections remain active as long as your phone number is used within 14 days. Sessions are automatically restored after server restarts.
This project uses an unofficial method to communicate with WhatsApp. This is against the WhatsApp Terms of Service. There is a real risk that your phone number could be temporarily or permanently banned by WhatsApp.
Use at your own risk. Recommended to use a secondary, non-critical phone number for development.
- Comprehensive REST API: 87+ endpoints covering all WhatsApp functionality
- Multi-Number Support: Run multiple WhatsApp accounts simultaneously
- Media Support: Send/receive images, audio, videos, documents, stickers
- Advanced Messaging: Reactions, message editing, polls, location sharing
- Group Management: Create groups, manage participants, admin controls
- Contact Management: Access contacts, business profiles, user info
- Self-Hosted: Runs entirely on your infrastructure with Docker
- Global Access: Cloudflare Tunnel integration for worldwide secure access
- Session Persistence: Automatic reconnection with persistent storage
- 24/7 Operation: Runs as system services with auto-restart
- Easy Updates: Automated update script preserving all sessions
- Ubuntu 20.04+ server (Oracle Cloud, DigitalOcean, AWS, etc.)
- Docker and Docker Compose installed
- Cloudflare account with domain
- Internet connection
- WhatsApp account(s)
# Create project directory
mkdir -p /home/ubuntu/whatsapp-privateapi
cd /home/ubuntu/whatsapp-privateapi
# Install Docker if not present
sudo apt update
sudo apt install docker.io docker-compose -y
sudo usermod -aG docker ubuntu
# Download latest WhatsApp API image
docker pull ghcr.io/aldinokemal/go-whatsapp-web-multidevice:latestCreate Docker Compose configurations for each WhatsApp number:
Example for first number (+491633644503 β using last 3 digits "503"):
# docker-compose-1-503.yml (replace 503 with your number's last 3 digits)
version: '3.8'
services:
whatsapp-privateapi-1-503: # Replace 503 with your last 3 digits
image: ghcr.io/aldinokemal/go-whatsapp-web-multidevice:latest
ports:
- "3010:3000"
volumes:
- ./data-1-503:/app/storages # Replace 503 with your last 3 digits
restart: unless-stopped
container_name: whatsapp-privateapi-1-503 # Replace 503 with your last 3 digitsExample for second number (+4915510974808 β using last 3 digits "808"):
# docker-compose-2-808.yml (replace 808 with your number's last 3 digits)
version: '3.8'
services:
whatsapp-privateapi-2-808: # Replace 808 with your last 3 digits
image: ghcr.io/aldinokemal/go-whatsapp-web-multidevice:latest
ports:
- "3011:3000"
volumes:
- ./data-2-808:/app/storages # Replace 808 with your last 3 digits
restart: unless-stopped
container_name: whatsapp-privateapi-2-808 # Replace 808 with your last 3 digits# Start first API (replace 1-503 with your naming)
docker-compose -f docker-compose-1-503.yml up -d
# Start second API (replace 2-808 with your naming)
docker-compose -f docker-compose-2-808.yml up -d
# Verify containers are running
docker psCloudflare Tunnel enables secure worldwide access to your WhatsApp APIs through custom domains while maintaining access control via IP or email policies.
- Cloudflare account with domain
cloudflaredinstalled on Windows (for tunnel management)
On Windows:
# Download cloudflared
Invoke-WebRequest https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe -OutFile cloudflared.exe
# Authenticate with Cloudflare
.\cloudflared.exe tunnel login
# Create tunnels for each API (replace with your naming scheme)
.\cloudflared.exe tunnel create whatsapp-privateapi-1-503 # Replace 503 with your last 3 digits
.\cloudflared.exe tunnel create whatsapp-privateapi-2-808 # Replace 808 with your last 3 digits
# Set DNS records (replace with your naming scheme and domain)
.\cloudflared.exe tunnel route dns whatsapp-privateapi-1-503 whatsapp-privateapi-1-503.yourdomain.com
.\cloudflared.exe tunnel route dns whatsapp-privateapi-2-808 whatsapp-privateapi-2-808.yourdomain.com# Download and install cloudflared
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared-linux-amd64.deb
# Verify installation
cloudflared versionCreate tunnel configurations:
# API 1-503 configuration (replace with your naming)
sudo nano /etc/cloudflared/privateapi-1-503-config.ymltunnel: whatsapp-privateapi-1-503 # Replace with your tunnel name
credentials-file: /home/ubuntu/.cloudflared/TUNNEL-ID-1.json # Replace with actual tunnel ID
ingress:
- hostname: whatsapp-privateapi-1-503.yourdomain.com # Replace with your domain
service: http://127.0.0.1:3010
- service: http_status:404Create systemd services:
# Service for API 1-503 (replace naming throughout)
sudo tee /etc/systemd/system/cloudflared-1-503.service << 'EOF'
[Unit]
Description=Cloudflared 1-503 Tunnel
After=network.target
[Service]
Type=simple
User=ubuntu
ExecStart=/usr/bin/cloudflared --config /etc/cloudflared/privateapi-1-503-config.yml tunnel run
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
# Enable and start service (replace service name with your naming)
sudo systemctl daemon-reload
sudo systemctl enable cloudflared-1-503
sudo systemctl start cloudflared-1-503Cloudflare Zero Trust Setup:
- Go to
https://one.dash.cloudflare.com - Access β Applications β Add application
- Configure application with your domains
- Set policies:
- IP-based: Allow specific server IPs
- Email-based: Require email authentication
- Combined: Multiple authentication methods
Maintain the latest API version while preserving all WhatsApp sessions.
Create update script:
nano /home/ubuntu/whatsapp-privateapi/update-apis.sh#!/bin/bash
echo "π WhatsApp APIs Update started..."
cd /home/ubuntu/programs/whatsapp-privateapi
# Verify Docker access
if ! docker ps > /dev/null 2>&1; then
echo "β Docker access failed! Run script with sudo."
exit 1
fi
echo "π¦ Updating Docker images..."
docker pull ghcr.io/aldinokemal/go-whatsapp-web-multidevice:latest
echo "βΉοΈ Stopping both APIs first (to avoid network conflicts)..."
echo " β Stopping API 1-503..."
docker-compose -f docker-compose-1-503.yml down
echo " β Stopping API 2-808..."
docker-compose -f docker-compose-2-808.yml down
echo "π Starting both APIs with updated images (sessions preserved)..."
echo " β Starting API 1-503..."
docker-compose -f docker-compose-1-503.yml up -d
echo " β Starting API 2-808..."
docker-compose -f docker-compose-2-808.yml up -d
echo "β³ Waiting for containers to be ready..."
sleep 5
echo "β
Update completed successfully!"
echo "π Container status:"
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" | grep whatsapp
echo "πΎ Session data check:"
echo "API 1-503 sessions:"
ls -la data-1-503/ | head -5
echo "..."
echo "API 2-808 sessions:"
ls -la data-2-808/ | head -5
echo "..."
echo "π APIs are accessible on:"
echo " β API 1-503: http://localhost:3010"
echo " β API 2-808: http://localhost:3011"Make executable and set up automated updates:
# Make script executable
sudo chown root:root /home/ubuntu/whatsapp-privateapi/update-apis.sh
sudo chmod +x /home/ubuntu/whatsapp-privateapi/update-apis.sh
# Set up weekly automated updates (Sundays at 3 AM)
sudo crontab -e
# Add: 0 3 * * 0 /home/ubuntu/whatsapp-privateapi/update-apis.sh >> /home/ubuntu/whatsapp-privateapi/update.log 2>&1# Open required ports
sudo iptables -I INPUT 6 -p tcp --dport 3010 -j ACCEPT
sudo iptables -I INPUT 6 -p tcp --dport 3011 -j ACCEPT
sudo iptables -I INPUT 6 -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT 6 -p tcp --dport 443 -j ACCEPT
sudo netfilter-persistent saveConfigure Security Groups to allow:
- Port 80: HTTP (0.0.0.0/0)
- Port 443: HTTPS (0.0.0.0/0)
- Port 3010: API 1-503 (optional if using Cloudflare)
- Port 3011: API 2-808 (optional if using Cloudflare)
π For detailed Oracle Cloud setup and instance creation: Oracle Cloud General Setup Guide
- Visit your API endpoint:
https://whatsapp-privateapi-1-503.yourdomain.com(replace with your naming and domain) - Scan QR code with your WhatsApp mobile app
- API becomes ready for use
curl -X POST https://whatsapp-privateapi-1-503.yourdomain.com/send/message \
-H "Content-Type: application/json" \
-d '{
"phone": "1234567890",
"message": "Hello from API!"
}'curl -X POST https://whatsapp-privateapi-1-503.yourdomain.com/send/image \
-H "Content-Type: application/json" \
-d '{
"phone": "1234567890",
"caption": "Check this image!",
"image": "base64_encoded_image_data"
}'curl -X POST https://whatsapp-privateapi-1-503.yourdomain.com/group \
-H "Content-Type: application/json" \
-d '{
"name": "My API Group",
"participants": ["1234567890", "0987654321"]
}'# Check container status (replace with your naming)
docker ps
docker logs whatsapp-privateapi-1-503
# Restart containers (replace with your naming)
docker-compose -f docker-compose-1-503.yml restart# Check tunnel services (replace with your naming)
sudo systemctl status cloudflared-1-503
sudo systemctl status cloudflared-2-808
# Restart tunnel services (replace with your naming)
sudo systemctl restart cloudflared-1-503- Session Lost: Re-scan QR code at API endpoint
- Connection Timeout: Check if phone number was used within 14 days
- API Not Responding: Verify container and tunnel status
# Container management (replace container names with your naming)
docker ps # List running containers
docker logs whatsapp-privateapi-1-503 # View container logs
docker-compose -f docker-compose-1-503.yml restart # Restart API
# Tunnel management (replace service names with your naming)
sudo systemctl status cloudflared-1-503 # Check tunnel status
sudo systemctl restart cloudflared-1-503 # Restart tunnel
sudo journalctl -u cloudflared-1-503 -f # View tunnel logs
# Update APIs
sudo /home/ubuntu/whatsapp-privateapi/update-apis.shGET /app/loginβ Display QR code for loginGET /app/login-with-codeβ Generate pairing code for loginPOST /app/logoutβ Logout sessionPOST /app/reconnectβ Rebuild connectionGET /app/devicesβ List linked devices
GET /user/info?jid={phone@s.whatsapp.net}β Get contact informationGET /user/avatar?jid={phone@s.whatsapp.net}β Get profile picturePOST /user/pushnameβ Set display nameGET /user/my/groupsβ Get own groupsGET /user/my/newslettersβ Get own broadcast listsGET /user/my/privacyβ Get privacy settingsGET /user/my/contactsβ Get all contactsGET /user/check?phone=491234567890β Check if number has WhatsAppGET /user/business-profile?jid=...β Get business profile info
POST /send/messageβ Send text messagePOST /send/imageβ Send imagePOST /send/audioβ Send audio/voice messagePOST /send/videoβ Send videoPOST /send/documentβ Send documentPOST /send/contactβ Send contact cardPOST /send/linkβ Send link with previewPOST /send/locationβ Send locationPOST /send/pollβ Send pollPOST /send/stickerβ Send stickerPOST /send/presenceβ Set online/offline statusPOST /send/chat-presenceβ Set "typing..." status
POST /message/{id}/revokeβ Revoke message (delete for everyone)POST /message/{id}/deleteβ Delete locallyPOST /message/{id}/reactionβ Add emoji reactionPOST /message/{id}/updateβ Edit message (within 15 min)POST /message/{id}/readβ Mark as readPOST /message/{id}/starβ Star messagePOST /message/{id}/unstarβ Remove star
GET /chatsβ Get all chatsGET /chat/{chat_jid}/messagesβ Get message historyPOST /chat/{jid}/labelβ Set chat labelPOST /chat/{jid}/pinβ Pin chat
POST /groupβ Create group with participantsPOST /group/join-with-linkβ Join group via invite linkGET /group/info?jid=...β Get group informationPOST /group/leaveβ Leave groupPOST /group/participants/addβ Add participantsPOST /group/participants/removeβ Remove participantsPOST /group/participants/promoteβ Promote to adminPOST /group/participants/demoteβ Demote from adminGET /group/participant-requests?jid=...β List pending join requestsPOST /group/participants/approveβ Approve join requestPOST /group/participants/rejectβ Reject join requestPOST /group/photoβ Set group picturePOST /group/nameβ Change group namePOST /group/lockedβ Lock/unlock groupPOST /group/announceβ Toggle announcement modePOST /group/topicβ Set group topicGET /group/invite-link?group_id=...β Get group invite link
POST /newsletter/unfollowβ Unfollow broadcast list
π Check out the detailed cURL commands in the api.md file in this repo!
This project is provided as-is for educational purposes. Use at your own risk and in compliance with WhatsApp's Terms of Service.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Ready to programmatically control your WhatsApp communications with enterprise-grade reliability!