Campaigns
A campaign is an email you send to a selection of contacts in your account.
Overview
Each campaign has a name, a status that tracks where it is in its lifecycle, and
the details of the message to send — its subject, preview text, sender, and
audience. A campaign starts as a draft and is built up incrementally across
update calls. It can also start from a template — see
Creating from a template.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /campaigns | List campaigns |
| POST | /campaigns | Create a campaign |
| GET | /campaigns/{uuid} | Get a campaign |
| PATCH | /campaigns/{uuid} | Update a campaign |
| DELETE | /campaigns/{uuid} | Delete a campaign |
| POST | /campaigns/{uuid}/send | Send a campaign now |
| POST | /campaigns/{uuid}/test | Send a test email |
| POST | /campaigns/{uuid}/schedule | Schedule a campaign |
| POST | /campaigns/{uuid}/unschedule | Unschedule a campaign |
| POST | /campaigns/{uuid}/cancel | Cancel a campaign |
| GET | /campaigns/{uuid}/contacts | List a campaign's live audience |
| GET | /campaigns/{uuid}/recipients | List who a campaign was sent to |
| GET | /campaigns/{uuid}/link-clicks | List a campaign's link clicks |
Statuses
A campaign's status tracks where it is in its lifecycle:
| Status | Meaning |
|---|---|
draft | Being edited. Not scheduled or sent. |
scheduled | Scheduled to send at a future time. |
queued | Queued for sending. |
sending | Currently being sent. |
sent | Fully sent. |
failed | Sending did not complete successfully. |
canceled | Canceled before it finished sending. |
A/B test campaigns
An A/B test sends two versions of a campaign to a share of its audience, picks
the better one, and sends that version to everyone else. You can test the subject
line, the preheader, or both. Variant A is the campaign's own subject and
preheader; variant B's values and the test settings live in the ab_test
object.
Setting up a test
Send ab_test on Create Campaign or Update
Campaign:
{
"subject": "Free shipping all weekend",
"ab_test": {
"b_subject": "Free shipping ends Sunday"
}
}
The object is merged onto the campaign's stored test: keys you send change,
and keys you leave out keep their values. The exception is the winner schedule:
switching winner_schedule_type to at_time clears duration_hours, switching
it to after_hours clears winner_at, and an after_hours test without a
duration_hours gets 24 unless you send one. b_subject, b_preheader,
duration_hours, and winner_at can be sent as null to clear them; the other
keys can't be null. Send ab_test: null to remove the test. On a campaign
without a test the merge starts from these defaults:
| Field | Default |
|---|---|
test_subject | true if you sent a non-null b_subject, otherwise false |
test_preheader | true if you sent a non-null b_preheader, otherwise false |
pool_percent | 20 |
winner_criteria | clicks |
winner_schedule_type | after_hours |
duration_hours | 24 |
So {"b_subject": "…"} alone sets up a complete subject test. If both
test_subject and test_preheader end up false, an existing test is removed;
on a campaign without a test that's rejected with 422 VALIDATION_ERROR on
ab_test. Each field is described in A/B Test Object.
A test can be saved before it's complete, so you can build it up over several
requests: a tested field without a B value, at_time without winner_at, or
after_hours with duration_hours sent as null, is saved, and
readiness.missing lists ab_test until the test is complete.
Out-of-range values return 422 VALIDATION_ERROR on the offending key, such as
ab_test.pool_percent, and keys other than the nine writable fields of the A/B
Test Object return The ab_test field must be an object with only these keys: test_subject, test_preheader, b_subject, b_preheader, pool_percent, winner_criteria, winner_schedule_type, duration_hours, winner_at.
on ab_test. A rejected ab_test changes nothing: on create, no
draft is created; on update, no other field is saved either.
Winner time
For at_time, winner_at must be at least 1 hour and at most 72 hours after the
send time. The send time is the campaign's scheduled_at when it is in the future,
otherwise now.
- An Update Campaign or Create
Campaign request that sends
winner_atorwinner_schedule_typereturns422 VALIDATION_ERRORonab_test.winner_atwhen the winner time doesn't fit that window. A storedwinner_atthat no longer fits doesn't block changes to otherab_testkeys. - Sending or scheduling when the stored
winner_atdoesn't fit the new send time returns409 CAMPAIGN_NOT_SENDABLEwith the messageThe winner time must be at least 1 hour and at most 72 hours after the send time.The campaign is left unchanged: ascheduledcampaign keeps its status andscheduled_at.
How a test runs
The test's progress is in ab_test.phase:
| Phase | Meaning |
|---|---|
configured | Set up; no test email has gone out yet. |
testing | The test emails to variants A and B are going out. |
choosing_winner | The test emails are out; waiting for the winner to be picked. |
sending_winner | The winner is picked and its send to the rest of the audience has started. The phase stays sending_winner after that send finishes. |
While the test runs:
statusstayssendingfrom the first test email until the winner send finishes. That includes a wait of up to 72 hours after the test emails go out, plus however long the winner send itself takes.recipients_countis the size of the test group until the winner is picked, then grows to the full total. The recipient list grows in the same two steps: first the test group (variantaandb), then the rest of the audience (variantwinner).subjectandpreheaderare variant A's. Results per variant are inab_test.variants.- Canceling during the wait stops the winner send.
After the test has started
Once ab_test.phase is anything other than configured, the test can't be
changed or run again:
- Update Campaign rejects every change to the campaign — not
only to
ab_test— with409 CAMPAIGN_NOT_EDITABLEand the messageCampaign cannot be edited because its A/B test has already started. This holds even when the campaign's status isfailed. - The campaign can't be sent or scheduled again. While it is
sendingits status already rules that out; if it ends upfailed,readiness.missinglistsab_test_started, and Send Campaign and Schedule Campaign return409 CAMPAIGN_NOT_SENDABLEwith a message saying the A/B test has already started.
Audience size
An A/B test needs at least 3 contacts in the audience — enough for variant A,
variant B and the winner. A smaller audience lists ab_test_audience in
readiness.missing, and sending or scheduling returns 422 CAMPAIGN_NOT_READY. The check uses the audience at the moment you ask, so a
scheduled campaign whose audience drops below 3 before its send time ends up
failed.
Testing a variant
Send a Test Email can preview either variant — see A/B test variants.
Editing and deleting by status
Which write operations a campaign allows depends on its status:
- A campaign can be updated only while its status is
draft,scheduled, orfailed. Updating a campaign in any other status returns409 CAMPAIGN_NOT_EDITABLE. A campaign whose A/B test has started follows its own rule — see After the test has started. - A campaign can be deleted only while its status is
draft,sent,failed, orcanceled. Deleting a campaign in any other status returns409 CAMPAIGN_NOT_DELETABLE.
Sending lifecycle
Which lifecycle transition a campaign allows also depends on its status:
- A campaign can be sent (Send Campaign) or scheduled
(Schedule Campaign) only while its status is
draft,failed, orscheduled, and only once it is ready (see Readiness). Any other status returns409 CAMPAIGN_NOT_SENDABLE, and a campaign that is not ready returns422 CAMPAIGN_NOT_READY. - A
scheduledcampaign can be unscheduled (Unschedule Campaign), returning it todraft. Any other status returns409 CAMPAIGN_NOT_UNSCHEDULABLE. - A
queuedorsendingcampaign can be canceled (Cancel Campaign). Any other status returns409 CAMPAIGN_NOT_CANCELABLE. Ascheduledcampaign is unscheduled, not canceled.
While one of these transitions is being processed for a campaign, a concurrent
transition on the same campaign returns 409 CAMPAIGN_TRANSITION_IN_PROGRESS;
retry after a moment.
To see who a campaign would send to right now, list its live audience with List Campaign Contacts. To see who a sent campaign was actually sent to and how each recipient engaged, use List Campaign Recipients.
Active plan required
An account can only send while it has an active plan. Send
Campaign, Schedule Campaign, and Send a
Test Email return 403 PLAN_INACTIVE when the account is not
allowed to send: it has no active plan, it has been deactivated, or sending has
been disabled for it by support. The same code is returned in all three cases.
A refused call leaves the campaign untouched — its status, schedule, and content are unchanged, and no email goes out. Repeating the request returns the same error until the account owner activates a plan or contacts support; changing the request does not resolve it.
When the account's plan cannot be verified, the same three calls return 503 SERVICE_UNAVAILABLE, leaving the campaign untouched in the same way. This one is
temporary and needs no action from the account owner — retry the request, with
backoff.
Sending a test
Send a Test Email sends a one-off preview to a single address
without changing the campaign's status, reaching its audience, or recording
recipients, so it works from any status. It needs only a subject, a body, and a
sender identity.
Audience
A campaign's audience is a contact list, a contact segment, or both. You set it
with the list_uuid and segment_uuid fields on Create
Campaign and Update Campaign, and read
it back in the audience object:
| Field | Type | Description |
|---|---|---|
list_uuid | string|null | UUID of the contact list the campaign sends to. null when not set. |
segment_uuid | string|null | UUID of the contact segment the campaign sends to. null when not set. |
With a segment, the campaign sends to the contacts matching the segment's
conditions — and when a list is also set, only to those in the list. A segment
must have at least one filter condition. Setting segment_uuid replaces any filter
conditions already on the campaign, and sending segment_uuid: null removes the
segment and its conditions. On Update Campaign, setting
list_uuid changes only the list: a segment and its conditions stay. Creating from
a template follows its own rule — see Creating from a
template.
A list_uuid or segment_uuid that does not belong to your account, or a segment
with no filter conditions, is rejected with 422 VALIDATION_ERROR.
Filter conditions saved in the dashboard are also part of the audience, but the API
does not return them. A campaign with only those conditions reports null for both
fields, and does not list audience in missing. List Campaign
Contacts shows who it would send to.
Readiness
Every single-campaign response carries a readiness object describing whether
the campaign is ready to send:
| Field | Type | Description |
|---|---|---|
can_send | boolean | true only when every requirement is met (missing is empty). |
missing | array | The requirements not yet met. |
Each entry in missing names a requirement and how to satisfy it:
| Requirement | How to satisfy |
|---|---|
from_name | Set from_name on the campaign. |
sender_email | Set from_identity to a sender identity. |
sender_enabled | The campaign's sender identity is not ready to send from. See Sending readiness. |
subject | Set subject on the campaign. |
content | Set the email body with the content field (Markdown) on Create Campaign or Update Campaign, or build it in the dashboard. See Campaign body. |
audience | Set list_uuid and/or segment_uuid. A campaign whose segment's conditions are not applied to it also lists audience, with or without a list, and can't be sent — send segment_uuid again to apply them. See Audience. |
audience_filters | The campaign's audience filters reference a custom field that no longer exists. Edit them so they no longer reference it. |
ab_test | The campaign's A/B test is incomplete: a tested field has no B value, winner_schedule_type is at_time without a winner_at, or after_hours without a duration_hours. Complete it with ab_test on Update Campaign, or remove the test with ab_test: null. See A/B test campaigns. |
ab_test_audience | The campaign has an A/B test but fewer than 3 contacts in its audience. Grow the audience or remove the test with ab_test: null. See Audience size. |
ab_test_started | The campaign's A/B test has already started, so the campaign can't be sent or scheduled again. See After the test has started. |
New requirements can be added to this list. Treat a value you don't recognize as
a requirement that is not yet met: can_send stays false until it drops out
of missing.
A campaign with no body lists content in missing, and can_send reports
false until the body is set. Once a body is set, content drops out of
missing.
Campaign Object
Create, Get, and Update return the full campaign object:
| Field | Type | Description |
|---|---|---|
uuid | string | Unique identifier for the campaign |
name | string | Campaign name |
status | string | Current status (see Statuses) |
subject | string|null | Email subject line. null until set. On an A/B test campaign, variant A's. |
preheader | string|null | Preview text shown after the subject in the inbox. null until set. On an A/B test campaign, variant A's. |
from_name | string|null | Sender display name. null until set. |
reply_to | string|null | Reply-to email address. null until set. |
from_identity | string|null | UUID of the sending identity the campaign sends from. null until set. |
from_email | string|null | Email address of the selected sending identity. null when no identity is set. |
content | string|null | The email body as Markdown, or null — either no body is set, or the body uses layout with no Markdown form (distinguish via content_editable_via_api). See Campaign body. |
content_editable_via_api | boolean | false when the body uses layout the API can't author (see Campaign body). |
content_overwrite_required | boolean | true when replacing the body with content requires overwrite: true (see Campaign body). |
audience | object | The campaign's recipients (see Audience). |
ab_test | object|null | The campaign's A/B test settings and state, or null without a test (see A/B Test Object). |
readiness | object | Whether the campaign is ready to send (see Readiness). |
created_at | string | ISO 8601 timestamp (UTC) |
updated_at | string | ISO 8601 timestamp (UTC) the campaign itself last changed, such as an edit or a status change. Messages being sent, opened, or clicked don't change it. |
last_updated_at | string|null | ISO 8601 timestamp (UTC) the campaign was last edited. |
The List Campaigns endpoint returns a condensed version of
each campaign: it omits preheader, reply_to, from_identity, from_email,
content, content_editable_via_api, content_overwrite_required,
audience, readiness, and last_updated_at, and instead includes language,
scheduled_at, and recipients_count. Its ab_test is a short summary — phase,
winner_variant, and winner_at — or null (see A/B Test Summary
Object).
A/B Test Object
ab_test is null for a campaign without an A/B test. Otherwise it holds the
settings you write with ab_test on Create Campaign and
Update Campaign — see Setting up a
test — and the test's current state. Variant A is the
campaign's own subject and preheader, so only variant B's values appear here.
The first nine fields are the ones you can write; the rest are read-only.
| Field | Type | Description |
|---|---|---|
test_subject | boolean | Whether the subject line is tested. When true, variant B uses b_subject. |
test_preheader | boolean | Whether the preheader is tested. When true, variant B uses b_preheader. |
b_subject | string|null | Variant B's subject line (max 255 characters). null until set. |
b_preheader | string|null | Variant B's preheader (max 255 characters). null until set. |
pool_percent | integer | Share of the audience, in percent, that gets the test emails, split evenly between A and B — an even number from 2 to 98. The rest of the audience gets the winner. |
winner_criteria | string | How the winner is picked: clicks (higher click rate — unique clickers per send) or open_rate (higher open rate). |
winner_schedule_type | string | When the winner is picked: after_hours (duration_hours after the test emails finish going out) or at_time (at winner_at). |
duration_hours | integer|null | Hours between the test emails finishing and the winner pick, from 1 to 72. Used with after_hours; null for at_time. |
winner_at | string|null | When the winner is picked, as an ISO 8601 timestamp (UTC). For at_time, the time you set — send it as an ISO 8601 instant with an explicit offset or Z, within the winner time window. If the test emails haven't finished an hour before that time, the pick moves to one hour after they finish, and winner_at changes to match. For after_hours, null until the test emails finish, then the computed pick time. |
phase | string | configured, testing, choosing_winner, or sending_winner. See How a test runs. |
test_audience_count | integer|null | Number of contacts in the full audience when the test was split — not the size of the test group. null until the test starts. |
winner_variant | string|null | The variant that won, a or b. null until the winner is picked. |
test_finished_at | string|null | ISO 8601 timestamp (UTC) the test emails finished going out. null until then. |
winner_chosen_at | string|null | ISO 8601 timestamp (UTC) the winner was picked. null until then. |
variants | array | Results per variant. Only present on Get Campaign with include=stats. See Variant Object. |
Variant Object
ab_test.variants lists the results per variant, in the order a, b,
winner, with an entry only for variants that have started sending — the array
is empty before the test starts. The campaign's top-level stats add up variant
A, variant B and the winner send. See Get Campaign for an
example.
| Field | Type | Description |
|---|---|---|
variant | string | a, b, or winner (the winning version sent to the rest of the audience). |
subject | string|null | The subject line this variant was sent with. null when it isn't recorded. |
preheader | string|null | The preheader this variant was sent with. null when it had none. |
sends | integer | Messages of this variant sent. |
opens | integer | Distinct recipients of this variant who opened. |
clicks | integer | Distinct recipients of this variant who clicked — counted the same way as stats.clicks. |
open_rate | number | opens ÷ sends, a ratio between 0 and 1 rounded to 4 decimals (0 when nothing was sent). |
click_rate | number | clicks ÷ sends, a ratio between 0 and 1 rounded to 4 decimals (0 when nothing was sent). |
decision | object|null | The sends, opens, clicks, open_rate, and click_rate frozen when the winner was picked — the numbers the pick was based on. null for winner and before the pick. |
Campaign body
The campaign body is the email's content. Set it with the content field on
Create Campaign and Update Campaign, read
it back in the content field, and send content: null to clear it. The body can
also be edited in the dashboard.
Writing the body
content is a Markdown string, up to 65000 characters. Supported:
- Headings (levels 1–6)
- Bold and italic text
- Links —
http,https,mailto,tel,sms, orwhatsapp - Bullet and numbered lists
- Blockquotes
- Fenced and indented code blocks
- Images
- Horizontal rules (
---) - Hard line breaks
Tables, strikethrough, task lists, inline `code`, and raw HTML are not
supported — they are silently dropped or flattened to plain text, so stick to the
supported subset.
Reading the body back
content returns the stored body as Markdown, or null when no body is set or the
body uses layout that has no Markdown form. Two flags describe whether that body
can be rewritten through the API:
| Field | Type | Description |
|---|---|---|
content_editable_via_api | boolean | false when the body uses layout the API can't author (multi-column layouts, social-icon rows, countdown timers); the returned content is then a lossy approximation. |
content_overwrite_required | boolean | true when the existing body carries formatting Markdown can't preserve — the layout above, or styling such as custom colors, fonts, buttons, or styled images. |
When both flags are false, the body is plain enough to overwrite freely.
Overwriting a richer body
To replace a body that reports content_overwrite_required: true, set
overwrite: true on your Update Campaign call — this
permanently discards the existing styling or layout. The same applies on Create
Campaign when content replaces a body
copied from a template. Without it, the write is
rejected with 409 CONTENT_OVERWRITE_REQUIRED. A body that is
content_editable_via_api: false can only be changed by editing it in the
dashboard, or by passing overwrite: true to replace it with Markdown.