WhatsApp Official
Connect your own Meta WhatsApp Business Account: templates, media, campaigns and replies.
The WhatsApp Official plugin connects your own WhatsApp Business Account from Meta to SMS21. Messages go out through Meta’s official Cloud API from your verified number and business name, with the templates approved on your account. You keep your Meta setup; SMS21 adds sending from the dashboard and API, campaigns, delivery tracking and an inbox.
Who pays what
Set up in Meta
- Verify your business in Meta Business Suite (Settings → Security Centre).
- Create an app at developers.facebook.com (type Business) and add the WhatsApp product.
- Add your phone number in WhatsApp Manager, verify it and add a payment method. The number must not be registered in the WhatsApp app.
- Create a permanent token: Business Settings → Users → System users → add an Admin system user, assign your app and WhatsApp account, and generate a token that never expires with
whatsapp_business_messagingandwhatsapp_business_management. - Copy the IDs: the Phone number ID and WhatsApp Business Account ID from WhatsApp → API Setup, and the App Secret from App settings → Basic.
Connect in SMS21
- Activate WhatsApp Official under Plugins (company owners and admins).
- Open WhatsApp Official → Connect, paste the two IDs, the token and the App Secret, and choose the project that receives replies. SMS21 verifies them with Meta and imports your templates.
- Copy the Callback URL and Verify token shown once, paste them in your app under WhatsApp → Configuration → Webhook, and subscribe to the
messagesfield. Switch the app to Live.
The token and App Secret are encrypted for SMS21’s sending service only; they are never shown again. Replace them under Connect whenever you rotate them in Meta.
Templates
- Templates on your account are synced automatically every 30 minutes (or with Sync with Meta). Their review status comes from Meta.
- Create templates in SMS21 under Templates: header, body with
{{name}}variables and sample values, footer and buttons. SMS21 submits them to Meta for review. - Templates with positional placeholders (
{{1}},{{2}}) appear with variablesvar1,var2; named ones keep their names.
Sending with the API
Nothing changes in your code: while the plugin is active, POST /whatsapp/template, POST /whatsapp/send and WhatsApp OTPs are sent from your own number, using the template IDs (wtpl_…) listed under Templates.
curl -X POST https://sms21.in/v1/whatsapp/template \
-H "X-API-Key: $SMS21_API_KEY" -H "Content-Type: application/json" \
-d '{
"to": "919876543210",
"templateId": "wtpl_…",
"variables": { "var1": "Asha", "var2": "A-1042" }
}'Media
| type | Use |
|---|---|
image | JPEG or PNG, up to 5 MB |
video | MP4 (H.264), up to 16 MB |
document | PDF and other files, up to 100 MB; set filename |
Files are sent by public https link; Meta downloads them. Templates with an image, video or document header need media; free-text messages may attach one with the text as caption.
Delivery, read receipts and replies
- Statuses (
submitted,delivered— including read — andfailed) arrive through the webhook you configured in Meta, and reach your own webhooks as usual. - Customer replies appear in WhatsApp Official → Inbox and are forwarded as
message.receivedevents to the chosen project’s webhooks. - Free-text messages are only delivered within 24 hours of the customer’s last message; the inbox shows when the window is open. Outside it, send a template.
Errors
| HTTP | Code | Meaning |
|---|---|---|
| 409 | WA_ACCOUNT_NOT_CONNECTED | The plugin is active but no account is connected, or Meta refused its token. |
| 400 | WHATSAPP_TEMPLATE_INVALID | The template is not on your connected account. |
| 400 | WA_META_REJECTED | Connecting: Meta refused the IDs or token (the reason is included). |
| 409 | WA_NUMBER_IN_USE | The number is connected to another SMS21 account. |
| 409 | TEMPLATE_NOT_APPROVED | Meta has not approved the template (yet). |
All fields are in the API reference.