Skip to main content
POST
/
send-whatsapp-message
curl -X POST "https://api.magpipe.ai/functions/v1/send-whatsapp-message" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number_id": "1026733600525693",
    "recipient_wa_id": "14155551234",
    "message": "Hi! Your appointment is confirmed for tomorrow at 2pm."
  }'
{
  "success": true,
  "message_id": "wamid.HBgNMTQxNTU1NTEyMzQVAgARGBI...",
  "stored": {
    "id": "msg_a1b2c3d4-5678-9012-3456-789012345678",
    "content": "Hi! Your appointment is confirmed for tomorrow at 2pm.",
    "direction": "outbound",
    "status": "sent",
    "channel": "whatsapp",
    "sent_at": "2024-01-15T10:30:00.000Z"
  }
}

Overview

Sends a WhatsApp text message to a recipient using one of your connected WhatsApp Business numbers. The number must be connected via the Magpipe dashboard before it can be used.
WhatsApp enforces a 24-hour messaging window. You can only send free-form messages within 24 hours of the recipient’s last message to you. Attempts to message outside this window will be rejected by Meta.

Request

Headers

Authorization
string
required
Bearer token for authentication.
Content-Type
string
required
Must be application/json

Body Parameters

phone_number_id
string
required
The Meta phone number ID for your WhatsApp Business number. Found in the Meta Business Manager or in the Magpipe Deploy tab after connecting.Example: "1026733600525693"
recipient_wa_id
string
required
The recipient’s WhatsApp ID — their phone number in international format without the + prefix.Example: "14155551234"
message
string
required
The text message content.Example: "Hi! Your appointment is confirmed for tomorrow at 2pm."

Response

success
boolean
Whether the message was sent successfully.
message_id
string
The WhatsApp message ID returned by Meta.
stored
object
The stored message record from Magpipe.

Example Request

curl -X POST "https://api.magpipe.ai/functions/v1/send-whatsapp-message" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number_id": "1026733600525693",
    "recipient_wa_id": "14155551234",
    "message": "Hi! Your appointment is confirmed for tomorrow at 2pm."
  }'

Example Response

{
  "success": true,
  "message_id": "wamid.HBgNMTQxNTU1NTEyMzQVAgARGBI...",
  "stored": {
    "id": "msg_a1b2c3d4-5678-9012-3456-789012345678",
    "content": "Hi! Your appointment is confirmed for tomorrow at 2pm.",
    "direction": "outbound",
    "status": "sent",
    "channel": "whatsapp",
    "sent_at": "2024-01-15T10:30:00.000Z"
  }
}

Error Responses

{
  "error": "phone_number_id, recipient_wa_id, and message are required"
}
{
  "error": "Unauthorized"
}
{
  "error": "WhatsApp account not found"
}
{
  "error": "Failed to send WhatsApp message",
  "detail": "Meta API error details"
}