Campaigns
Start a campaign
/campaignsScope campaigns:sendCreates a broadcast and starts it straight away, or at scheduledAt. Sending carries on in the background; follow it with Get a campaign or under Campaigns in the dashboard.
Pick the audience with segmentId or tags. With neither, it goes to every active contact.
Body
templateNamestringrequiredName of an approved template.
segmentIdstringSend to a saved segment. Its members are worked out when the campaign starts. Cannot be combined with
tags.tagsstring[]Send to contacts with any of these tags.
variablesobjectTemplate variable values. Each recipient gets their own: put
{{lead.first_name}},{{lead.company}},{{custom.city}}and so on in a value to fill it from their contact. A variable namedcustomer_name,name,first_name,last_name,company,email,phoneorlanguagefills from the contact by itself; the value you send is used only for contacts without one.fromstringWhich of your numbers to send from. Defaults to your default number.
namestringCampaign name. One is made up if you leave it out.
scheduledAtstringStart later instead of now, as an ISO 8601 time with offset such as
2027-10-29T10:00:00+05:30. Must be in the future. Needs a plan that includes scheduling.headerMediaUrlstringPublic
httpslink to the header image, video or document, used instead of the file saved with the template. Can contain{{lead.X}}for a different file per contact. Needed only when the template has a media header and no file saved in Wamafy.buttonsobject[]Values for dynamic buttons: a link button with a placeholder, or a copy-code button. Required for each one the template has. A value can contain
{{lead.X}}.indexintegerrequiredThe button's position in the template, starting at 0, as List templates reports it.
typestringrequiredWhat kind of button it is.
One of:
url,copy_codevaluestringrequiredFor a link button, the part that replaces the placeholder (
offers/diwali); for a tracked link, the full destination URL. For copy code, the code.
offerExpiresAtstringFor a limited-time offer template with a countdown: when the offer ends, as an ISO 8601 time with offset.
Good to know
- Opted-out contacts are skipped.
- Keep
campaignId: Get a campaign shows how it is going. - For a media header, the campaign uses
headerMediaUrlwhen you send one, otherwise the file saved with the template in Wamafy. - Sending one message per contact over Send a template message works too, but this gives you a single campaign with its own report.
Errors
| Status | Code | When |
|---|---|---|
| 400 | BAD_REQUEST | A dynamic button has no value or names a button that takes none, or scheduledAt is in the past. Nothing is created. |
| 400 | HEADER_MEDIA_REQUIRED | The template has a media header, no file saved in Wamafy, and no headerMediaUrl was sent. |
| 403 | CAPACITY_LIMIT_REACHED | Your plan's monthly campaign or message allowance is used up. |
| 403 | PLAN_UPGRADE_REQUIRED | scheduledAt was sent and your plan does not include scheduling. |
| 404 | NOT_FOUND | No approved template or segment by that name or id. Nothing is created. |
| 422 | VALIDATION_ERROR | Both segmentId and tags were sent, or a field has the wrong shape (a header link must be https). |
Plus the errors any endpoint can return, such as a missing key or scope. See Errors.
# 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/campaigns" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateName": "diwali_offer",
"segmentId": "0f2c8a1e-6b3d-4c9a-8e2f-5d7b1a3c9e40",
"variables": {
"1": "friend"
},
"name": "Diwali VIP"
}'{
"success": true,
"data": {
"campaignId": "3c5e7a9b-1d2f-4a6c-8e0b-2d4f6a8c0e13",
"name": "Diwali VIP",
"status": "sending",
"scheduledAt": null
}
}Base URL https://api.wamafy.com/api/v1/public
More examples
Personalised for each contact
Fill a variable from each recipient's contact with {{lead.first_name}}. Every contact in the segment gets their own name.
# 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/campaigns" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateName": "diwali_offer",
"segmentId": "0f2c8a1e-6b3d-4c9a-8e2f-5d7b1a3c9e40",
"variables": {
"1": "{{lead.first_name}}"
},
"name": "Diwali personalised"
}'Contacts with a tag
Send to everyone tagged vip or gold. A contact with either tag gets it once.
# 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/campaigns" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateName": "diwali_offer",
"tags": [
"vip",
"gold"
],
"variables": {
"1": "friend"
},
"name": "Diwali tagged"
}'Scheduled for later
Add scheduledAt to start at a set time. The answer says scheduled, and the segment is worked out when it starts, so contacts who join before then are included.
# 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/campaigns" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateName": "diwali_offer",
"segmentId": "0f2c8a1e-6b3d-4c9a-8e2f-5d7b1a3c9e40",
"variables": {
"1": "{{lead.first_name}}"
},
"scheduledAt": "2027-10-29T10:00:00+05:30",
"name": "Diwali morning"
}'With an image header and a link button
The same header and button options a single send has. Here every contact gets the same image and a link that ends in their own phone number.
# 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/campaigns" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateName": "festive_link",
"tags": [
"vip"
],
"headerMediaUrl": "https://wamafy.com/smoke/sample.png",
"buttons": [
{
"index": 0,
"type": "url",
"value": "offers/{{lead.phone}}"
}
],
"variables": {
"1": "{{lead.first_name}}"
},
"name": "Festive with link"
}'Every contact
Leave out both segmentId and tags to send to every active contact in the workspace. Check the template and the count in the dashboard first: this cannot be undone once it starts.
# 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/campaigns" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateName": "diwali_offer",
"variables": {
"1": "friend"
},
"name": "Diwali everyone"
}'