Skip to main content

Send Text Message

Send a text message to a specific phone number. Creates a new conversation if one doesn’t exist.
curl -X POST https://your-api.com/api/whatsapp/send \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "phoneNumber": "+50212345678",
    "content": "Hello! Your service request has been received.",
    "requestId": 123
  }'

Request Body

phoneNumber
string
required
Recipient’s phone number in international format (e.g., +50212345678)
content
string
required
Message text content
requestId
integer
Optional service request ID to link the conversation

Response

success
boolean
Indicates if the message was sent successfully
data
object
Message and conversation details
data.message
object
Saved message object
data.conversation
object
Conversation object
Response Example
{
  "success": true,
  "data": {
    "message": {
      "message_id": 456,
      "conversation_id": 123,
      "content": "Hello! Your service request has been received.",
      "message_type": "text",
      "direction": "outbound",
      "status": "sent",
      "created_at": "2026-03-03T10:30:00Z"
    },
    "conversation": {
      "conversation_id": 123,
      "phone_number": "50212345678",
      "request_id": 123
    }
  }
}

Send Message in Conversation

Send a message within an existing conversation.
curl -X POST https://your-api.com/api/whatsapp/conversations/123/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "content": "Thank you for your patience. A technician will contact you shortly."
  }'

Path Parameters

conversationId
integer
required
ID of the conversation

Request Body

content
string
required
Message text content
messageType
string
default:"text"
Type of message (currently only text is supported)

Response

{
  "success": true,
  "data": {
    "message_id": 457,
    "conversation_id": 123,
    "content": "Thank you for your patience. A technician will contact you shortly.",
    "status": "sent"
  }
}

Send Template Message

Send pre-approved WhatsApp template messages to one or multiple recipients.
curl -X POST https://your-api.com/api/whatsapp/send-template \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "templateName": "appointment_reminder",
    "languageCode": "es",
    "components": [
      {
        "type": "body",
        "parameters": [
          {"type": "text", "text": "Juan Pérez"},
          {"type": "text", "text": "15 de marzo a las 10:00 AM"}
        ]
      }
    ],
    "recipients": [
      {"phoneNumber": "+50212345678", "requestId": 123},
      {"phoneNumber": "+50298765432", "requestId": 124}
    ]
  }'

Request Body

templateName
string
required
Name of the approved template (must exist in Meta Business Manager)
languageCode
string
default:"es"
Language code (e.g., es, en, es_MX)
components
array
Template components with parameters
components[].type
string
Component type: header, body, or button
components[].parameters
array
Array of parameter objects with type and text fields
recipients
array
required
Array of recipient objects (minimum 1)
recipients[].phoneNumber
string
required
Phone number in international format
recipients[].requestId
integer
Optional service request ID

Response

success
boolean
Always true if the request was processed
summary
object
Summary of send results
summary.total
integer
Total recipients
summary.sent
integer
Successfully sent count
summary.failed
integer
Failed count
results
array
Individual results for each recipient
Response Example
{
  "success": true,
  "summary": {
    "total": 2,
    "sent": 2,
    "failed": 0
  },
  "results": [
    {
      "phoneNumber": "+50212345678",
      "success": true,
      "data": {
        "messages": [
          {"id": "wamid.HBgNNTA2MTI..."}
        ]
      }
    },
    {
      "phoneNumber": "+50298765432",
      "success": true,
      "data": {
        "messages": [
          {"id": "wamid.HBgNNTA2OTg..."}
        ]
      }
    }
  ]
}

Get Templates

Fetch all approved WhatsApp templates from Meta Cloud API and sync with database.
curl -X GET https://your-api.com/api/whatsapp/templates \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

{
  "success": true,
  "data": [
    {
      "name": "appointment_reminder",
      "status": "APPROVED",
      "category": "UTILITY",
      "language": "es",
      "components": [
        {
          "type": "BODY",
          "text": "Hola {{1}}, te recordamos tu cita para el {{2}}."
        },
        {
          "type": "FOOTER",
          "text": "Ambiotec - Servicios Profesionales"
        }
      ]
    }
  ]
}
Templates must be created and approved in Meta Business Manager before they can be used. The approval process can take 24-48 hours.

Template Components Example

Template with Header, Body, and Button
{
  "templateName": "service_confirmation",
  "languageCode": "es",
  "components": [
    {
      "type": "header",
      "parameters": [
        {"type": "text", "text": "Confirmación de Servicio"}
      ]
    },
    {
      "type": "body",
      "parameters": [
        {"type": "text", "text": "Juan Pérez"},
        {"type": "text", "text": "SR-2024-001"},
        {"type": "text", "text": "15 de marzo, 10:00 AM"}
      ]
    },
    {
      "type": "button",
      "sub_type": "url",
      "index": "0",
      "parameters": [
        {"type": "text", "text": "tracking-code-123"}
      ]
    }
  ]
}

Build docs developers (and LLMs) love