EZContact API: Send WhatsApp Messages from Any App
Learn how to use the EZContact REST API to send WhatsApp messages, templates, and automate conversations from your own app, CRM, or backend system.
Your CRM just captured a new lead. Your e-commerce platform just got an order. Your scheduling tool just confirmed a booking.
What happens next? In most businesses: nothing automated. Someone has to manually copy the info, open WhatsApp, find the contact, and type a message.
The EZContact API changes that. With a single API call, you can send WhatsApp messages—templates, notifications, confirmations—from any app, script, or backend system. No manual copy-pasting. No delays.
This guide walks you through the EZContact REST API: authentication, endpoints, code examples in multiple languages, and best practices for building reliable WhatsApp automations.
Why Use the EZContact API?
EZContact is an official Meta Business Partner with access to the WhatsApp Business API. When you connect your app to EZContact’s API, you get:
- ✅ Official WhatsApp infrastructure — messages sent through Meta’s approved channels
- ✅ Template support — send pre-approved message templates to any contact, even outside the 24h window
- ✅ Direct messages — send free-form messages to contacts who’ve messaged you within 24 hours
- ✅ No setup complexity — EZContact handles the WhatsApp connection; you just call the API
- ✅ Centralized inbox — all replies come back into your EZContact panel (WhatsApp + Instagram + Messenger)
Prerequisites
Before you start, you’ll need:
- An EZContact account — sign up at ezcontact.ai
- A connected WhatsApp Business channel in your EZContact panel
- An API key — generate one in Settings → Preferences → API Keys
- At least one approved WhatsApp template (for messages to new contacts)
Authentication
All EZContact API requests require your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
You can test your credentials with the auth endpoint:
curl -s https://app.ezcontact.ai/api/v1/test_auth.php \
-H "Authorization: Bearer YOUR_API_KEY"
Successful response:
{
"status": "ok",
"account": "your-account-name"
}
If you get a 401, double-check your API key in Settings → API Keys.
Endpoint 1: Send a WhatsApp Template
Use this endpoint to send a pre-approved message template to any phone number — even contacts who have never messaged you before.
When to use it: Order confirmations, appointment reminders, re-engagement campaigns, alerts.
POST https://app.ezcontact.ai/api/v1/templates_send.php
Request body:
{
"to": "+15551234567",
"template_name": "appointment_reminder",
"language": "en_US",
"params": "John Doe,March 5 at 10am,Downtown Clinic"
}
| Field | Type | Required | Description |
|---|---|---|---|
to | string | ✅ | Phone number in E.164 format (e.g. +15551234567) |
template_name | string | ✅ | Exact name of your approved WhatsApp template |
language | string | ✅ | Template language code (e.g. en_US, es_MX) |
params | string | — | Comma-separated values for template variables ({{1}}, {{2}}, etc.) |
Full cURL example:
curl -s -X POST https://app.ezcontact.ai/api/v1/templates_send.php \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+15551234567",
"template_name": "appointment_reminder",
"language": "en_US",
"params": "John Doe,March 5 at 10am,Downtown Clinic"
}'
Response:
{
"status": "sent",
"message_id": "wamid.HBgNMTU1...",
"to": "+15551234567"
}
Endpoint 2: Send a Direct Message
Use this endpoint to send a free-form message to a contact who has messaged you within the last 24 hours.
When to use it: Replying to support requests, sending follow-ups, continuing conversations.
POST https://app.ezcontact.ai/api/v1/send_message.php
Request body:
{
"to": "+15551234567",
"message": "Hi! Your order #1234 has been shipped and will arrive by Thursday."
}
cURL example:
curl -s -X POST https://app.ezcontact.ai/api/v1/send_message.php \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+15551234567",
"message": "Hi! Your order #1234 has been shipped and will arrive by Thursday."
}'
Note: If the 24-hour window has expired, use the templates endpoint instead.
Code Examples
Python
import requests
API_KEY = "your_api_key_here"
BASE_URL = "https://app.ezcontact.ai/api/v1"
def send_whatsapp_template(to, template_name, language="en_US", params=None):
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
payload = {
"to": to,
"template_name": template_name,
"language": language,
}
if params:
payload["params"] = ",".join(params)
response = requests.post(
f"{BASE_URL}/templates_send.php",
headers=headers,
json=payload
)
return response.json()
# Example: Send appointment reminder
result = send_whatsapp_template(
to="+15551234567",
template_name="appointment_reminder",
language="en_US",
params=["John Doe", "March 5 at 10am", "Downtown Clinic"]
)
print(result)
Node.js
const axios = require('axios');
const API_KEY = 'your_api_key_here';
const BASE_URL = 'https://app.ezcontact.ai/api/v1';
async function sendWhatsAppTemplate(to, templateName, language = 'en_US', params = []) {
const response = await axios.post(
`${BASE_URL}/templates_send.php`,
{
to,
template_name: templateName,
language,
params: params.join(','),
},
{
headers: {
Authorization: `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
}
);
return response.data;
}
// Example: Notify new order
sendWhatsAppTemplate(
'+15551234567',
'order_confirmation',
'en_US',
['Order #5678', '$89.00', 'March 3, 2026']
).then(console.log);
PHP
<?php
$apiKey = 'your_api_key_here';
$baseUrl = 'https://app.ezcontact.ai/api/v1';
function sendWhatsAppTemplate($to, $templateName, $language = 'en_US', $params = []) {
global $apiKey, $baseUrl;
$payload = json_encode([
'to' => $to,
'template_name' => $templateName,
'language' => $language,
'params' => implode(',', $params),
]);
$ch = curl_init("$baseUrl/templates_send.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $apiKey",
'Content-Type: application/json',
]);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
// Example: Send shipping notification
$result = sendWhatsAppTemplate(
'+15551234567',
'shipping_notification',
'en_US',
['Order #1234', 'Thursday, March 5']
);
print_r($result);
?>
Real-World Use Cases
1. E-Commerce Order Notifications
Trigger a WhatsApp message the moment an order is placed or shipped — no manual follow-up needed.
# Called from your order management system
def on_order_shipped(order):
send_whatsapp_template(
to=order['customer_phone'],
template_name='shipping_notification',
params=[order['customer_name'], order['tracking_number'], order['estimated_delivery']]
)
2. Appointment Reminders (Healthcare, Services)
Send automatic reminders 24 hours before each appointment — reducing no-shows by up to 40%.
// Called from your scheduling system
async function sendAppointmentReminder(appointment) {
await sendWhatsAppTemplate(
appointment.patientPhone,
'appointment_reminder_24h',
'en_US',
[appointment.patientName, appointment.dateTime, appointment.location]
);
}
3. Lead Qualification Trigger
When a new lead fills out a form, trigger an instant WhatsApp message — before they go cold.
# Called from your CRM or form webhook
def on_new_lead(lead):
send_whatsapp_template(
to=lead['phone'],
template_name='lead_welcome',
params=[lead['name'], lead['interest']]
)
Error Handling
Always handle errors gracefully in production integrations:
def send_whatsapp_template(to, template_name, language="en_US", params=None):
try:
response = requests.post(...)
response.raise_for_status()
data = response.json()
if data.get("status") == "sent":
return {"success": True, "message_id": data["message_id"]}
else:
return {"success": False, "error": data.get("error", "Unknown error")}
except requests.exceptions.HTTPError as e:
if e.response.status_code == 401:
return {"success": False, "error": "Invalid API key"}
elif e.response.status_code == 429:
return {"success": False, "error": "Rate limit exceeded — retry after 60s"}
else:
return {"success": False, "error": str(e)}
except Exception as e:
return {"success": False, "error": str(e)}
Common error codes:
| Code | Meaning | Solution |
|---|---|---|
| 401 | Invalid API key | Check key in Settings → API Keys |
| 400 | Missing/invalid parameters | Check to format and template name |
| 429 | Rate limit exceeded | Wait 60s and retry (60 req/min limit) |
| 404 | Template not found | Check template name matches exactly |
Rate Limits
The EZContact API allows 60 requests per minute per API key. For bulk campaigns (hundreds or thousands of messages), use the bulk messaging feature in your EZContact dashboard instead — it handles rate limiting and queuing automatically.
Next Steps
The EZContact API makes it straightforward to add WhatsApp messaging to any system — your CRM, e-commerce platform, scheduling tool, or custom app.
To get started:
- Create your account → ezcontact.ai
- Connect your WhatsApp Business number in the Channels panel
- Generate your API key in Settings → API Keys
- Create your first template and get it approved by Meta
- Send your first message with the code examples above
Questions? Our team is available via WhatsApp at ezcontact.ai — or explore our full documentation.
EZContact is an official Meta Business Partner offering WhatsApp Business API, AI agents, and a unified inbox for WhatsApp, Instagram, and Messenger. Try it free at ezcontact.ai
