Skip to main content

Send WhatsApp API

Send WhatsApp messages to specific recipients, contacts, tags, or all contacts. Uses Meta-approved templates with variable substitution and supports scheduling.

Endpoint

POST /api/v1/whatsapp/send

Headers

X-API-Key: sk_live_your_api_key
Content-Type: application/json

Quick Example

curl -X POST https://api.sendmator.com/api/v1/whatsapp/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "order_confirmation",
"recipient_type": "direct_whatsapp",
"direct_whatsapp": "+1234567890",
"conversation_category": "UTILITY",
"variables": {
"order_id": "12345",
"delivery_date": "March 20"
}
}'

Request Parameters

Required Fields

FieldTypeDescription
template_keystringWhatsApp template identifier (must be Meta-approved)
recipient_typestringHow to target recipients: direct_whatsapp, contact, tag, all
conversation_categorystringWhatsApp conversation category: MARKETING, UTILITY, AUTHENTICATION

Recipient-Specific Fields

Recipient TypeRequired FieldTypeDescription
direct_whatsappdirect_whatsappstringPhone number in E.164 format (e.g., +1234567890)
contactcontact_external_idstringExternal ID of the contact
tagtagstring[]Array of tags to match
all(none)-Sends to all active contacts with WhatsApp opt-in

Optional Fields for Direct WhatsApp

FieldTypeDescription
direct_first_namestringRecipient's first name (for personalization)
direct_last_namestringRecipient's last name (for personalization)

Common Optional Fields

FieldTypeDescription
variablesobjectTemplate variables (key-value pairs)
metadataobjectCustom tracking data
triggerAtstringISO 8601 UTC timestamp for scheduled send
whatsapp_identity_idstringWhatsApp identity UUID (defaults to user's default)
campaign_namestringCampaign name for tracking purposes

Conversation Categories

WhatsApp requires you to specify the conversation category for billing and compliance:

CategoryDescriptionUse CasesExample
MARKETINGPromotional messagesSales, offers, updates"50% off this weekend!"
UTILITYAccount updates, transactionsOrder confirmations, shipping updates"Your order has shipped"
AUTHENTICATIONOTPs, verification codesLogin codes, 2FA"Your verification code is 123456"

Complete Examples

1. Send Direct WhatsApp OTP

Send to a specific phone number for authentication:

curl -X POST https://api.sendmator.com/api/v1/whatsapp/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "otp_verification",
"recipient_type": "direct_whatsapp",
"direct_whatsapp": "+1234567890",
"direct_first_name": "John",
"conversation_category": "AUTHENTICATION",
"variables": {
"otp_code": "123456",
"expiry_minutes": "10"
}
}'

Response:

{
"success": true,
"trigger_id": "550e8400-e29b-41d4-a716-446655440000",
"job_id": "123",
"message": "WhatsApp message queued successfully"
}

Use Cases:

  • OTP verification
  • 2FA authentication
  • Account verification
  • Password reset codes

2. Send Order Confirmation to Contact

Send to a specific contact using their external ID:

curl -X POST https://api.sendmator.com/api/v1/whatsapp/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "order_confirmation",
"recipient_type": "contact",
"contact_external_id": "user-123",
"conversation_category": "UTILITY",
"variables": {
"order_id": "ORD-12345",
"total_amount": "$99.99",
"delivery_date": "March 20, 2026"
}
}'

Response:

{
"success": true,
"trigger_id": "abc123-def456-ghi789",
"job_id": "124",
"message": "WhatsApp message queued successfully"
}

Use Cases:

  • Order confirmations
  • Shipping updates
  • Appointment reminders
  • Account notifications

Auto-populated Variables: When sending to a contact, their data is automatically available:

  • {{contact_first_name}} - Contact's first name
  • {{contact_last_name}} - Contact's last name
  • {{contact_phone}} - Contact's WhatsApp number
  • {{contact_external_id}} - Contact's external ID

3. Send Promotional Message to Tagged Contacts

Send marketing messages to specific customer segments:

curl -X POST https://api.sendmator.com/api/v1/whatsapp/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "flash_sale",
"recipient_type": "tag",
"tag": ["premium", "vip"],
"conversation_category": "MARKETING",
"campaign_name": "Spring Sale 2026",
"variables": {
"discount_percentage": "40",
"sale_end_date": "March 31"
}
}'

Response:

{
"success": true,
"trigger_id": "pqr901-stu234-vwx567",
"job_id": "125",
"message": "WhatsApp message queued successfully"
}

Use Cases:

  • Flash sales
  • Product launches
  • Event invitations
  • VIP promotions

4. Scheduled WhatsApp Message

Schedule a WhatsApp message for future delivery:

curl -X POST https://api.sendmator.com/api/v1/whatsapp/send \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_key": "appointment_reminder",
"recipient_type": "contact",
"contact_external_id": "user-123",
"conversation_category": "UTILITY",
"variables": {
"appointment_date": "March 20, 2026",
"appointment_time": "2:00 PM",
"doctor_name": "Dr. Smith"
},
"triggerAt": "2026-03-19T14:00:00Z"
}'

