Send a WhatsApp message with cURL: copy-paste commands
Send a WhatsApp template message from the command line with cURL. Check your key, send with a test key first, retry without double-sending, read the status, and a short shell script that handles the errors.
November 15, 2026 · 7 min read
If you want to see a WhatsApp API call work before you write any application code, cURL is the quickest way. This guide gives you the commands in order: check your key, send a template message with a test key (nothing is sent), repeat the call safely, read the message status, and then a short shell script that retries only the errors worth retrying.
SendFromChat is an independent product and is not affiliated with Meta or WhatsApp. It runs on Meta's official WhatsApp Cloud API; you keep your own WhatsApp Business account.
What was tested: every command and the script below were run with cURL 8 in Git Bash on Windows against a small local mock server that follows our REST API reference. They were not run against a live SendFromChat key or Meta, so try them with a test key first. The commands are written for bash or zsh. On Windows, use Git Bash or WSL; quoting in cmd and PowerShell is different and is not covered here.
The short version
- Get a template approved.
- Create a test key: it runs every check and sends nothing.
POST /messageswith anIdempotency-Keyheader, so a retry never sends twice.- Check the HTTP status and the
error.typein the answer before you retry anything.
1. What you need
- An approved template. A message you start outside a 24-hour conversation window must use a template Meta has approved (how the window works). Approval is usually a matter of minutes (the rules, explained). The examples use a template called
order_shippedwith the text "Hi {{1}}, your order {{2}} has shipped." - A test key (
sfc_test_…), created on the dashboard's Developers page. It checks your plan, opt-outs, the template and the 24-hour window, then stops: nothing is sent, saved or counted. Swap in a live key (sfc_live_…) when you are ready. - Opt-in. Only message people who agreed to WhatsApp updates (how to collect opt-in).
Keep the key in an environment variable on your machine or server, not in a shared script, a repository or browser code:
export SENDFROMCHAT_KEY=sfc_test_...
2. Check that the key works
curl -sS https://sendfromchat.com/api/v1 \
-H "Authorization: Bearer $SENDFROMCHAT_KEY"
GET /api/v1 returns your workspace, whether the key is live or test, and the numbers it can send from. A wrong or revoked key returns 401 with "type": "unauthorized". A test key can only send from a connected number, so with no number connected a send returns 409 no_number.
3. Send a template message
curl -sS -i https://sendfromchat.com/api/v1/messages \
-H "Authorization: Bearer $SENDFROMCHAT_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-4821-shipped" \
-d '{
"to": "+491512345678",
"template": {
"name": "order_shipped",
"language": "en_US",
"variables": ["Ana", "#4821"]
}
}'
Four details matter:
-iprints the response headers, which is where you will see the status code and, on a repeat,Idempotent-Replayed.tois international format with the country code, such as+491512345678(phone number format).variablesfill{{1}},{{2}}… in order. An object like{"1": "Ana", "2": "#4821"}works too.- Single quotes around the JSON keep the shell from touching
#and$. If a value contains a single quote, put the body in a file and use-d @body.json.
With a test key the answer is 200 and includes "status": "test". With a live key it is 202 and looks like this:
{ "id": "wamid.HBgL…", "status": "accepted", "to": "+491512345678", "from": "…", "whatsappAccountId": "…", "type": "template" }
202 accepted means the request was accepted, not that the customer received or read the message. Step 5 shows how to check.
4. Repeat the call without sending twice
Run the same command again with the same Idempotency-Key. A retry with the same key and the same body returns the first response with Idempotent-Replayed: true instead of sending again. Reusing the key with a different body returns idempotency_mismatch.
Derive the key from the event in your system (order-4821-shipped), not from the attempt. A timeout, a re-run job or a double click then gets the first answer back instead of a second message.
5. Other message types
Free-form text, which only delivers within 24 hours of the person's last message to you:
curl -sS https://sendfromchat.com/api/v1/messages \
-H "Authorization: Bearer $SENDFROMCHAT_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+491512345678", "text": "Thanks, we are on it."}'
If the window has closed, the answer is 422 with "type": "window_closed" and a windowOpenUntil time. Send a template instead.
A file from a public https link (the same 24-hour rule applies):
curl -sS https://sendfromchat.com/api/v1/messages \
-H "Authorization: Bearer $SENDFROMCHAT_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+491512345678", "media": {"url": "https://example.com/brochure.pdf", "filename": "Brochure.pdf", "caption": "Here is the brochure"}}'
More on files in sending a PDF over the WhatsApp API.
6. Read the status
Use the id from a live send (the wamid… value):
curl -sS "https://sendfromchat.com/api/v1/messages/wamid.HBgL..." \
-H "Authorization: Bearer $SENDFROMCHAT_KEY"
The status moves sent (Meta accepted it) → delivered → read, or ends as failed with the reason. Polling works for a quick check; for a real app, subscribe to webhooks instead (delivery status guide, receiving replies).
7. A small script that retries the right errors
Not every error should be retried. A closed window or an opted-out contact will fail every time; a network timeout or a server error is worth another try, and the idempotency key makes that safe. Save this as send.sh:
#!/bin/sh
# Usage: SENDFROMCHAT_KEY=sfc_test_... ./send.sh order-4821-shipped < body.json
# Exit codes: 0 sent (or accepted), 1 error to fix, 2 WhatsApp's rules (do not retry now).
set -u
IDEM="${1:?usage: send.sh IDEMPOTENCY_KEY < body.json}"
BODY=$(cat)
API="${SENDFROMCHAT_API:-https://sendfromchat.com/api/v1}"
OUT=$(mktemp)
trap 'rm -f "$OUT"' EXIT
attempt=1
while [ "$attempt" -le 3 ]; do
code=$(curl -sS --max-time 10 -o "$OUT" -w '%{http_code}' \
-X POST "$API/messages" \
-H "Authorization: Bearer $SENDFROMCHAT_KEY" \
-H "Idempotency-Key: $IDEM" \
-H "Content-Type: application/json" \
-d "$BODY") || code=000
case "$code" in
200|202)
cat "$OUT"; echo
exit 0 ;;
000|5??)
echo "attempt $attempt: HTTP $code, retrying with the same key" >&2 ;;
409)
if grep -q '"request_in_progress"' "$OUT"; then
echo "attempt $attempt: the same key is still running, retrying" >&2
else
cat "$OUT" >&2; echo >&2
exit 1
fi ;;
422|429)
cat "$OUT" >&2; echo >&2
exit 2 ;;
*)
cat "$OUT" >&2; echo >&2
exit 1 ;;
esac
sleep $((attempt * 2))
attempt=$((attempt + 1))
done
echo "gave up after 3 attempts" >&2
exit 1
Use it like this:
chmod +x send.sh
./send.sh order-4821-shipped <<'JSON'
{"to": "+491512345678", "template": {"name": "order_shipped", "language": "en_US", "variables": ["Ana", "#4821"]}}
JSON
What it does with each answer:
| HTTP status | Meaning | The script |
|---|---|---|
200, 202 |
Test run or accepted | Prints the answer, exits 0 |
no answer, 5xx |
Network or server problem | Retries up to 3 times with the same key |
409 request_in_progress |
The same key is still being processed | Retries |
409 no_number |
No connected number | Stops, exit 1 |
422 |
WhatsApp's rules: opted_out, window_closed, template_not_approved, whatsapp_rejected |
Stops, exit 2: log it and move on |
429 warmup_limit |
A new number reached today's cap | Stops, exit 2: retry later |
429 rate_limited |
Over the per-minute request limit | Stops, exit 2: wait the Retry-After seconds, then retry |
400, 401, 402, 403, 404 |
Fix the request, the key or the plan | Stops, exit 1 |
warmup_limit applies to brand-new numbers, which are capped at 50, 100, then 200 template sends a day for the first three days. The full error table is in the REST API reference.
Two limits of the script: it sends one message per run, and it does not wait for delivery. For a list of recipients, loop over it with a different idempotency key for each person (order-4821-shipped, order-4822-shipped, …), and keep your own record of who has been sent. The same idea in a language of your choice: Python, Node.js, PHP and Laravel.
Costs, in plain terms
Two separate things: SendFromChat's flat monthly plan (from $19), and Meta's per-message charge, which Meta bills to your own WhatsApp Business account at its published rates, with no markup from us. Rates depend on the message category and the recipient's country; see WhatsApp API pricing.
A note for EU and UK customers
SendFromChat stores data in Mumbai, India. Transfers from the EU and UK are covered by the Standard Contractual Clauses and the UK Addendum in our Data Processing Agreement, and the sub-processors are listed publicly. Read it before you decide; our GDPR guide covers consent, opt-out and records on your side.
Try it
Start the 30-day free trial (no card), connect a number, create a test key and run the command in step 3. If you would rather not write the call yourself, ask your AI assistant: SendFromChat connects to Claude and ChatGPT, and with Claude Code it can write the integration for your language (Claude Code guide). Weighing other routes? See SendFromChat vs Twilio and using Meta's Cloud API directly.
Do this from your AI assistant
SendFromChat connects Claude, ChatGPT, Cursor or any MCP client to the WhatsApp Business API — templates, bulk sends, inbox, chatbots and sequences, just by asking. 30 days free, no card.
Start freeMore guides
How to handle WhatsApp STOP and opt-outs in your app
A customer replied STOP on WhatsApp. What must your app do? Honour the opt-out everywhere, block the next send, log it, and let people opt back in, with a tested webhook handler and the exact error to expect.
WhatsApp Cloud API webhook not working? A step-by-step checklist
Meta's WhatsApp webhook won't verify, or verifies but sends nothing? Work through six checks in order (verify token, public HTTPS, subscribed field, overrides, signature, 200 reply) with a tested Node receiver and curl commands.
Retry WhatsApp API sends without double-sending: idempotency keys, timeouts and 429s
How to retry a failed WhatsApp send safely. An Idempotency-Key example in Node, what the API does on a replay, a timeout, a 409 or a 429, and which errors you should never retry. Tested against a local mock.
WhatsApp template variables: how to fill the parameters from the API (and why a send says missing_variables)
How to fill {{1}}, {{2}} and {{3}} in a WhatsApp template from code, with curl and Node examples, a check that counts the values before you send, and what the 132000 and 132012 errors mean when a send does reach Meta.