WhatsApp Cloud API With curl: Every Call You Need to Test

Copy-paste curl commands for the WhatsApp Cloud API: check your token, send text, templates, buttons and media, mark as read, and test your webhook.

Illustration: a terminal running a curl command next to a phone receiving a WhatsApp test message (sample data)

To send a WhatsApp message with curl, POST a JSON body to https://graph.facebook.com/v27.0/<PHONE_NUMBER_ID>/messages with two headers: Authorization: Bearer <TOKEN> and Content-Type: application/json. Every other call in Meta’s Cloud API follows the same pattern, so one terminal is enough to test a whole integration before you write any code.

This page is a reference you can paste from: set a few shell variables once, then run the calls in order. It covers checks that send nothing, the common message types, media, read receipts and your own webhook. All of it is Meta’s official Cloud API on Graph API v27.0, the latest in Meta’s changelog (4 November 2026). Prefer a window with buttons? See how to test the Cloud API with Postman.

Key takeaways

  • Set TOKEN, PHONE_ID, WABA_ID and API once, add a one-line helper, and every command below runs as written.
  • Start with a GET on your phone number ID. It proves the token and the ID without sending anything.
  • With -d, curl already uses POST, so you don’t need -X POST. You do need the JSON content type header.
  • Meta highly recommends a plus sign and country code in to. Without the plus, your own number’s country code is added.
  • A reply with messages[0].id means Meta accepted the request, not that the phone received it.

Set up once: variables, a helper and a few flags

You need an access token, a phone number ID and a WhatsApp Business Account (WABA) ID from your Meta app. If you don’t have them yet, start with the Cloud API setup guide and where to find your WABA and phone number IDs. Then set these in your terminal:

LineWhat it holds
read -rs TOKENYour access token. Paste it and press Enter; nothing is shown, and it stays out of your shell history
PHONE_ID=106540352242922Your phone number ID, not the phone number itself
WABA_ID=102290129340398Your WhatsApp Business Account ID
API=https://graph.facebook.com/v27.0Host and version in one place, so an upgrade is one edit
AUTH="Authorization: Bearer $TOKEN"The header every call needs
wa() { curl -sS "$API/$PHONE_ID/messages" -H "$AUTH" -H "Content-Type: application/json" -d "$1"; }A helper for the messages endpoint: wa followed by a JSON body in single quotes sends it

The IDs above are the sample values from Meta’s own examples; use yours. The commands are written for bash or zsh. On Windows, run them in WSL or Git Bash, or save the JSON body in a file and pass @body.json in its place, which avoids quoting problems.

FlagWhat it doesWhen to use it
-dSends a body, and makes the request a POSTSending messages. curl’s manual says of -X: “Normally you do not need this option”
-FSends a multipart form; @ attaches a fileMedia upload
-s and -SHide the progress meter, but still show errorsWhen you pipe the output somewhere
-iShows response headersChecking the status line

Check your token and number before you send

These calls only read. Run them first: a wrong ID or an expired token is quicker to spot here than in a failed send.

What you checkCommandWhat comes back
Token and phone number IDcurl -s "$API/$PHONE_ID" -H "$AUTH"id, display_phone_number, verified_name, quality_rating and code_verification_status
Every number on the accountcurl -s "$API/$WABA_ID/phone_numbers" -H "$AUTH"A data array with each number’s ID, name and quality rating
Your templatescurl -s "$API/$WABA_ID/message_templates?fields=name,status,category,language&limit=20" -H "$AUTH"A data array, plus paging with cursors for the next page
Which apps get this account’s webhookscurl -s "$API/$WABA_ID/subscribed_apps" -H "$AUTH"A data array of subscribed apps

Leave out fields on the template call and Meta returns its default fields, including components, which is how you see a template’s exact variables before sending it.

If a token keeps failing, Meta’s debug_token endpoint reports is_valid, expires_at and scopes. Call it with an app access token or an app developer’s user token, not the token you’re inspecting:

Set APP_ID and APP_SECRET from your app’s Basic settings first, in the same way as TOKEN.

curl -s -G "$API/debug_token" --data-urlencode "input_token=$TOKEN" --data-urlencode "access_token=$APP_ID|$APP_SECRET"

-G turns the --data-urlencode values into a query string on a GET. For sending, the token needs the whatsapp_business_messaging permission.

Send messages: template, text and buttons

Every send goes to the same URL, so the wa helper from the setup takes just the JSON body. Only type and the object named after it change. Replace +919800000000 with your own WhatsApp number; don’t test on customers.

