📌 Step 1: Create Meta Developer Account
- Go to: https://developers.facebook.com
- Click Get Started
- Login with your Facebook account
- Verify your account (OTP + details)
👉 Now your Meta Developer account is ready.
📌 Step 2: Create a New App
- Click My Apps → Create App
- Select Business type
- Enter:
- App Name
- Click Create App
📌 Step 3: Add WhatsApp Product
- Inside your app dashboard
- Click Add Product
- Select WhatsApp → Set Up
👉 Now WhatsApp API is added to your app.
📌 Step 4: Get Temporary Access Token
After setup, you will see:
- Phone Number ID
- WhatsApp Business Account ID
- Temporary Access Token
👉 Copy the Access Token
📌 Step 5: Send Test Message
Use this API:
POST https://graph.facebook.com/v18.0/PHONE_NUMBER_ID/messages
Example JSON:
{
"messaging_product": "whatsapp",
"to": "YOUR_NUMBER",
"type": "text",
"text": {
"body": "Hello from WhatsApp Cloud API 🚀"
}
}
👉 Replace:
- PHONE_NUMBER_ID
- YOUR_NUMBER
📌 Step 6: Setup Webhook (Important)
- Go to WhatsApp → Configuration
- Click Edit Webhook
- Enter:
- Callback URL
- Verify Token
Example Verify Script (PHP):
if ($_GET['hub_verify_token'] === '12345') {
echo $_GET['hub_challenge'];
}
👉 This is required to receive incoming messages.
📌 Step 7: Subscribe to Events
Select:
- messages
- message_status
Click Subscribe
📌 Step 8: Make Token Permanent
Temporary token expires in 24 hours.
👉 To fix:
- Go to System Users in Meta Business
- Generate Permanent Access Token
- Assign WhatsApp permissions
⚠️ Common Errors & Fixes
❌ Error: Unsupported post request
👉 Fix:
- Check PHONE_NUMBER_ID
- Check API version
❌ Error: Invalid OAuth Access Token
👉 Fix:
- Token expired
- Generate new token
❌ Error: Recipient not allowed
👉 Fix:
- Add number in test recipients
❌ Webhook not verifying
👉 Fix:
- Verify token mismatch
- HTTPS required
🎯 Pro Tips
- Use templates for bulk messaging
- Always use HTTPS webhook
- Store access token securely
- Use queue system for bulk sends
💡 Use Cases
- Customer support automation
- Order updates
- OTP verification
- Marketing campaigns
🏁 Conclusion
Setting up WhatsApp Cloud API is easy if you follow the correct steps. With Meta’s official API, you can build powerful automation tools and grow your business faster.