Guides & Tutorials

Launch an A/B test

POST /api/split.php

Use this endpoint to create and launch a A/B test to a list of subscribers. Content of each section 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 an A/B test.

Parameter Value
splits A list of sections, which will be part of the A/B test. See also “Structure of the parameter splits”.

Required.
list List(s) of subscribers to send the A/B test to. Value can be either an ID or list of IDs.

Required.
size Deprecated.

A percentage taken from unique subscribers, contained in lists obtained from the parameter list, which is divided equally between all the sections specified in the splits parameter.

Required.
condition Deprecated.

Winning condition, which will be used to select the best-performing section. Possible values are openrate, clicks, views and unsubscribed.

Default: clicks
win_at Deprecated.

Due date to send out the A/B test to the rest of the list with the best-performing split options.

Formatted as YYYY-MM-DD HH:MM:SS, and presented in Europe/Tallinn timezone.

Required.
save_as_draft Disable A/B test launch.

Default: 0

Structure of the parameter splits

Note! Either template_id, html or html_raw parameter must be provided (among other required parameters) to create and launch an A/B test.

Parameter Value
subject Email subject.

Required.
from From email address.

Required.
from_name From name.
template_id Template ID.
html Link to HTML content.

Needs to be in a publicly accessible URL.
html_raw HTML content.
html_raw Due date of the section. If no value is set, the section will be scheduled for immediate delivery with a 5-minute “grace” period.

Note! Due date must not be later than parameter win_at.

Formatted as YYYY-MM-DD HH:MM:SS, and presented in Europe/Tallinn timezone.

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 A/B test.

Examples

Launching an A/B test

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"splits":[{"subject": "Offers of the week - test A", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/contentA.html"}, {"subject": "Offers of the week - test B", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/contentB.html"}], "list": [10, 11], "condition": "clicks", "win_at": "2021-05-17 17:00:00", "size": 10}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/split.php"

(JavaScript/JSON)

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

Scheduling an A/B test

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"splits":[{"subject": "Offers of the week - test A", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/contentA.html", "due": "2021-05-17 16:30:00"}, {"subject": "Offers of the week - test B", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/contentB.html", "due": "2021-05 17 16:35:00"}], "list": [10, 11], "condition": "clicks", "win_at": "2021-05-17 17:00:00", "size": 10}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/split.php"

(JavaScript/JSON)

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

Creating A/B test as a draft

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"splits":[{"subject": "Offers of the week - test A", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/contentA.html", "due": "2021-05-17 16:30:00"}, {"subject": "Offers of the week - test B", "from": "offers@domain.tld", "html": "https://domain.tld/path/to/contentB.html", "due": "2021-05 17 16:35:00"}], "list": [10, 11], "condition": "clicks", "win_at": "2021-05-17 17:00:00", "size": 10, "save_as_draft": 1}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/split.php"

(JavaScript/JSON)

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