Campaigns

Start a campaign

POST/campaignsScope campaigns:send

Creates 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

  • templateNamestringrequired

    Name of an approved template.

  • segmentIdstring

    Send 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.

  • variablesobject

    Template 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 named customer_name, name, first_name, last_name, company, email, phone or language fills from the contact by itself; the value you send is used only for contacts without one.

  • fromstring

    Which of your numbers to send from. Defaults to your default number.

  • namestring

    Campaign name. One is made up if you leave it out.

  • scheduledAtstring

    Start 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.

  • headerMediaUrlstring

    Public https link 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}}.

    • indexintegerrequired

      The button's position in the template, starting at 0, as List templates reports it.

    • typestringrequired

      What kind of button it is.

      One of: url, copy_code

    • valuestringrequired

      For a link button, the part that replaces the placeholder (offers/diwali); for a tracked link, the full destination URL. For copy code, the code.

  • offerExpiresAtstring

    For 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 headerMediaUrl when 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

StatusCodeWhen
400BAD_REQUESTA dynamic button has no value or names a button that takes none, or scheduledAt is in the past. Nothing is created.
400HEADER_MEDIA_REQUIREDThe template has a media header, no file saved in Wamafy, and no headerMediaUrl was sent.
403CAPACITY_LIMIT_REACHEDYour plan's monthly campaign or message allowance is used up.
403PLAN_UPGRADE_REQUIREDscheduledAt was sent and your plan does not include scheduling.
404NOT_FOUNDNo approved template or segment by that name or id. Nothing is created.
422VALIDATION_ERRORBoth 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"
}'
Response 201
{
  "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"
}'
    Start a campaign - Wamafy API