Platforms / WhatsApp
WhatsApp API
Send and receive WhatsApp Business messages and templates.
At a glance
- Platform id
whatsapp- Connects
- business number
- Sign-in
- OAuth: the user approves on the platform's own page
- Post types
- Text · Image · Video · Template message
Capabilities
| Publishing | Partly |
|---|---|
| Scheduling | Yes |
| Comments | No |
| Direct messages | Yes |
| Mentions | No |
| Reviews | No |
| Analytics | No |
Required on every post
- platform_data.whatsapp.to: one or more phone numbers.
Options
Send these in platform_data.whatsapp on the post, or flat in a target's own platform_data (the target's keys win). See Publishing.
| Key | Type | What it does |
|---|---|---|
torequired | string or string[] | Recipients in international format. A comma list is accepted. |
template | { name, language, components? } | Send an approved template instead of free text (needed outside the 24-hour window). language is a code such as en_US. |
preview_url | boolean | Show a preview of the first link in a text message. |
Limits
- Text 4,096 characters; media captions 1,024.
- One image or one video per message.
Text over the limit fails validation before anything is sent. The caps of this server are explained in Rate limits.
Good to know
- The connect call takes a top-level onboarding: cloud_api (default) for a number used only through the API, or business_app for a number that stays on the WhatsApp Business app.
- Outside the 24-hour customer-service window only approved templates can be sent; the window reopens with each message the customer sends.
- No message history: the inbox fills from webhooks received after you connect.
- A tap on a reply button, list row or template quick reply arrives as dm.received with the tap's payload and interactive_type in its metadata. Every dm.received carries phone_number_id.
- dm.status.sent, delivered, read and failed follow each message you send; a failure carries WhatsApp's error_code, error_title and error_message.
- "Publishing" sends one message (text, one image or video, or a template) to each number you list; WhatsApp has no posts.
- Meta bills template messages per message category and country; replies inside the 24-hour window are free.
Publish with the API
curl https://api.zaynstack.com/v1/posts \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{
"text": "Hello from SocialWire",
"media": [{ "type": "image", "source_type": "url", "source": "https://example.com/file.jpg" }],
"platform_data": { "whatsapp": { "to": ["+14155550100"] } },
"targets": [{ "account_id": "<WhatsApp account id>" }],
"publish_now": true
}'An operation WhatsApp cannot do answers 501 resource.not_supported. Agents can do the same through the MCP server.
Connection errors
A connection that fails comes back to your redirect_uri with status=error, error=<code> and error_description, or as the error of the connect call. All codes: Connect accounts.
| Code | Meaning |
|---|---|
whatsapp.no_waba | The sign-in shared no WhatsApp Business Account. |
whatsapp.no_phone_number | The WhatsApp Business Account has no phone number. |
account.already_linked | The brand already holds a different account on this platform, or the account belongs to another brand while lock_accounts_to_brand is on. |
billing.brands_limit | No brand_id was sent, so a new brand was needed, and the plan has no room for another brand. |
Webhook events
Every platform sends the post.* and account.* events. WhatsApp also sends:
dm.received(button and list taps included)dm.sentdm.status.sent/ delivered / read / failed
Not supported yet
- Importing the chat history of a number that also uses the WhatsApp Business app (coexistence).
- Posts, comments and analytics.
Developer setup (self-hosting)
Only the operator of this server does this, once. Users then just click Connect.
- Create an app at developers.facebook.com → My Apps → Create app → type Business.
- Add the WhatsApp product to the app.
- Paste the Callback address shown below into Valid OAuth Redirect URIs.
- Under Webhooks, subscribe with the Webhook address below and your META_WEBHOOK_VERIFY_TOKEN.
- App settings → Basic: add Privacy Policy URL, Terms URL, User data deletion URL, app icon and category.
- Facebook Login for Business → Configurations: create one for WhatsApp Embedded Signup and put its id in WHATSAPP_CONFIG_ID.
- Callback address
https://api.zaynstack.com/api/connect/whatsapp/callback- Webhook address
https://api.zaynstack.com/api/hooks/whatsapp- Server variables
FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, WHATSAPP_CONFIG_ID, META_WEBHOOK_VERIFY_TOKEN- Developer console
- WhatsApp developer console
Permissions requested
whatsapp_business_managementwhatsapp_business_messaging
When a reconnect grants fewer permissions than before, an account.updated event with change permissions_reduced is sent. Accounts connected before a permission was added keep working but must reconnect to use the features it unlocks.
Before anyone can connect (review)
- Business verification of your company in Meta Business Manager (documents + domain).
- App Review: request Advanced Access for every permission listed below, each with a screencast of the feature and test instructions.
- Switch the app to Live mode after approval.
- Become a Tech Provider (Meta) so customers can onboard their own numbers through Embedded Signup.
Typical wait: 2-4 weeks. Until then the app works for your own accounts and the testers you add in the console.