Quickstart
1. Create an API key
In your dashboard, go to Settings, Integrations, API Access and click Create key. For this guide give it the templates:read and messages:send scopes. The key is shown once, so copy it straight away.
Keep it in an environment variable rather than in your code. The examples read it from there:
export WAMAFY_API_KEY="wamafy_live_..."$env:WAMAFY_API_KEY = "wamafy_live_..."The cURL examples are written for macOS, Linux or Git Bash. On Windows, use the Node.js or Python version, or run cURL from Git Bash.
Use the key only from your server. Anyone who has it can send messages as your business. More on keys in Authentication.
2. Pick a template
WhatsApp only lets a business start a conversation with a template that Meta has approved. List yours to get its name and the variables it needs:
# macOS, Linux or Git Bash, with WAMAFY_API_KEY set. The quoting does not work in Windows cmd or PowerShell.
curl "https://api.wamafy.com/api/v1/public/templates" \
-H "Authorization: Bearer $WAMAFY_API_KEY"In the response, variables gives the keys to fill in. For a body of Hi {{1}}, your order {{2}} is on its way. the keys are "1" and "2".
3. Send it
Send the template to your own phone first. The number needs its country code.
# macOS, Linux or Git Bash, with WAMAFY_API_KEY set. The quoting does not work in Windows cmd or PowerShell.
curl -X POST "https://api.wamafy.com/api/v1/public/messages" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+919876543210",
"templateName": "order_update",
"variables": {
"1": "Priya",
"2": "#1043"
}
}'A successful send returns the message id. Keep it.
{
"success": true,
"data": {
"messageId": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgSQzU",
"to": "919876543210",
"from": "6f1c2a9e-1b3d-4c7a-9e2f-7d4b8a1c0e55",
"status": "sent",
"campaignName": null,
"templateName": "order_update"
}
}status: "sent" means WhatsApp accepted the message. Whether it reached the phone comes a moment later, which is the next step.4. Check it was delivered
Look the message up by its id:
# macOS, Linux or Git Bash, with WAMAFY_API_KEY set. The quoting does not work in Windows cmd or PowerShell.
curl "https://api.wamafy.com/api/v1/public/messages/wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgSQzU" \
-H "Authorization: Bearer $WAMAFY_API_KEY"status moves from sent to delivered and, if the person has read receipts on, to read. If it says failed, error has WhatsApp's reason.
Next
- Reply when a customer writes back, without a template: The 24-hour window.
- Get delivery updates pushed to you instead of asking: Delivery status webhook.
- Hear about incoming messages: Event webhooks.
- Handle failures properly: Errors.