Skip to content

Send Message

POST
/wab
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.

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
Media typeapplication/json
One of: discriminator: type
Template

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
agent
required

WhatsApp Business phone number of the sending agent (E.164 without +)

string
number
required

Destination WhatsApp phone number (E.164 without +)

string
type
required

Message type — determines which additional fields are required

string
Allowed values: template text image file audio video location sticker contacts
type
required
string
Allowed values: template
language
required

Template language code

string
Allowed values: en es fr de it pt
templateName
required

Exact name of the approved template

string
templateData
required
object
body
object
placeholders

Values to fill in the body {{1}}, {{2}}, … variables in order

Array<string>
header

Required when the template header contains a media or document component

object
type

Header media type

string
Allowed values: IMAGE VIDEO DOCUMENT
mediaUrl

Publicly accessible URL of the header media

string format: uri
filename

File name displayed to the recipient (required when type is DOCUMENT)

string
placeholders

Values for header text variables (max 1 item for text headers)

Array<string>
<= 1 items
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"
}
}
}

Message successfully enqueued

Media typeapplication/json
object
error
boolean
code
integer
message
string
Example
{
"error": false,
"code": 200,
"message": "Message enqueued successfully"
}

Agent field must be specified

Media typeapplication/json
object
error
boolean
code

HTTP-style error code returned by the API

integer
message

Human-readable error description

string
Example
{
"error": true,
"code": 304,
"message": "Agent field must be specified to send WAB message"
}

Number field must be specified

Media typeapplication/json
object
error
boolean
code

HTTP-style error code returned by the API

integer
message

Human-readable error description

string
Example
{
"error": true,
"code": 305,
"message": "Number field must be specified to send WAB message"
}

Phone number must be in E.164 format

Media typeapplication/json
object
error
boolean
code

HTTP-style error code returned by the API

integer
message

Human-readable error description

string
Example
{
"error": true,
"code": 306,
"message": "Please use number in E.164 format"
}

Type field must be specified

Media typeapplication/json
object
error
boolean
code

HTTP-style error code returned by the API

integer
message

Human-readable error description

string
Example
{
"error": true,
"code": 307,
"message": "Type field must be specified to send WAB message"
}

Agent or user are invalid

Media typeapplication/json
object
error
boolean
code

HTTP-style error code returned by the API

integer
message

Human-readable error description

string
Example
{
"error": true,
"code": 400,
"message": "Agent or User are invalid"
}

WhatsApp agent not found or invalid

Media typeapplication/json
object
error
boolean
code

HTTP-style error code returned by the API

integer
message

Human-readable error description

string
Example
{
"error": true,
"code": 404,
"message": "Whatsapp agent isn't valid or not found"
}

Internal error enqueuing message

Media typeapplication/json
object
error
boolean
code

HTTP-style error code returned by the API

integer
message

Human-readable error description

string
Example
{
"error": true,
"code": 500,
"message": "Error enqueuing message"
}