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
Recipient’s phone number in international format (e.g., +50212345678)
Optional service request ID to link the conversation
Response
Indicates if the message was sent successfully
Message and conversation details
{
"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
Request Body
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
Name of the approved template (must exist in Meta Business Manager)
Language code (e.g., es, en, es_MX)
Template components with parametersComponent type: header, body, or button
Array of parameter objects with type and text fields
Array of recipient objects (minimum 1)Phone number in international format
Optional service request ID
Response
Always true if the request was processed
Individual results for each recipient
{
"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"}
]
}
]
}