MessageCommand
Sample templatewa '{"messaging_product": "whatsapp", "to": "+919800000000", "type": "template", "template": {"name": "hello_world", "language": {"code": "en_US"}}}'
Text with a link previewwa '{"messaging_product": "whatsapp", "recipient_type": "individual", "to": "+919800000000", "type": "text", "text": {"preview_url": true, "body": "Track order ORD-1042: https://example.com/track/1042"}}'
Reply buttonswa '{"messaging_product": "whatsapp", "recipient_type": "individual", "to": "+919800000000", "type": "interactive", "interactive": {"type": "button", "body": {"text": "Your table for 4 is booked for 8 pm. Need to change it?"}, "action": {"buttons": [{"type": "reply", "reply": {"id": "change-booking", "title": "Change"}}, {"type": "reply", "reply": {"id": "cancel-booking", "title": "Cancel"}}]}}}'
  • Only the template works at any time. Free-form messages need an open 24-hour customer service window, which starts when the customer messages you. So send the template, reply to it from your phone, then run the other two.
  • Text: the body can be up to 4,096 characters. For a preview, the link must start with http:// or https://, and only the first link in the body is previewed.
  • Reply buttons: up to 3 buttons, each with a unique title of up to 20 characters and an ID of up to 256. The body takes up to 1,024 characters, and an optional footer 60.

To send your own template with variables, a media header or buttons, keep the same command and swap the body: the JSON for each case is in how to send a WhatsApp template message with the API. List messages and other interactive types are explained in WhatsApp interactive messages.

Media: upload, send, fetch and delete

Media is the one place where the request isn’t JSON. Upload the file as a multipart form, keep the ID that comes back, and send that ID in a normal message. -F makes the request a POST too.

StepCommand
Upload a filecurl -s "$API/$PHONE_ID/media" -H "$AUTH" -F "messaging_product=whatsapp" -F "file=@menu.jpg;type=image/jpeg"
Send it as an imagewa '{"messaging_product": "whatsapp", "recipient_type": "individual", "to": "+919800000000", "type": "image", "image": {"id": "<MEDIA_ID>", "caption": "This week’s menu"}}'
Get a media URLcurl -s "$API/<MEDIA_ID>" -H "$AUTH"
Download the filecurl -s "<MEDIA_URL>" -H "$AUTH" -o photo.jpg
Delete uploaded mediacurl -s -X DELETE "$API/<MEDIA_ID>" -H "$AUTH"
  • The upload returns {"id": "<MEDIA_ID>"}. Meta keeps uploaded files for 30 days unless you delete them sooner.
  • The type= after the file name sets the file’s MIME type. Images can be JPEG, PNG or static WebP, up to 5 MB.
  • Media URLs expire after 5 minutes. If the download returns 404, ask for a new URL and try again. The download needs the same Authorization header, or it fails.
  • -X DELETE is needed here, because nothing else tells curl the method. A successful delete returns {"success": true}.

Formats, size limits and sending by link are in how to send images and documents with the WhatsApp API. Files that customers send you arrive as media IDs in a webhook; see how to download media from the WhatsApp API.

Mark as read, show typing, reply and react

These four calls all refer to a message the customer sent you, so you need its ID (wamid...), which arrives in your webhook as messages[].id.

ActionBody to pass to `wa`
Mark as read{"messaging_product": "whatsapp", "status": "read", "message_id": "<WAMID>"}
Mark as read and show “typing…”{"messaging_product": "whatsapp", "status": "read", "message_id": "<WAMID>", "typing_indicator": {"type": "text"}}
Quote their message in your reply{"messaging_product": "whatsapp", "recipient_type": "individual", "to": "+919800000000", "context": {"message_id": "<WAMID>"}, "type": "text", "text": {"body": "Yes, the blue one is in stock in size M."}}
React to their message{"messaging_product": "whatsapp", "recipient_type": "individual", "to": "+919800000000", "type": "reaction", "reaction": {"message_id": "<WAMID>", "emoji": "👍"}}
  • The first two return {"success": true} with no message ID, because nothing was sent.
  • Marking one message as read also marks the earlier ones in a one-to-one chat. Meta says to do it within 30 days of receiving the message.
  • The typing indicator clears when your reply lands or after 25 seconds, whichever comes first. Meta’s advice is to show it only if you’re going to respond.

The rules behind these are in typing indicators and read receipts and how to reply to a message with the API.

Read the response and the errors

A send that Meta accepts returns messaging_product, a contacts array with the number you sent (input) and its WhatsApp ID (wa_id), and a messages array with the new message’s id. Meta’s page is explicit that this only shows the API accepted your request; delivery is reported later through webhooks. To pull out just the ID, pipe the output through jq, as in wa @body.json | jq -r '.messages[0].id'.

A failed call returns an error object instead. Meta says to build on code and error_data.details, not the title or the HTTP status, and to keep fbtrace_id for its support team.

