Automations
An automation is a campaign of type automation. Instead of a one-time send to a frozen audience, it is a standing journey: contacts enter it one at a time as enrollments and move through a graph of steps over time. The automation itself is created, started, paused and canceled through the Campaigns endpoints; the Automations endpoints enroll contacts and list enrollments.
Defining an automation
POST /campaigns with type: "automation", a domain_id, a marketing template_id, a trigger and a steps array creates the automation in draft. Omitting trigger or steps is 422 with trigger_required or steps_required; an audience is not used. Sender resolution works as for blasts, using the automation route — see Sender profiles.
Triggers
trigger.kind |
Enrolls a contact when |
|---|---|
manual |
You call POST /automations/{id}/enroll. |
contact_created |
A contact is created with POST /contacts. |
list_added |
A contact is added with POST /lists/{id}/members to the list named by list_id. |
POST /automations/{id}/enroll works for every trigger kind. Triggers only fire while the automation is running (status sending); contacts created or added before it started are not enrolled retroactively. Contact imports fire neither contact_created nor list_added, even when the import targets a list; enroll imported contacts explicitly if they should enter the journey.
Steps
steps holds 1 to 32 steps. Each has an id of 1–32 characters from A–Z a–z 0–9 _ -. The first step in the array is the entry point, and steps link to each other by id.
type |
Fields | Behaviour |
|---|---|---|
send |
template_id, optional next_id |
Sends the template to the contact, producing a message with source_type: automation and journey_step_id set to this step. It uses the template’s current version at the moment the step runs. If the template is not an active marketing template at that moment, the step is skipped and the journey continues. |
wait |
duration_ms, optional next_id |
Waits a fixed time before the next step: at least 1 ms and at most 7 776 000 000 ms (90 days). |
branch |
condition, true_next, optional false_next |
Evaluates condition against the contact and continues at true_next or false_next. |
exit |
— | Ends the enrollment. |
A step without next_id ends the enrollment after it runs. The graph is validated on create; an invalid one is 422 with { "field": "steps", "message": <reason> }. It must contain at most one branch step, every referenced id must exist, and it must contain an exit step reachable from the graph.
Branch conditions
A condition has a field, an op and a value. field is a path into the contact record, such as first_name, status or custom.plan.
op |
True when |
|---|---|
eq / neq |
The field equals / does not equal value, including its type: "5" does not equal 5. |
gt, gte, lt, lte |
Both the field and value are numbers and the comparison holds. |
in |
value is an array that contains the field’s value. |
contains |
Both are strings and the field contains value. |
A missing field never matches, except for neq. When the condition is false and there is no false_next, the enrollment exits with exit_reason: branch_no_path.
Lifecycle
An automation uses the campaign statuses:
draft ──POST /campaigns/{id}/send──► sending ◄──resume── paused
│ └────pause────► │
└──cancel──► canceled ◄──cancel──┘
- It is created in
draft.POST /campaigns/{id}/sendstarts it and moves it tosending, where it stays — an automation never reachessent. - New enrollments are accepted only while it is
sending. POST /campaigns/{id}/pauseandPOST /campaigns/{id}/resumeapply to the whole automation, not to single enrollments.POST /campaigns/{id}/cancelends it for good and moves everyactiveandwaitingenrollment tocanceled.
Enrollments
POST /automations/{id}/enroll enrolls one existing contact, identified by contact_id or email, and returns 202 with { "enrollment_id", "status" }. A contact enrolls at most once per automation: enrolling it again returns the existing enrollment, even one that has already exited, so the call is safe to repeat and a contact never re-enters the same automation.
| Error | Meaning |
|---|---|
404 |
The automation or the contact does not exist in your account. The two cases are not distinguished. |
409 campaign_not_automation |
The campaign is not of type automation. |
409 campaign_not_active |
The automation is not running (sending), for example because it was never started. |
409 no_steps |
The automation has no steps. |
Key fields
| Field | Description |
|---|---|
id |
The enrollment identifier (enrollment_id in the enroll response). |
campaign_id / contact_id |
The automation and the contact. |
current_step_id |
The step the enrollment is at or waiting on; null once it has ended. |
status |
See Statuses. |
enrolled_at / last_step_at / exited_at |
When the contact entered, last advanced, and left. |
exit_reason |
Why the enrollment ended early; null when it reached an exit step or the end of the journey. |
Statuses
| Status | Meaning |
|---|---|
active |
Progressing through the journey. |
waiting |
Paused at a wait step until its duration has passed. |
exited |
Ended: reached an exit step or a step without next_id, or stopped early for the reason in exit_reason. Final. |
canceled |
Ended because the automation was canceled (exit_reason: campaign_canceled). Final. |
Exit reasons
exit_reason |
Cause |
|---|---|
unsubscribed |
At a send step the contact was no longer subscribed (or no longer existed). |
insufficient_credits |
The balance could not fund the message of a send step. |
credit_protection |
Funding the message would cross your protected credit minimum. |
sender_not_configured |
No sender profile resolved for the send step. |
branch_no_path |
A branch condition was false and the step has no false_next. |
unknown_step |
The step the enrollment was due to run no longer exists. |
campaign_canceled |
The automation was canceled. |
A suppressed address still progresses through the journey, but each message to it ends in status suppressed instead of being sent. GET /automations/{id}/enrollments lists an automation’s enrollments, cursor-paginated and optionally filtered by status.
Related API
- Automations tag —
POST /automations/{id}/enroll,GET /automations/{id}/enrollments. - Campaigns tag, for the automation itself —
POST /campaigns,GET /campaigns,GET /campaigns/{id},PATCH /campaigns/{id},DELETE /campaigns/{id},POST /campaigns/{id}/send,POST /campaigns/{id}/pause,POST /campaigns/{id}/resume,POST /campaigns/{id}/cancel.
See the API Reference for full schemas, and Campaigns for the lifecycle an automation shares with blasts.