PlatformXeDocs
Get API Key

Send WhatsApp

API reference for sending WhatsApp template and session messages.

Send a WhatsApp message through the PlatformXe multi-provider fallback chain. Supports both pre-approved template messages and free-form session messages.

Endpoint

POST /api/v1/messaging/whatsapp

Scope: messaging:send

Request body

FieldTypeRequiredDescription
tostringYesRecipient phone number in E.164 format (e.g. +2348012345678)
templateIdstringConditionalTemplate identifier for template messages. Required if message is not provided
templateVariablesRecord<string, string>NoKey-value pairs for template placeholder substitution
messagestringConditionalFree-form message body for session messages. Required if templateId is not provided
phoneNumberIdstringYesThe WhatsApp Business phone number ID to send from

Session messages (using message instead of templateId) can only be sent within a 24-hour window after the recipient last messaged your WhatsApp Business number. Outside this window, you must use a template message.

Response

{
  "success": true,
  "data": {
    "messageId": "wa_abc123def456",
    "provider": "primary",
    "status": "sent",
    "sessionActive": true
  }
}
FieldTypeDescription
messageIdstringUnique message identifier for tracking
providerstringWhich provider in the fallback chain handled delivery
statusstringsent (dispatched) or queued (accepted for retry)
sessionActivebooleanWhether a 24-hour session window is currently active with the recipient

Examples

curl (template message)

curl -X POST https://api.platformxe.com/api/v1/messaging/whatsapp \
  -H "Content-Type: application/json" \
  -H "x-api-key: pxk_live_your_api_key_here" \
  -d '{
    "to": "+2348012345678",
    "templateId": "order_confirmation_v2",
    "templateVariables": {
      "customerName": "Adaeze",
      "orderId": "ORD-12345",
      "total": "15,000"
    },
    "phoneNumberId": "pn_wa_001"
  }'

curl (session message)

curl -X POST https://api.platformxe.com/api/v1/messaging/whatsapp \
  -H "Content-Type: application/json" \
  -H "x-api-key: pxk_live_your_api_key_here" \
  -d '{
    "to": "+2348012345678",
    "message": "Thanks for reaching out! Your support ticket #4567 has been assigned to an agent.",
    "phoneNumberId": "pn_wa_001"
  }'

SDK (template message)

import { PlatformXe } from '@caldera/platformxe-sdk';

const px = new PlatformXe({ apiKey: 'pxk_live_your_api_key_here' });

const result = await px.whatsapp.send({
  to: '+2348012345678',
  templateId: 'order_confirmation_v2',
  templateVariables: {
    customerName: 'Adaeze',
    orderId: 'ORD-12345',
    total: '15,000',
  },
  phoneNumberId: 'pn_wa_001',
});

console.log(result.data.messageId);
// "wa_abc123def456"

SDK (session message)

const result = await px.whatsapp.send({
  to: '+2348012345678',
  message: 'Thanks for reaching out! Your support ticket #4567 has been assigned to an agent.',
  phoneNumberId: 'pn_wa_001',
});

console.log(result.data.sessionActive);
// true

Use template messages for initial outreach and notifications. Session messages are best suited for follow-up replies within an active conversation.

Error responses

CodeDescription
BAD_REQUESTMissing required fields, or both templateId and message provided
SESSION_EXPIREDAttempted to send a session message outside the 24-hour window
TEMPLATE_NOT_FOUNDThe specified templateId does not exist or is not approved
FORBIDDENAPI key does not have the messaging:send scope
RATE_LIMITEDRate limit exceeded for this API key
PROVIDER_ERRORAll providers in the fallback chain failed