Updated on November 24, 2026
Every send through the WhatsApp Business API is a JSON POST to a single messages endpoint: on the Meta Cloud API, https://graph.facebook.com/v27.0/<PHONE_NUMBER_ID>/messages; on Vectalk, https://apis.vectalk.com.br/api/messages. The only thing that changes between text, template, image, document or buttons is the type field and the object with the same name. Below you will find ready-to-copy curl commands, along with the limits of each type.
This is a cheat sheet for the terminal. If you prefer a graphical interface, see how to test the API in Postman; for the same sends in Node.js and Python, see sending examples in cURL, Node.js and Python.
Setup: environment variables
Set the variables once and every command below works without edits.
# Direct Cloud API (Meta)
export WA_URL="https://graph.facebook.com/v27.0/YOUR_PHONE_NUMBER_ID"
export WA_TOKEN="your_system_user_token"
export TO="5511999999999"
# Or Vectalk (same payloads)
# export WA_URL="https://apis.vectalk.com.br/api"
# export WA_TOKEN="your_vectalk_token"
With these variables, the send endpoint is $WA_URL/messages in both cases. Version v27.0 is the one used in the current examples on Meta’s send messages page. The temporary token from the dashboard expires quickly; for ongoing use, generate a permanent token with a system user.
About the recipient number: Meta accepts the number with + and the country code, and recommends including them. The Vectalk documentation describes the to field in E.164 format without the + (for example, 5511999999999). Using digits only, with the country code, works on both.
Plain text
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "text",
"text": { "body": "Hi! Your order is out for delivery." }
}'
The body accepts up to 4,096 characters, according to Meta’s text messages page. Free-form text can only be sent inside the 24-hour window opened by the customer’s last message; outside it, Meta returns error 131047 and you need a template.
The '"$TO"' trick closes the single quote, inserts the variable and reopens the quote. If you prefer, save the JSON to a file and use -d @mensagem.json.
Text with link preview
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "text",
"text": {
"preview_url": true,
"body": "Track your order: https://exemplo.com.br/pedido/123"
}
}'
With preview_url: true, WhatsApp shows a preview of the first URL in the text.
Reply quoting a message
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"context": { "message_id": "wamid.HBgLNTUxMTk5OTk5OTk5ORUCABIYFjNFQjA..." },
"type": "text",
"text": { "body": "About this message: we have already sorted it out." }
}'
context.message_id is the wamid of the message you want to quote. Details and limitations in how to reply to a specific message.
Want to try it while you read? Create a Vectalk account and send your first message through the official API. Create free account →
Template
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "template",
"template": {
"name": "confirmacao_pedido",
"language": { "code": "pt_BR" },
"components": [{
"type": "body",
"parameters": [
{ "type": "text", "text": "Maria" },
{ "type": "text", "text": "#4821" }
]
}]
}
}'
The template must be approved and exist in the language you specify; otherwise Meta returns 132001. If the number of parameters does not match the template variables, the error is 132000. Both are in Meta’s error code list. The structure of the template object follows the templates overview.
Template with an image header and a dynamic URL button
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "template",
"template": {
"name": "pedido_enviado",
"language": { "code": "pt_BR" },
"components": [
{
"type": "header",
"parameters": [
{ "type": "image", "image": { "link": "https://exemplo.com.br/banner.jpg" } }
]
},
{
"type": "body",
"parameters": [{ "type": "text", "text": "Maria" }]
},
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [{ "type": "text", "text": "4821" }]
}
]
}
}'
In the URL button, the parameter is only the variable suffix of the URL registered in the template. index is the button position, as a string. More details in template with a dynamic URL button.
Media
Image by link
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "image",
"image": {
"link": "https://exemplo.com.br/produto.jpg",
"caption": "Your product has been set aside for you."
}
}'
Meta’s image messages page accepts JPEG, PNG and static WebP up to 5 MB, with a caption of up to 1,024 characters. It also advises against sending by link and recommends uploading the media first and sending it by id.
Media upload and sending by id
On the Meta Cloud API, the MIME type goes along with the file field:
curl -sS -X POST "$WA_URL/media" \
-H "Authorization: Bearer $WA_TOKEN" \
-F "messaging_product=whatsapp" \
-F "file=@produto.jpg;type=image/jpeg"
# response: {"id":"1037543291543636"}
On Vectalk, the type goes in a separate type field, and the upload requires an instance token:
curl -sS -X POST "https://apis.vectalk.com.br/api/media" \
-H "Authorization: Bearer $WA_TOKEN" \
-F "file=@produto.jpg" \
-F "type=image/jpeg" \
-F "messaging_product=whatsapp"
Then send it with the id:
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "image",
"image": { "id": "1037543291543636", "caption": "Your product has been set aside for you." }
}'
According to Meta’s media page, media IDs obtained by upload are valid for 30 days. For recurring sends, upload once and reuse the id within that period.
Document with a file name
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "document",
"document": {
"link": "https://exemplo.com.br/boletos/4821.pdf",
"filename": "boleto-pedido-4821.pdf",
"caption": "Here is the payment slip for order #4821."
}
}'
filename (with extension) is the name the customer sees. Documents can be up to 100 MB. (A boleto is a Brazilian bank payment slip, a common way to pay for orders in Brazil.) The full guide is in how to send PDFs and documents.
Audio and video
# audio
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"messaging_product":"whatsapp","to":"'"$TO"'","type":"audio","audio":{"id":"AUDIO_ID"}}'
# video
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"messaging_product":"whatsapp","to":"'"$TO"'","type":"video","video":{"id":"VIDEO_ID","caption":"See how to assemble it."}}'
Audio and video can be up to 16 MB; video in MP4 or 3GP, with H.264 and AAC.
Reply buttons
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "interactive",
"interactive": {
"type": "button",
"body": { "text": "Can you confirm your appointment tomorrow at 2 PM?" },
"footer": { "text": "Example Clinic" },
"action": {
"buttons": [
{ "type": "reply", "reply": { "id": "confirmar", "title": "Confirm" } },
{ "type": "reply", "reply": { "id": "remarcar", "title": "Reschedule" } }
]
}
}
}'
Up to 3 buttons, titles of up to 20 characters, a body of up to 1,024 and a footer of up to 60, according to Meta’s reply buttons page. When the customer taps one, the webhook arrives with interactive.button_reply.id, which you use to decide the next step.
List
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "'"$TO"'",
"type": "interactive",
"interactive": {
"type": "list",
"body": { "text": "Choose the topic of your request:" },
"action": {
"button": "See options",
"sections": [{
"title": "Orders",
"rows": [
{ "id": "rastreio", "title": "Track order" },
{ "id": "troca", "title": "Exchange or return", "description": "Up to 7 days after delivery" }
]
}]
}
}
}'
The limits are on Meta’s list messages page: up to 10 sections and up to 10 rows across all of them, button text of up to 20 characters, row titles of up to 24 and descriptions of up to 72. The customer’s reply arrives in interactive.list_reply.id. Other interactive formats are covered in interactive messages.
Mark as read and typing indicator
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"status": "read",
"message_id": "wamid.HBgLNTUxMTk5OTk5OTk5ORUCABIYFjNFQjA...",
"typing_indicator": { "type": "text" }
}'
Without typing_indicator, the command only marks the message as read. With it, the customer also sees “typing…” until you reply or for up to 25 seconds, according to Meta’s typing indicator page. The success response is {"success": true}. More in how to mark a message as read.
Reading the response and errors
An accepted send returns the wamid:
{
"messaging_product": "whatsapp",
"contacts": [{ "input": "5511999999999", "wa_id": "5511999999999" }],
"messages": [{ "id": "wamid.HBgLNTUxMTk5OTk5OTk5ORUCABIYFjNFQjA..." }]
}
This means the request was accepted, not that the message was delivered. Delivery comes later, through the sent, delivered, read or failed statuses on the webhook (see message status via webhook).
For scripts, two curl tweaks help:
curl -sS -X POST "$WA_URL/messages" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d @mensagem.json \
-w '\nHTTP %{http_code}\n' | tee resposta.txt
# just the wamid, with jq
jq -r '.messages[0].id' resposta.txt
# just the error code and message
jq -r '.error | "\(.code) \(.message)"' resposta.txt
| Code | What it means | What to do |
|---|---|---|
131047 | More than 24 hours since the customer’s last message | Send a template |
132000 | Number of parameters does not match the template | Check the variables |
132001 | Template does not exist in that language or is not approved | Check name, language and status |
131053 | Media upload failed (unsupported type, wrong MIME) | Check format and type |
130429 | Throughput limit reached | Slow down and try again |
190 | Expired token | Generate a new token |
The full list is in WhatsApp API errors.
Extra commands on Vectalk
Beyond sending, Vectalk documents useful routes for support scripts. All of them use Authorization: Bearer:
# list templates (instance token; optional filter by name)
curl -sS "https://apis.vectalk.com.br/api/templates?name=confirmacao_pedido" \
-H "Authorization: Bearer $WA_TOKEN"
# list sent messages that failed in a period
curl -sS "https://apis.vectalk.com.br/api/messages?status=failed&direction=outbound&from=2026-11-01&to=2026-11-24" \
-H "Authorization: Bearer $WA_TOKEN"
# register a webhook
curl -sS -X POST "https://apis.vectalk.com.br/api/webhooks" \
-H "Authorization: Bearer $WA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"instance_id":"YOUR_INSTANCE_ID","url":"https://meuapp.com.br/whatsapp/webhook","name":"Production"}'
The routes are documented in list templates, list messages and webhooks.
How to do this with Vectalk
Vectalk is a proxy for the official WhatsApp Cloud API: the payloads in all the examples above are the same; only the URL and the token change. Create the token under Settings → API Tokens (Configurações → API Tokens) and send to https://apis.vectalk.com.br/api/messages, as shown in the quickstart. With an instance token, the phone_number_id is resolved automatically; with an organization token, include "phone_number_id" in the body, as described on the authentication page. Media upload and templates require an instance token. To get started, create your account. For the big picture of the API, see the guide to the official WhatsApp API.
Frequently asked questions
Why does curl give me an invalid JSON error?
It is almost always the quotes. Inside -d '...' the message text cannot contain a single quote (as in “it’s”). In those cases, save the JSON to a file and use -d @mensagem.json. On Windows (cmd), the quoting rules are different; prefer the file there too.
curl returned the wamid, but the message never arrived. What now?
The wamid only confirms that the request was accepted. Check the status on the webhook: if it comes back as failed, the error code tells you why. The full checklist is in message sent but not delivered.
Can I send to several numbers in a single curl call?
No. Each call sends to one recipient (or one group). For lists, run a loop that controls the pace and use approved marketing templates with opt-in.
Do I need Content-Type: application/json?
Yes, for sends with -d. For media uploads with -F, curl builds the multipart/form-data on its own; do not set the header manually.
How do I test the webhook with curl?
Generate the signature with openssl and send a sample payload to your local URL. The step-by-step is in test the webhook locally and in how to test a WhatsApp bot.
Official sources consulted on November 24, 2026: Meta: send messages, Meta: text messages, Meta: image messages, Meta: document messages, Meta: media, Meta: reply buttons, Meta: list messages, Meta: mark as read, Meta: typing indicator, Meta: templates, Meta: error codes, Vectalk: quickstart, Vectalk: authentication, Vectalk: media upload, Vectalk: list templates, Vectalk: list messages, Vectalk: webhooks.
Put your business on the official WhatsApp
Create your account, connect your number to the official API (you can keep the app with coexistence) and start serving customers and sending messages.
