Send Message
const url = 'https://api.contacta.mx/wab';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"type":"template","agent":"5215589427963","number":"525510101234","templateName":"ejemplo_nota_1","language":"es","templateData":{"body":{"placeholders":["2024-01-01","John Doe","My Business","$ 1500"]},"header":{"type":"DOCUMENT","mediaUrl":"https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf","filename":"document.pdf"}}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.contacta.mx/wab \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "type": "template", "agent": "5215589427963", "number": "525510101234", "templateName": "ejemplo_nota_1", "language": "es", "templateData": { "body": { "placeholders": [ "2024-01-01", "John Doe", "My Business", "$ 1500" ] }, "header": { "type": "DOCUMENT", "mediaUrl": "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf", "filename": "document.pdf" } } }'Sends a WhatsApp message to a recipient number through the specified agent.
The type field in the request body determines the message variant.
See the request body examples for all supported types.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Message payload. The type field determines which additional fields are required.
type |
Required fields |
|---|---|
template |
templateName, templateData, language |
text |
message |
image |
url — caption optional |
file |
url, filename |
audio |
url |
video |
url |
location |
longitude, latitude — name, address optional |
sticker |
url |
contacts |
contact |
Send a pre-approved WhatsApp template message.
Templates must be approved by Meta before use. Use templateData to fill in
the dynamic placeholders defined in your template.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Template language code
Exact name of the approved template
object
object
Values to fill in the body {{1}}, {{2}}, … variables in order
Required when the template header contains a media or document component
object
Header media type
Publicly accessible URL of the header media
File name displayed to the recipient (required when type is DOCUMENT)
Values for header text variables (max 1 item for text headers)
Send a plain text message.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Text content of the message
Send an image with an optional caption.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Publicly accessible URL of the image (JPG, PNG, WebP)
Optional caption displayed below the image
Send a document or file attachment (PDF, DOCX, etc.).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Publicly accessible URL of the file
File name displayed to the recipient
Send an audio file (MP3, OGG, etc.).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Publicly accessible URL of the audio file
Send a video file (MP4).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Publicly accessible URL of the video file (MP4)
Send a location pin with name and address.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Longitude coordinate
Latitude coordinate
Location name displayed to the recipient
Address displayed below the location name
Send a sticker (WebP format).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
Publicly accessible URL of the sticker file (WebP)
Send a contact card with name, phones, emails, addresses, and more.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
Destination WhatsApp phone number (E.164 without +)
Message type — determines which additional fields are required
object
object
Full display name shown on the contact card
object
WhatsApp ID if this phone is registered on WhatsApp
object
object
Birthday in YYYY-MM-DD format
object
object
Examples
Template with document header
{ "type": "template", "agent": "5215589427963", "number": "525510101234", "templateName": "ejemplo_nota_1", "language": "es", "templateData": { "body": { "placeholders": [ "2024-01-01", "John Doe", "My Business", "$ 1500" ] }, "header": { "type": "DOCUMENT", "mediaUrl": "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf", "filename": "document.pdf" } }}Text message
{ "type": "text", "agent": "5215628341366", "number": "525510101234", "message": "Hola, este es un mensaje de prueba."}Image with caption
{ "type": "image", "agent": "5215628341366", "number": "525510101234", "url": "https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample01.jpg", "caption": "Sample image"}PDF file
{ "type": "file", "agent": "5215628341366", "number": "525510101234", "url": "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf", "filename": "sample01.pdf"}Audio file
{ "type": "audio", "agent": "5215628341366", "number": "525510101234", "url": "https://www.buildquickbots.com/whatsapp/media/sample/audio/sample02.mp3"}Video file
{ "type": "video", "agent": "5215628341366", "number": "525510101234", "url": "https://www.buildquickbots.com/whatsapp/media/sample/video/sample01.mp4"}Location pin
{ "type": "location", "agent": "5215628341366", "number": "525510101234", "longitude": 72.877655, "latitude": 19.075983, "name": "Mumbai", "address": "Mumbai, Maharashtra"}Sticker
{ "type": "sticker", "agent": "5215628341366", "number": "525510101234", "url": "http://www.buildquickbots.com/whatsapp/stickers/SampleSticker01.webp"}Contact card
{ "type": "contacts", "agent": "5215628341366", "number": "525510101234", "contact": { "name": { "first_name": "John", "last_name": "Wick", "formatted_name": "John Wick" }, "phones": [ { "phone": "+1 (650) 555-1234", "type": "WORK", "wa_id": "16505551234" } ], "emails": [ { "email": "john@example.com", "type": "WORK" } ], "org": { "company": "Acme Corp", "title": "Manager" } }}Responses
Section titled “Responses”Message successfully enqueued
object
Example
{ "error": false, "code": 200, "message": "Message enqueued successfully"}Agent field must be specified
object
HTTP-style error code returned by the API
Human-readable error description
Example
{ "error": true, "code": 304, "message": "Agent field must be specified to send WAB message"}Number field must be specified
object
HTTP-style error code returned by the API
Human-readable error description
Example
{ "error": true, "code": 305, "message": "Number field must be specified to send WAB message"}Phone number must be in E.164 format
object
HTTP-style error code returned by the API
Human-readable error description
Example
{ "error": true, "code": 306, "message": "Please use number in E.164 format"}Type field must be specified
object
HTTP-style error code returned by the API
Human-readable error description
Example
{ "error": true, "code": 307, "message": "Type field must be specified to send WAB message"}Agent or user are invalid
object
HTTP-style error code returned by the API
Human-readable error description
Example
{ "error": true, "code": 400, "message": "Agent or User are invalid"}WhatsApp agent not found or invalid
object
HTTP-style error code returned by the API
Human-readable error description
Example
{ "error": true, "code": 404, "message": "Whatsapp agent isn't valid or not found"}Internal error enqueuing message
object
HTTP-style error code returned by the API
Human-readable error description
Example
{ "error": true, "code": 500, "message": "Error enqueuing message"}
