WhatsApp API
Configure your WhatsApp Business API integration and send messages programmatically.
Setup Guide
Before using the WhatsApp endpoints, you need to obtain credentials from Facebook/Meta.
Step 1: Create Facebook Developer Account
- Go to developers.facebook.com
- Click 'Get Started' and create an account
- Verify your email and phone number
- Complete developer verification if prompted
Step 2: Create Facebook App
- Go to 'My Apps' > 'Create App'
- Select 'Business' as the app type
- Fill in app name and contact email
- Add WhatsApp product to your app
- Note down your App ID and App Secret
Step 3: Set Up WhatsApp Business API
- Go to WhatsApp > API Setup in your app
- Add a phone number (or use test number)
- Generate temporary access token
- Note down your WhatsApp Business Account ID
- Copy the temporary access token
Step 4: Generate System User Token
- Go to Business Settings > System Users
- Create a new system user
- Assign WhatsApp Business Management permission
- Generate a permanent access token
- Save this token securely - it doesn't expire
Step 5: Configure Webhook (Optional)
- Go to WhatsApp > Configuration
- Add webhook URL:
https://your-domain.com/webhook/whatsapp - Use a verify token (any random string)
- Subscribe to
messagesandmessaging_postbacksevents - Verify webhook endpoint
Required Credentials
| Credential | Description |
|---|---|
| Facebook App ID | Your Facebook App ID from step 2 |
| Facebook App Secret | Your Facebook App Secret from step 2 |
| WhatsApp Business Account ID | From WhatsApp API Setup |
| System User Access Token | Long-lived token from step 4 |
| Phone Number ID | From WhatsApp API Setup |
| Webhook Verify Token | Custom token for webhook verification |
Troubleshooting
| Issue | Solution |
|---|---|
| Can't find WhatsApp product | Ensure your developer account is verified and you've selected 'Business' app type |
| Access token expired | Use System User tokens instead of temporary tokens for production |
| Phone number not verified | Verify your phone number in WhatsApp Business API settings |
| Webhook verification failed | Ensure your webhook endpoint returns the challenge parameter |
Configure WhatsApp Integration
Set up WhatsApp Business API credentials in your workspace.
POST /api/whatsapp/configure
Request Body:
{
"facebookAppId": "your_facebook_app_id",
"facebookAppSecret": "your_facebook_app_secret",
"whatsappBusinessAccountId": "your_whatsapp_business_account_id",
"accessToken": "your_system_user_access_token",
"phoneNumberId": "your_phone_number_id",
"webhookVerifyToken": "your_webhook_verify_token"
}
Response:
{
"success": true,
"message": "WhatsApp configuration saved successfully",
"configuration": {
"id": 1,
"isConfigured": true,
"phoneNumber": "+1234567890",
"businessAccountId": "your_whatsapp_business_account_id",
"tokenExpiresAt": "2025-12-31T23:59:59.000Z",
"createdAt": "2025-01-01T00:00:00.000Z"
}
}
Check WhatsApp Status
Check the status of your WhatsApp Business API integration.
GET /api/whatsapp/status
Response:
{
"isConfigured": true,
"isActive": true,
"phoneNumber": "+1234567890",
"businessAccountId": "123456789",
"tokenStatus": "valid",
"tokenExpiresAt": "2025-12-31T23:59:59.000Z",
"lastSyncAt": "2025-01-01T12:00:00.000Z",
"templatesCount": 5,
"capabilities": {
"sendMessages": true,
"receiveMessages": true,
"manageTemplates": true,
"accessInsights": true
}
}
Sync WhatsApp Templates
Import approved message templates from WhatsApp Business API.
POST /api/whatsapp/templates/sync
Response:
{
"success": true,
"message": "Templates synced successfully",
"imported": 5,
"updated": 2,
"skipped": 1,
"templates": [
{
"id": 1,
"name": "welcome_message",
"status": "APPROVED",
"language": "en",
"category": "MARKETING",
"components": [
{
"type": "BODY",
"text": "Hello {{1}}, welcome to {{2}}!"
}
]
}
]
}
Send WhatsApp Message
Send a message using WhatsApp Business API.
POST /api/whatsapp/send
Request Body:
{
"to": "+1234567890",
"type": "template",
"template": {
"name": "welcome_message",
"language": {
"code": "en"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "John"
},
{
"type": "text",
"text": "Acme Corp"
}
]
}
]
}
}
Response:
{
"success": true,
"message": "Message sent successfully",
"messageId": "wamid.ABC123...",
"status": "sent",
"timestamp": "2025-01-01T12:00:00.000Z"
}
cURL Example:
curl -X POST "https://waflow.edesy.in/api/whatsapp/send" \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{
"to": "+1234567890",
"type": "template",
"template": {
"name": "welcome_message",
"language": {"code": "en"},
"components": [
{
"type": "body",
"parameters": [
{"type": "text", "text": "John"},
{"type": "text", "text": "Acme Corp"}
]
}
]
}
}'
List WhatsApp Templates
Get all approved WhatsApp message templates.
GET /api/whatsapp/templates
Response:
{
"templates": [
{
"id": 1,
"name": "welcome_message",
"status": "APPROVED",
"language": "en",
"category": "MARKETING",
"components": [
{
"type": "HEADER",
"format": "TEXT",
"text": "Welcome!"
},
{
"type": "BODY",
"text": "Hello {{1}}, welcome to {{2}}! We're excited to have you on board."
},
{
"type": "FOOTER",
"text": "Best regards, Team"
}
]
}
],
"total": 1
}
Testing Your Setup
After completing the setup:
- Go to Settings > WhatsApp Configuration in WAFlow
- Enter your credentials and save
- Check that the status indicator turns green
- Try syncing templates from WhatsApp
- Send a test message to verify