Send Message
POST /wab
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 Body required
Section titled “Request Body required ”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 +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Template language code
esExact name of the approved template
ejemplo_nota_1object
object
Values to fill in the body {{1}}, {{2}}, … variables in order
[ "2024-01-01", "John Doe", "$ 1500"]Required when the template header contains a media or document component
object
Header media type
DOCUMENTPublicly accessible URL of the header media
https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdfFile name displayed to the recipient (required when type is DOCUMENT)
document.pdfValues for header text variables (max 1 item for text headers)
[ "John Doe"]Send a plain text message.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Text content of the message
This is a text message sent via WhatsApp Business API.Send an image with an optional caption.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Publicly accessible URL of the image (JPG, PNG, WebP)
https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample01.jpgOptional caption displayed below the image
Sample imageSend a document or file attachment (PDF, DOCX, etc.).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Publicly accessible URL of the file
https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdfFile name displayed to the recipient
sample01.pdfSend an audio file (MP3, OGG, etc.).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Publicly accessible URL of the audio file
https://www.buildquickbots.com/whatsapp/media/sample/audio/sample02.mp3Send a video file (MP4).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Publicly accessible URL of the video file (MP4)
https://www.buildquickbots.com/whatsapp/media/sample/video/sample01.mp4Send a location pin with name and address.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Longitude coordinate
72.877655Latitude coordinate
19.075983Location name displayed to the recipient
MumbaiAddress displayed below the location name
Mumbai, MaharashtraSend a sticker (WebP format).
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
Publicly accessible URL of the sticker file (WebP)
http://www.buildquickbots.com/whatsapp/stickers/SampleSticker01.webpSend a contact card with name, phones, emails, addresses, and more.
object
WhatsApp Business phone number of the sending agent (E.164 without +)
5215628341366Destination WhatsApp phone number (E.164 without +)
525510101234Message type — determines which additional fields are required
object
object
JohnWickFull display name shown on the contact card
John Wickobject
+1 (650) 555-1234WORKWhatsApp ID if this phone is registered on WhatsApp
16505551234object
john@example.comWORKobject
1 Hacker WayMenlo ParkCA94025United StatesusWORKBirthday in YYYY-MM-DD format
1995-08-18object
Acme CorpProductManagerobject
https://www.example.comWORKExamples
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
200Message enqueued successfullyExample
{ "error": false, "code": 200, "message": "Message enqueued successfully"}Agent field must be specified
object
trueHTTP-style error code returned by the API
400Human-readable error description
Agent or User are invalidExample
{ "error": true, "code": 304, "message": "Agent field must be specified to send WAB message"}Number field must be specified
object
trueHTTP-style error code returned by the API
400Human-readable error description
Agent or User are invalidExample
{ "error": true, "code": 305, "message": "Number field must be specified to send WAB message"}Phone number must be in E.164 format
object
trueHTTP-style error code returned by the API
400Human-readable error description
Agent or User are invalidExample
{ "error": true, "code": 306, "message": "Please use number in E.164 format"}Type field must be specified
object
trueHTTP-style error code returned by the API
400Human-readable error description
Agent or User are invalidExample
{ "error": true, "code": 307, "message": "Type field must be specified to send WAB message"}Agent or user are invalid
object
trueHTTP-style error code returned by the API
400Human-readable error description
Agent or User are invalidExample
{ "error": true, "code": 400, "message": "Agent or User are invalid"}WhatsApp agent not found or invalid
object
trueHTTP-style error code returned by the API
400Human-readable error description
Agent or User are invalidExample
{ "error": true, "code": 404, "message": "Whatsapp agent isn't valid or not found"}Internal error enqueuing message
object
trueHTTP-style error code returned by the API
400Human-readable error description
Agent or User are invalidExample
{ "error": true, "code": 500, "message": "Error enqueuing message"}Examples
Section titled “Examples ”Useful for guiding users to view code examples in different developer languages.
curl -X POST "https://api.example.com/wab" \ -H "Accept: application/json" \ -H "Connection: keep-alive" \ -H "Content-Type: application/json" \ -H "Authorization: Basic <base64-encoded-credentials>" \ -d '{}' const fetch = require('node-fetch');
fetch("https://api.example.com/wab", { method: "POST", headers: { "Accept": "application/json", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <base64-encoded-credentials>"}, body: JSON.stringify({}) }) .then(res => res.json()) .then(console.log) .catch(console.error); <?php $curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => "https://api.example.com/wab", CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_HTTPHEADER => [ "Accept: application/json", "Connection: keep-alive", "Content-Type: application/json", "Authorization: Basic <base64-encoded-credentials>" ], CURLOPT_POSTFIELDS => json_encode({}) ]);
$response = curl_exec($curl); curl_close($curl); echo $response; ?> using System.Net.Http; using System.Text; using System.Threading.Tasks;
var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.POST, "https://api.example.com/wab") { Content = new StringContent("{}", Encoding.UTF8, "application/json") }; request.Headers.Add("Accept", "application/json");request.Headers.Add("Connection", "keep-alive");request.Headers.Add("Content-Type", "application/json");request.Headers.Add("Authorization", "Basic <base64-encoded-credentials>"); var response = await client.SendAsync(request); var responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); import requests import json
url = "https://api.example.com/wab" headers = { "Accept": "application/json", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <base64-encoded-credentials>" } data = {}
response = requests.post(url, headers=headers, json=data) print(response.text) import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets;
public class ApiExample { public static void main(String[] args) throws Exception { URL url = new URL("https://api.example.com/wab"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Accept", "application/json"); conn.setRequestProperty("Connection", "keep-alive"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "Basic <base64-encoded-credentials>");
String jsonInputString = "{}"; try(OutputStream os = conn.getOutputStream()) { byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8); os.write(input, 0, input.length); }
int code = conn.getResponseCode(); System.out.println("Response code: " + code); } }