Want to send WhatsApp messages from your code? This developer guide covers the WhatsApp Cloud API by Meta and the simpler Infowave REST API – with working examples in cURL, PHP, Python and Node.js.
What is WhatsApp Cloud API?
WhatsApp Cloud API is Meta's hosted WhatsApp Business API. You send HTTPS requests to graph.facebook.com with an access token and your phone number ID; Meta delivers the message and sends status updates to your webhook.
- Access token – a permanent System User token from Meta Business settings
- Phone number ID – the ID of your registered business number (not the number itself)
- WABA ID – your WhatsApp Business Account, used for templates
- Webhook – your HTTPS endpoint for incoming messages and delivery status
Option A: Send a message with Meta's Cloud API directly
curl -X POST "https://graph.facebook.com/v21.0/PHONE_NUMBER_ID/messages" \
-H "Authorization: Bearer META_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "919876543210",
"type": "template",
"template": { "name": "hello_world", "language": { "code": "en_US" } }
}'
Free-form text ("type": "text") only works inside the 24-hour customer service window. To start a conversation, you must use an approved template. With the raw API you also handle media uploads, template components, retries and webhook verification yourself.
Option B: Send a message with the Infowave API (simpler)
Infowave wraps the Cloud API into short endpoints and shows every message in your team inbox. Get your vendor UID and API token from the dashboard's API settings.
cURL – send a text message
curl -X POST "https://wa.infowaveit.com/api/VENDOR_UID/contact/send-message" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"phone_number":"919876543210","message_body":"Hi Rahul, your order #1042 has shipped."}'
PHP
$ch = curl_init("https://wa.infowaveit.com/api/VENDOR_UID/contact/send-message");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer YOUR_API_TOKEN", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"phone_number" => "919876543210",
"message_body" => "Hi Rahul, your order #1042 has shipped.",
]),
]);
$response = curl_exec($ch);
Python
import requests
r = requests.post(
"https://wa.infowaveit.com/api/VENDOR_UID/contact/send-message",
headers={"Authorization": "Bearer YOUR_API_TOKEN"},
json={"phone_number": "919876543210", "message_body": "Hi Rahul, your order #1042 has shipped."},
timeout=30,
)
print(r.json())
Node.js
const res = await fetch("https://wa.infowaveit.com/api/VENDOR_UID/contact/send-message", {
method: "POST",
headers: { "Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json" },
body: JSON.stringify({ phone_number: "919876543210", message_body: "Hi Rahul, your order #1042 has shipped." }),
});
console.log(await res.json());
Send a template message (to start a conversation)
curl -X POST "https://wa.infowaveit.com/api/VENDOR_UID/contact/send-template-message" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "919876543210",
"template_name": "order_shipped",
"template_language": "en",
"field_1": "Rahul",
"field_2": "#1042"
}'
field_1, field_2… fill the template's body variables in order. Media headers and buttons are supported too – see the template API docs.
Send an image or PDF
curl -X POST "https://wa.infowaveit.com/api/VENDOR_UID/contact/send-media-message" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"phone_number":"919876543210","media_type":"document",
"media_url":"https://example.com/invoice-1042.pdf","file_name":"Invoice-1042.pdf","caption":"Your invoice"}'
Receive replies with webhooks
Add your webhook URL in API settings. Infowave POSTs a JSON payload for every incoming message and status change (sent, delivered, read, failed), so you can update your CRM or trigger workflows. Full payload examples are in the webhook docs.
Best practices
- Always use international format without
+–91+ 10-digit number for India. - Use templates for first messages and the free 24-hour window for replies.
- Keep your API token secret – store it in environment variables, never in front-end code.
- Handle errors and retry with backoff on temporary failures.