Guides & Tutorials

Launch a campaign

POST /api/campaign.php

Use this endpoint to create and launch a campaign to a list of subscribers. Content of the campaign can be provided through existing template, remote URL or HTML.

Request parameters

Note! Either template_id, html or html_raw parameter must be provided (among other required parameters) to create and launch a campaign.

Parameter Value
subject Campaign name and message subject.

Required.
from From email address.

Required.
from_name From name.
reply_to Reply-To email address.
template_id Template ID.
html Link to HTML content.

Needs to be in a publicly accessible URL.
html_raw HTML content.
list List(s) of subscribers to send the campaign to. Value can be either an ID or list of IDs.

Required.
due Due date of the campaign. If no value is set, the campaign will be scheduled for immediate delivery with a 5-minute “grace” period.

Formatted as YYYY-MM-DD HH:MM:SS, and presented in Europe/Tallinn timezone.
tags List of tags to apply to the campaign.
save_as_draft Disable campaign launch.

Default: 0

If the URL provided to parameter html response is other than HTTP/1.1 200, the request will fail.

Plain-text content will be generated from HTML content.

Response parameters

All possible response codes and their descriptions can be found in the “Response codes” page.

Parameter Value
code Response code.
message Human-readable response message.
id ID of the created campaign.

Example

Launching a campaign

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"subject": "Offers of the week", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/content.html", "list": [10, 11], "tags": ["offers"]}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/campaign.php"

(JavaScript/JSON)

{
  "code": 101,
  "message": "OK",
  "id": 1
}

Scheduling a campaign

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"subject": "Offers of the week", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/content.html", "list": 3, "due": "2021-05-17 12:00:00", "tags": ["offers"]}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/campaign.php"

(JavaScript/JSON)

{
  "code": 101,
  "message": "OK",
  "id": 2
}

Creating campaign as a draft

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"subject": "Offers of the week", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/content.html", "list": 3, "save_as_draft”: 1, "tags": ["offers"]}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/campaign.php"

(JavaScript/JSON)

{
  "code": 101,
  "message": "OK",
  "id": 3
}

Launching a campaign with provided HTML

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"subject": "Offers of the week", "from": "offers@domain.tld", "html_raw": "<html>...</html>", "list": 3, "tags": ["offers"]}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/campaign.php"

(JavaScript/JSON)

{
  "code": 101,
  "message": "OK",
  "id": 4
}