A production-ready starter template for building WhatsApp automation, bots, and integrations using the Meta WhatsApp Cloud API and Python FastAPI.
Perfect for:
- Developers building WhatsApp bots
- Automation workflows
- Webhook receivers
- Message notifications
- Learning the Cloud API basics
- Receive messages via secure webhook (HMAC SHA-256 signature verification)
- Send text messages
- Send images, documents, templates
- Async HTTP with httpx (non-blocking)
- Pydantic request/response validation
- Configurable Graph API version
- Health check endpoints
.envenvironment setup- Docker and docker-compose support
- CI/CD with GitHub Actions
- Tests with pytest
- Proper logging and error handling
whatsapp-cloud-api-starter/
├─ src/
│ ├─ __init__.py
│ ├─ server.py # FastAPI server with lifespan
│ ├─ config.py # Centralized settings
│ ├─ models.py # Pydantic request/response models
│ ├─ send_message.py # Messaging endpoints
│ ├─ webhook.py # Webhook handler
│ └─ utils/
│ ├─ __init__.py
│ └─ verify_signature.py
├─ tests/
│ └─ test_endpoints.py
├─ examples/
│ └─ sample_payload.json
├─ .github/workflows/ci.yml
├─ .env.example
├─ .gitignore
├─ Dockerfile
├─ docker-compose.yml
├─ requirements.txt
├─ README.md
└─ LICENSEpip install -r requirements.txtcp .env.example .envWHATSAPP_TOKEN=your_api_token
WHATSAPP_PHONE_NUMBER_ID=your_phone_number_id
WHATSAPP_SECRET=your_app_secret
VERIFY_TOKEN=your_webhook_verify_token
GRAPH_API_VERSION=v21.0
uvicorn src.server:app --reloadYour server runs at: http://localhost:8000
Interactive API docs at: http://localhost:8000/docs
docker compose up --buildMeta will call:
GET /webhook?hub.verify_token=xxx&hub.challenge=yyy
We return the challenge if tokens match.
All messaging endpoints are under the /api prefix.
POST /api/send-message
{
"to": "2348012345678",
"message": "Hello from WhatsApp Cloud API Starter Kit!"
}POST /api/send-image
{
"to": "2348012345678",
"image_url": "https://example.com/photo.jpg",
"caption": "Check this out"
}POST /api/send-document
{
"to": "2348012345678",
"document_url": "https://example.com/file.pdf",
"filename": "report.pdf"
}POST /api/send-template
{
"to": "2348012345678",
"template_name": "hello_world",
"language_code": "en_US"
}WhatsApp will POST incoming messages to:
POST /webhook
Incoming payloads are validated with HMAC SHA-256 signature verification.
pytest tests/ -vMIT License Free to use, modify, and distribute.
- Lasisi Ibrahim Pelumi
- Full-Stack Engineer • WhatsApp Automation Expert
- GitHub: https://github.com/ibrahimpelumi6142