Response:

{
"success": true,
"trigger_id": "lmn012-opq345-rst678",
"job_id": "126",
"message": "WhatsApp message scheduled successfully",
"scheduled_for": "2026-03-19T14:00:00Z",
"delay_ms": 86400000
}

Use Cases:

  • Appointment reminders
  • Event notifications
  • Scheduled announcements
  • Time-zone specific sends

Response Format

Success Response (201 Created)

{
"success": true,
"trigger_id": "550e8400-e29b-41d4-a716-446655440000",
"job_id": "123",
"message": "WhatsApp message queued successfully"
}
FieldTypeDescription
successbooleanAlways true for successful requests
trigger_idstringUnique ID to track this send operation
job_idstringJob queue ID for monitoring
messagestringHuman-readable status message

Error Responses

Template Not Approved (400)

{
"statusCode": 400,
"message": "WhatsApp template 'order_confirmation' is not approved by Meta",
"error": "Bad Request"
}

Invalid Conversation Category (400)

{
"statusCode": 400,
"message": "conversation_category must be one of: MARKETING, UTILITY, AUTHENTICATION",
"error": "Bad Request"
}

Contact Not Found (404)

{
"statusCode": 404,
"message": "Contact with external_id 'user-123' not found",
"error": "Not Found"
}

Insufficient Balance (400)

{
"statusCode": 400,
"message": "Insufficient wallet balance. Required: 15.00 USD, Available: 5.00 USD. Please recharge your wallet to continue.",
"error": "Bad Request"
}

WhatsApp Templates

All WhatsApp messages must use Meta-approved templates. You cannot send free-form text messages.

Template Requirements

  1. Meta Approval: All templates must be submitted to and approved by Meta
  2. Template Structure: Fixed structure with variable placeholders
  3. Language: Templates must be created for each language
  4. Categories: Must match the conversation category (MARKETING, UTILITY, AUTHENTICATION)

Template Variables

Use placeholders in your templates:

Hello {{1}}, your order {{2}} has been confirmed. Delivery by {{3}}.

Then pass variables in order:

{
"variables": {
"1": "John",
"2": "#12345",
"3": "March 20"
}
}

Media Support

WhatsApp templates can include:

  • Images: Header images for rich messaging
  • Videos: Product demos or announcements
  • Documents: PDFs, receipts, invoices
  • Buttons: Call-to-action buttons (URL, Quick Reply, Phone Number)

24-Hour Window Rule

WhatsApp enforces a 24-hour messaging window:

  • Within 24 hours: You can send any approved template
  • After 24 hours: Only template messages (with conversation category charges)
  • User-initiated: Clock resets when user sends a message to you

Best Practice: Use utility templates for follow-ups within the 24-hour window to avoid marketing conversation charges.


Pricing

WhatsApp pricing varies by conversation category and region:

CategoryRegionApproximate Price
AuthenticationUSA~$0.005/conversation
UtilityUSA~$0.01/conversation
MarketingUSA~$0.03/conversation
AuthenticationIndia~$0.0025/conversation
UtilityIndia~$0.004/conversation
MarketingIndia~$0.01/conversation

Note:

  • Conversations are 24-hour windows, not per-message
  • Multiple messages within 24 hours = 1 conversation charge
  • Different categories = different conversations

Best Practices

1. Choose the Right Category

# ✅ Good: Authentication for OTPs
{
"conversation_category": "AUTHENTICATION",
"template_key": "otp_verification"
}

# ✅ Good: Utility for transactional updates
{
"conversation_category": "UTILITY",
"template_key": "order_shipped"
}

# ⚠️ Marketing costs more - use sparingly
{
"conversation_category": "MARKETING",
"template_key": "promotional_offer"
}

2. Get Templates Pre-Approved

Before going live:

  1. Create templates in Sendmator dashboard
  2. Submit to Meta for review
  3. Wait for approval (usually 24-48 hours)
  4. Test with approved templates only

3. Respect Opt-In Requirements

MARKETING category requires explicit opt-in:

  • User must have opted in to marketing messages
  • Sendmator automatically filters non-opted-in contacts
  • UTILITY and AUTHENTICATION have more lenient rules

4. Use Variables Effectively

# ✅ Good: Clear variable names in order
{
"variables": {
"1": "John",
"2": "#12345",
"3": "March 20"
}
}

# ❌ Avoid: Out of order or missing variables
{
"variables": {
"3": "March 20",
"1": "John"
// Missing variable 2!
}
}

5. Test Before Broadcasting

# Step 1: Test with yourself
{
"recipient_type": "direct_whatsapp",
"direct_whatsapp": "+your-number"
}

# Step 2: Test with small group
{
"recipient_type": "tag",
"tag": ["internal-team"]
}

# Step 3: Send to everyone
{
"recipient_type": "all"
}

Multi-Channel Messages

To send messages across multiple channels (Email, SMS, WhatsApp, Push) simultaneously, use the Multi-Channel Trigger API instead of /whatsapp/send.


Next Steps