WhatsApp Automation API — Developer Setup Guide (2026)

How to set up WhatsApp automation with the Business API. Cloud API setup, sending messages, webhooks, and code examples for developers.

SociaHive
SociaHive Team

Published April 16, 2026

The WhatsApp Business API (Cloud API) lets developers build automated messaging, chatbots, and notification systems on WhatsApp. Here is how to set it up from scratch, send your first automated message, and handle incoming messages with webhooks.

WhatsApp Cloud API vs On-Premises API

Meta offers two API options:

FeatureCloud APIOn-Premises API
HostingMeta-hostedSelf-hosted
Setup timeMinutesDays-weeks
CostFree (pay Meta conversation fees)Server + maintenance costs
ScalingAuto-scalesYou manage scaling
Best forMost businessesEnterprise with compliance needs

Use the Cloud API unless you have specific compliance requirements that demand self-hosted infrastructure. It is free, faster to set up, and maintained by Meta.

Setup Guide (Cloud API)

Step 1: Create a Meta Developer Account

Go to developers.facebook.com and create an account (or log in with your Facebook account).

Step 2: Create a Facebook App

  • Click "Create App" → Choose "Business" type
  • Give it a name and select your Business portfolio
  • Add the "WhatsApp" product to your app

Step 3: Get Your Test Credentials

Meta provides a test phone number and access token for development:

  • Test phone number — A Meta-provided number for sending test messages
  • Temporary access token — Valid for 24 hours
  • Phone number ID — Identifies which number sends messages
  • Business Account ID — Your WhatsApp Business Account identifier

Step 4: Send a Test Message

const phoneNumberId = 'YOUR_PHONE_NUMBER_ID'

const accessToken = 'YOUR_ACCESS_TOKEN'

const recipientPhone = '1234567890' // Must include country code

const response = await fetch(

https://graph.facebook.com/v18.0/${phoneNumberId}/messages,

{

method: 'POST',

headers: {

'Authorization': Bearer ${accessToken},

'Content-Type': 'application/json',

},

body: JSON.stringify({

messaging_product: 'whatsapp',

to: recipientPhone,

type: 'text',

text: { body: 'Hello from WhatsApp API!' },

}),

}

)

Step 5: Set Up Webhooks for Incoming Messages

To receive messages, configure a webhook:

    • Create a webhook endpoint on your server (HTTPS required)
    • In the Meta Developer Dashboard, go to WhatsApp → Configuration → Webhook
    • Enter your webhook URL and a verify token
    • Subscribe to "messages" webhook field

Your webhook handler:

// Verification (GET request from Meta)

app.get('/webhook', (req, res) => {

const mode = req.query['hub.mode']

const token = req.query['hub.verify_token']

const challenge = req.query['hub.challenge']

if (mode === 'subscribe' && token === 'YOUR_VERIFY_TOKEN') {

res.status(200).send(challenge)

} else {

res.sendStatus(403)

}

})

// Incoming messages (POST request from Meta)

app.post('/webhook', (req, res) => {

const entry = req.body.entry?.[0]

const change = entry?.changes?.[0]

const message = change?.value?.messages?.[0]

if (message) {

const from = message.from // Sender's phone number

const text = message.text?.body // Message text

// Process the message and send automated reply

await sendReply(from, You said: ${text})

}

res.sendStatus(200) // Always respond 200 to acknowledge

})

Step 6: Add a Production Phone Number

For production use:

    • Add your own phone number in the WhatsApp dashboard
    • Verify the number via SMS or voice call
    • Set up a display name (requires Meta review)
    • Generate a permanent access token (System User token)

Message Types

The WhatsApp API supports several message types:

  • Text — Plain text messages
  • Template — Pre-approved message templates (required for business-initiated conversations)
  • Image/Video/Document — Media messages with optional captions
  • Interactive — Buttons and list messages for structured responses
  • Location — Share a map pin
  • Contacts — Share contact cards

Pricing

The WhatsApp Cloud API itself is free. You pay Meta's per-conversation fees:

Conversation TypeCost (varies by country)
Marketing$0.05-0.15 per conversation
Utility$0.02-0.08 per conversation
Authentication$0.02-0.06 per conversation
Service (user-initiated)Free first 1,000/month

One conversation = a 24-hour messaging window with one user.

Using a Platform Instead

If building directly on the API is more work than you want, automation platforms handle the API integration for you:

  • SociaHive — Visual flow builder for WhatsApp + Instagram + more. No API coding needed.
  • WATI — WhatsApp-focused platform with team inbox
  • Twilio — Developer-friendly API wrapper with additional features

These platforms use the same WhatsApp Business API under the hood but provide visual tools, team management, and analytics on top.

Frequently Asked Questions

Is the WhatsApp Business API free?

The API access is free. Meta charges per-conversation fees when you send business-initiated messages. User-initiated conversations (the customer messages you first) get 1,000 free conversations per month.

Do I need a dedicated phone number?

Yes. The WhatsApp Business API requires a phone number that is not registered on any WhatsApp app (regular or Business). You can port an existing number or get a new one.

Can I use the WhatsApp API for bulk messaging?

Yes, through broadcast messages using approved templates. Recipients must have opted in to receive your messages. Unsolicited bulk messaging violates WhatsApp's policies.

Ready to automate your Instagram?

Start free, plans from $29/mo. 14-day free Pro trial included.

Get Started