How to Send a WhatsApp Message with the API: A Developer's Guide for 2026
A developer's guide to sending WhatsApp messages via Meta's Cloud API in 2026: tokens, the /messages endpoint, templates, the 24-hour window, and pricing.
To send a WhatsApp message with the API, you POST a JSON payload to https://graph.facebook.com/v22.0/<PHONE_NUMBER_ID>/messages with an Authorization: Bearer <ACCESS_TOKEN> header. The body names the recipient, the message type, and the content. If the customer has messaged you in the last 24 hours you can send free-form text; outside that window you must send a pre-approved template.
This guide walks through the pieces a developer actually needs: where the phone number ID and access token come from, the difference between template and session messages, how the 24-hour window governs what you can send, and what Meta charges per conversation. The examples use Meta's WhatsApp Cloud API, which is the hosted version most US teams start with.
Last updated July 2026.
How do I send a message using the WhatsApp API?
Send an HTTP POST to graph.facebook.com/v22.0/<PHONE_NUMBER_ID>/messages with a Bearer access token in the header and a JSON body. Set messaging_product to whatsapp, add the recipient number in international format, pick a message type, and supply the content for that type.
Here is a minimal request that sends an approved template. Swap in your own phone number ID, token, recipient, and template name.
curl -X POST \
'https://graph.facebook.com/v22.0/<PHONE_NUMBER_ID>/messages' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"to": "15551234567",
"type": "template",
"template": {
"name": "order_confirmation",
"language": { "code": "en_US" }
}
}'
A successful call returns a JSON object with a message ID. To send plain text inside an open window, change type to text and pass a text object with a body string instead of the template block. Full details live in our guide to WhatsApp API integration.
Two things trip up first-time senders. The recipient number must be in full international format with no plus sign, spaces, or dashes, so a US number looks like 15551234567. And the API version in the URL matters: pin it to a version like v22.0 rather than leaving it floating, because Meta ships breaking changes across versions and old ones eventually retire.
How do I get a WhatsApp API access token?
Create a Meta developer app, add the WhatsApp product, and connect a WhatsApp Business Account. The dashboard gives you a temporary token that lasts about 24 hours for testing. For production, create a System User in Meta Business Suite and generate a permanent token scoped to your app and phone number.
Where does the phone number ID come from?
The phone number ID is not your phone number. It is a numeric identifier Meta assigns to each number registered on your WhatsApp Business Account. Find it in the API setup panel of your Meta developer app, next to the display number. That ID goes in the endpoint URL for every send. See the WhatsApp Business API overview for the full account setup.
Do I need a template to send a WhatsApp message?
It depends on timing. Inside the 24-hour customer service window you can send free-form text, media, and interactive messages without a template. Outside that window, or to start a conversation the user did not open, you must send a message template that Meta has already reviewed and approved for a specific category.
What is the 24-hour window in the WhatsApp API?
When a user messages you, a 24-hour timer starts. While it runs, you can reply with any supported message type at no charge for the service reply. Each new inbound message resets the timer. Once 24 hours pass with no reply from the user, the window closes and only approved templates are allowed.
Is the WhatsApp Cloud API free?
The API calls themselves are free. Meta hosts the Cloud API at no charge, so you are not billed for making requests. You pay Meta per conversation based on category. As of 2026 the approximate US rates are utility around $0.006 and authentication around $0.004 per message, while service replies in the open window are free. Treat these as approximate and check current rates on our WhatsApp Business API pricing page.
What are the message categories in the WhatsApp API?
Templates fall into three billable categories: utility, authentication, and marketing. Utility covers order updates and account alerts. Authentication delivers one-time codes. Marketing covers promotions and offers. Meta paused marketing-category templates to US numbers on April 1, 2025, and that pause is still in effect in 2026, so utility and authentication are your options for US sends.
Can I send bulk messages with the WhatsApp API?
Yes. Bulk sending means looping approved templates across many recipients, one POST per contact, within your account's messaging limit tier. Meta raises that tier as you send quality traffic. Respect opt-in rules and pace your requests. A managed WhatsApp bulk sender handles batching, retries, and rate limits so you do not build that layer yourself.
What is the difference between the Cloud API and the On-Premises API?
The Cloud API is hosted by Meta on its own servers, so there is nothing to install and you get updates automatically. The On-Premises API ran on servers you managed yourself. Meta has deprecated the On-Premises version, and the Cloud API is now the supported path for new integrations.
How do I handle errors and delivery status?
Every response carries either a message ID or an error object with a code and description. Common failures include an expired token, an unapproved template, a recipient outside the 24-hour window, or a malformed number. Register a webhook to receive sent, delivered, read, and failed status callbacks so your system knows what actually reached the customer.
Build retry logic for transient errors and back off when Meta returns a rate-limit response. Store the message ID from each send so you can match it to the status webhook later. That mapping is what lets you show accurate delivery states in your own dashboard rather than guessing.
Step-by-step summary
| Step | What you do |
|---|---|
| 1. Create app | Set up a Meta developer app and add the WhatsApp product. |
| 2. Connect account | Link a WhatsApp Business Account and register a phone number. |
| 3. Get credentials | Copy the phone number ID and generate a permanent access token. |
| 4. Create a template | Submit a utility or authentication template for Meta approval. |
| 5. Send the POST | Call the /messages endpoint with your token and JSON body. |
| 6. Handle webhooks | Read delivery and reply events to track status and the window. |
Wiring it into your stack
Once messages flow, most of the work moves to your own systems: firing sends when an order ships, logging delivery receipts, and syncing replies back to your CRM. The API gives you webhooks for inbound messages and status updates, and if you need to pipe those events between other tools, a dedicated data integration platform handles the plumbing without custom glue code. Start with utility templates, confirm opt-in for every contact, and grow your volume as Meta lifts your messaging tier.
A few habits keep an integration healthy over time. Rotate to a permanent System User token before you launch, because the temporary developer token expires in about a day and will silently break production. Keep at least one utility and one authentication template approved and versioned in your codebase so a rejected edit never leaves you unable to send. Log every request and response body during your first weeks live, since most support questions come down to a number format or a template variable that did not match.
The Cloud API rewards clean setup. Get the token and phone number ID right, keep your templates approved, and watch the 24-hour clock, and sending WhatsApp messages programmatically becomes a routine part of your backend.