CodeMeta’s meaningWhat to check in your command
190Access token has expiredSet TOKEN and AUTH again. Changing TOKEN alone doesn’t update AUTH
200No access token was providedAUTH is empty or -H "$AUTH" is missing (some endpoints answer 190 or 104 instead)
100Unsupported or misspelled parameterThe JSON keys, and that the URL has the phone number ID, not the phone number
131009A parameter value is invalidThe number format, or a wamid copied wrongly
131047More than 24 hours since the customer last repliedSend a template, or reply from your phone first
132001Template missing in that language, or not approvedRun the template list call and copy the name and language from it
  • Sharing output. -v prints the headers curl sends, on lines starting with >, and that includes your token. Remove it before pasting the output into a ticket.

Every code, including the ones that only arrive by webhook, is in WhatsApp API error codes. If you send in a loop, read WhatsApp API rate limits before you raise the speed.

Test your own webhook from the terminal

curl can’t receive Meta’s events, but it can play Meta’s part against your endpoint. Two commands cover the two things an endpoint must get right. Set APP_SECRET to your app secret and use your real callback URL.

  1. The handshake. curl -i "https://your-domain.example/webhook?hub.mode=subscribe&hub.verify_token=YOUR_VERIFY_TOKEN&hub.challenge=12345" should return status 200 and the body 12345. With a wrong verify token it should return anything but 200.
  2. Make a sample body. BODY='{"object":"whatsapp_business_account","entry":[]}'
  3. Sign it the way Meta does. SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$APP_SECRET" | sed 's/^.* //') gives the HMAC-SHA256 of the body, keyed with your app secret, as hex.
  4. Send the signed POST. curl -i "https://your-domain.example/webhook" -H "Content-Type: application/json" -H "X-Hub-Signature-256: sha256=$SIG" -d "$BODY" should be accepted with a 200.
  5. Send it again with one character of $SIG changed. Your endpoint should now reject it. If it still returns 200, anyone who finds the URL can send it fake events.

This proves your code, not Meta’s route to it. The callback URL must be public HTTPS with a valid certificate (Meta doesn’t support self-signed ones), and the account must be subscribed to your app. If the subscribed_apps check earlier returned an empty list, subscribe with curl -s -X POST "$API/$WABA_ID/subscribed_apps" -H "$AUTH", which returns {"success": true}. Real payloads and retries are covered in WhatsApp Cloud API webhooks, and the usual faults in webhook not receiving messages.

From curl to code, or to no code

Once a command works, it translates line by line into any language. We have guides for Node.js, Python, PHP, Java, C# and Go, each with error handling and a signed webhook.

If you use Automate AI, you don’t call Meta directly or host its webhooks. The app’s Developer page has its own cURL examples for Automate AI’s REST API, which uses an API key in the same Authorization: Bearer header, plus a Postman collection with every request. A new key is shown once, when you create it. That API isn’t Meta’s and has its own URLs, so the commands on this page won’t run against it unchanged.

Teams that don’t want to script at all can send approved templates as campaigns, now or on a schedule. The REST API and developer webhooks are included on the AI + Automation Plan and Series 4; see pricing and the WhatsApp Business API page.

Frequently asked questions

How do I send a WhatsApp message with curl?

Run curl "https://graph.facebook.com/v27.0/<PHONE_NUMBER_ID>/messages" with -H "Authorization: Bearer <TOKEN>", -H "Content-Type: application/json" and -d followed by a JSON body that has messaging_product, to, type and the message object.

Do I need -X POST in a WhatsApp API curl command?

No. -d and -F already make the request a POST, and curl’s manual says you normally don’t need -X. You do need -X DELETE to delete media, because nothing else sets that method.

Why does curl return a message ID but nothing arrives?

The reply only means Meta accepted the request. Delivery is reported later by webhook. Check the number has WhatsApp and is allowed on your test number, and look for a failed status in your webhook.

How do I upload a file to the WhatsApp API with curl?

Send a multipart form to /<PHONE_NUMBER_ID>/media with -F "messaging_product=whatsapp" and -F "file=@menu.jpg;type=image/jpeg". Put the media ID that comes back in the id field of the message.

Should the recipient number have a plus sign?

Meta highly recommends including the plus sign and the country calling code. If the plus is missing, your business number’s country code is added in front, which can misdeliver the message.

Sources

  1. Meta: Send messages
  2. Meta: Media (upload, retrieve, download, delete)
  3. Meta: Mark messages as read
  4. Meta: Interactive reply buttons messages
  5. Meta: Template management
  6. Meta: Error codes
  7. Meta: Create a webhook endpoint
  8. curl: man page

WhatsApp rules and prices change. We check these guides against Meta’s documentation, but always confirm current terms with Meta before you rely on them. Questions? Message us on WhatsApp at +91 836 977 8812.