Automations
Flows that start on an event and send email, wait, branch and update contacts, written as steps and connections through the API.
An automation is a flow that runs for one contact when an event arrives: send an email, wait a day, wait for another event, branch on a value, change the contact, add them to a segment. You write it as a JSON document of steps and connections with POST /automations, or build the same document in the dashboard. The routes are under Automations in the API reference, with four more for checking a draft and reading its numbers (below).
How it works
- You send an event for a contact with
POST /events/send. - Every enabled automation whose
triggerstep names that event starts a run for the contact. Several automations on one event all start. - The run goes through the steps along the connections. A
delayor await_for_eventlets it rest for a while; asend_emailhands the email to the same pipeline asPOST /emails. - The run ends when no connection leaves the step it is on:
completed. A step that fails ends it asfailed.
Create, enable and run one
A welcome email, then a reminder three days later unless the contact activates first:
curl -X POST https://api.billionsend.com/automations \
-H "Authorization: Bearer $BILLIONSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome",
"steps": [
{ "key": "start", "type": "trigger", "config": { "event_name": "user.signed_up" } },
{ "key": "welcome", "type": "send_email", "config": {
"template": { "id": "TEMPLATE_ID", "variables": { "name": { "var": "contact.first_name" } } } } },
{ "key": "wait", "type": "wait_for_event", "config": { "event_name": "user.activated", "timeout": "3 days" } },
{ "key": "nudge", "type": "send_email", "config": { "template": { "id": "REMINDER_TEMPLATE_ID" } } }
],
"connections": [
{ "from": "start", "to": "welcome" },
{ "from": "welcome", "to": "wait" },
{ "from": "wait", "to": "nudge", "type": "timeout" }
]
}'
The answer is { "object": "automation", "id": "..." }. The automation starts as disabled: a draft may be incomplete, so nothing runs yet. Enable it when it is ready:
curl -X PATCH https://api.billionsend.com/automations/AUTOMATION_ID \
-H "Authorization: Bearer $BILLIONSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "status": "enabled" }'
Now an event starts a run. The contact is created if the address is new:
curl -X POST https://api.billionsend.com/events/send \
-H "Authorization: Bearer $BILLIONSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "event": "user.signed_up", "email": "success@simulator.amazonses.com" }'
GET /automations/{id}/runs lists the runs and GET /automations/{id}/runs/{run_id} shows each step of one. The automations.* operations in the API reference list every field.
Steps and connections
A step is { "key", "type", "config" }. The key names the step in connections and in the run record: 1 to 64 characters from A-Z a-z 0-9 _ . -, unique in the automation. A connection is { "from", "to", "type" } with step keys; type is optional and read back as default.
- A graph holds at most 100 steps and 200 connections, and the document may nest at most 40 levels. A name is at most 255 characters, and a team may have at most 500 automations.
- The graph is a one-way flow: a loop is refused, and so is a second
triggeror a connection into thetrigger. - A step has at most one connection of each type leaving it, so a flow does not fork in parallel. Branches come from
conditionandwait_for_event. - A step with no connection leaving it ends the run (
completed).
Connection type |
Leaves | Followed when |
|---|---|---|
default |
any step | the step finishes (also the fallback for the two below when they have no connection of their own) |
condition_met, condition_not_met |
a condition step |
the rule is true or false |
event_received, timeout |
a wait_for_event step |
the event arrived, or the wait ran out |
The eight steps
type |
config |
What it does |
|---|---|---|
trigger |
event_name |
Where the flow starts: the event whose arrival starts a run. |
delay |
duration |
Rests for a duration. |
send_email |
template: { id, variables? }, subject?, from?, reply_to?, topic_id? |
Sends a published template to the contact. |
wait_for_event |
event_name, timeout?, filter_rule? |
Rests until the contact gets that event, or the timeout passes. |
condition |
a rule | Goes condition_met or condition_not_met. |
contact_update |
first_name?, last_name?, unsubscribed?, properties? |
Changes the contact. |
contact_delete |
none ({}) |
Deletes the contact. |
add_to_segment |
segment_id |
Adds the contact to a segment. |
send_email. template.id is the template’s id or alias, and the template must be published. variables fills the template’s variables with a text, a number, a boolean or a { "var": "..." } reference (at most 100 variables); a number-typed variable takes a number or numeric text. subject, from and reply_to replace the template’s own (at most 998 characters each). from or the template’s default sender must name a verified domain. With topic_id, the email is a topic email: the contact must be subscribed, and the unsubscribe link carries the topic. A topic bound to a sending domain only works from that domain.
wait_for_event. An event counts if it reaches the contact after the step began, or in the 5 seconds before. Without timeout the wait is 30 days, so no wait lasts forever. With a filter_rule, only events that pass it end the wait. Its field reads the event that arrived (event.*) or the contact; a { "var": "event.x" } in its value reads the event that started the run. It cannot use wait_events.. A field the arriving event lacks just means no match.
contact_update. Values are a text, a number, a boolean, null or a { "var": "..." }. null clears a name or removes a property. A property must already be defined for the team, with a value of its type. unsubscribed: true sets the contact’s own team-wide switch; false only clears that switch and never undoes a recipient’s own unsubscribe. At most 100 properties a step. The change writes a timeline entry and fires contact.updated with source: "automation".
contact_delete. Deletes the contact (contact.deleted fires with source: "automation"). This run ends as completed, and the contact’s other runs are cancelled.
add_to_segment. The segment must exist, or the step fails. A contact already in it counts as success (output.added: false).
Durations
A delay and a timeout are a number and a unit, in one or more parts: "30 seconds", "2 hours", "1 day 12 hours", "1h30m". Units are second, minute, hour, day and week, in singular, plural or short form (s, min, h, d, w). The shortest is 1 second and the longest 30 days. A date or time of day is not a duration.
Conditions
A condition step’s config is one rule, and a wait_for_event filter_rule is one too. A rule is { "type": "rule", "field", "operator", "value" }, or { "type": "and" | "or", "rules": [...] } with at least one rule inside. Rules nest at most 5 deep and a condition has at most 50 rule nodes.
| Operator | value |
True when |
|---|---|---|
eq, neq |
text, number, boolean or null |
equal, or not (a number and numeric text compare as numbers) |
gt, gte, lt, lte |
number | the field, read as a number, compares so |
contains, starts_with, ends_with |
text | the field is a text that does |
exists, is_empty |
none | the field is there, or is empty ("", null, an empty list or object) |
Any value may be { "var": "..." } instead.
Reading data
field and { "var": "..." } read one of three places, with dots for nesting:
| Path | Reads |
|---|---|
event.<key> |
the payload of the event that started the run, such as event.plan or event.order.total |
contact.<field> |
id, email, first_name, last_name, unsubscribed, created_at or properties.<key>, as the contact is when the step runs |
wait_events.<event name>.<key> |
the payload of an event an earlier wait_for_event took (the latest, if it waited for that name twice) |
A condition fails when it reads a field that holds nothing, and the error lists the paths (condition_field_missing). exists and is_empty are the exceptions: they answer. A { "var" } in a rule’s value that points to nothing never matches and does not fail. A { "var" } in a send_email variable or a contact_update value that reads nothing fails that step (variable_missing).
Enabling, versions and stopping
status is enabled or disabled. Every write of steps and connections is checked: keys, types, config shapes, connection types, loops, durations, rules and the limits above. A draft may be incomplete after that. To enable, the whole automation is checked against your account:
- exactly one
trigger, and every step reachable from it; - a
wait_events.path only names await_for_eventthat comes before it; - every template exists and is published, every sender domain is verified, and every topic and segment exists.
Each problem comes back as 422 validation_error with the JSON Pointer of the field to change, for example /steps/2/config/duration.
- An enabled automation’s steps cannot change (
409 conflict). Stop it first, sendstatus: "disabled"in the same request, or duplicate it and change the copy. - Each change of steps is a new version. A run keeps the version it started on, so an edit never changes a run in flight.
POST /automations/{id}/stopstops new runs; runs already going finish. When a flow is sending what it should not, sendcancel_runs: truein the body (a BillionSend extension) to cancel the runs already going as well: each ends ascancelled, as cancelling a run does, and email already queued is not recalled. With a very large number of runs the call can take long; if it is cut off, send it again and it cancels what is left. The dashboard asks the same when you disable an automation.DELETE /automations/{id}ends them and removes their history.POST /automations/{id}/duplicatemakes a disabled copy named<name> (copy).- Agents write drafts; people enable. An agent key and an MCP connection cannot enable an automation (
403 forbidden); they write a draft, and a person enables it in the dashboard, or an integration’s own API key does. Stopping is open to all of them.
Runs
GET /automations/{id}/runs lists runs, newest first, and filters with status=running,failed (a comma list of running, completed, failed, cancelled). A run’s steps lists every step of its version: the ones it went through in order, then the rest as pending (still reachable) or skipped. A step’s status is pending, running, waiting, completed, failed or skipped, and it carries output or error. A run carries a status_reason, a sentence that says why it is in that state: the step a running run is at, the message and step of a failure, or who or what cancelled it.
{
"object": "automation_run",
"id": "…",
"status": "completed",
"started_at": "2026-11-18T09:00:00.000Z",
"completed_at": "2026-11-18T09:00:01.000Z",
"steps": [
{ "key": "start", "type": "trigger", "status": "completed" },
{ "key": "welcome", "type": "send_email", "status": "completed",
"output": { "to": "success@simulator.amazonses.com", "email_id": "…", "template": { "id": "TEMPLATE_ID", "variables": {} } } }
]
}
A run ends as cancelled when its contact is deleted, when you cancel it, or when its automation is stopped with cancel_runs. A run that is still going 90 days after it started ends as failed with run_expired. The email a run sends is in Logs and GET /emails like any other.
Why a step failed
A failed step has error: { code, message, details? }. The common codes:
code |
Meaning |
|---|---|
condition_field_missing |
A condition read a field with no value for this run. |
variable_missing, variable_invalid |
A { "var" } read nothing, or the value does not fit the template’s variable type. |
template_not_found, template_unavailable, template_render_failed |
The template was deleted, is not published, or does not render. |
sender_missing, invalid_sender, sender_domain_unverified |
No from, not one valid address, or the domain is no longer verified. |
topic_not_found, topic_domain_mismatch |
The topic was deleted, or is bound to another sending domain. |
monthly_quota_exceeded |
The plan’s monthly sending quota is used up, or, with overage on, its hard cap past it. |
team_refused, quota_backlog_full |
The team could not send for 24 hours: it is suspended, unclaimed, or has sending paused (the account’s or the domain’s), or its backlog of mail held for the plan’s quota is full. |
invalid_property, invalid_value, contact_not_found |
A contact_update value is not valid for its property, or the contact is gone. |
segment_not_found |
The segment was deleted. |
run_expired |
The run passed 90 days. |
Sending rules
An automation’s email is transactional mail with a contact attached: it is not a broadcast and counts in your plan’s email quota like any send. Runs themselves are not metered: GET /usage reports automation_runs.used for the billing period, and its limit is 9007199254740991, which means no limit.
- A recipient who unsubscribed gets no automation email unless the sending domain allows it. The contact’s own switch, the recipient’s unsubscribe from the sending domain or the team, the contact’s opt-out of the step’s topic, and the suppression list all skip the
send_emailstep: it isskippedwithoutput.reason(contact_unsubscribed,domain_unsubscribed,team_unsubscribed,topic_unsubscribedorrecipient_suppressed;recipient_unknown_mailboxfor an address that recently bounced as a mailbox that does not exist;undeliverableordead_domainfor an address or a domain that cannot receive mail) and the run goes on to the next step. A domain with Send transactional email to unsubscribed recipients on lets the domain and team unsubscribes through when the step names no topic; the contact’s switch, a topic opt-out and the suppression list still stop it. See Unsubscribes. - The email carries the contact’s
List-Unsubscribeheaders. A body with no unsubscribe placeholder gets the default unsubscribe footer, as in a broadcast. - If one of the team’s own gates holds the send (sending paused, an unclaimed account, a held backlog), the step waits and tries again, from 5 minutes up to an hour apart, for at most 24 hours; after that it fails as
team_refused(quota_backlog_fullwhen the backlog was the reason). - If the recipient’s mailbox provider is holding back the sending domain’s bulk mail, the step waits for the provider to lift it or for its ramp-up room, with
output.deferred: "provider_backoff"; this wait has no 24-hour limit. - A team’s runs start at most 20 sends per second; the rest wait a moment.
- At most 20 runs of one automation may be open for one contact. An event past that starts no run and is recorded as
dropped.
Validate, simulate, cancel and metrics
These four routes only add to the automation routes above, which stay exactly as they are. They are also MCP tools, so an agent can check its own draft.
| Operation | What it does |
|---|---|
POST /automations/validate |
Checks steps and connections without storing anything. Always 200, with valid, can_enable and every problem found: layer is draft for what stops a save and enable for what stops enabling, each with path, code, message and suggestion. |
POST /automations/{id}/simulate |
Works out one contact’s pass through the automation without running it: which way each step goes, and the emails it would send. Takes a contact (a real one by id or email, or a made-up one), the starting event’s payload, and events to hand to the waits, each with an optional after duration. Delays move a clock of its own, so days answer at once. Nothing is sent, stored or counted. |
POST / |
Ends a running run as cancelled. Email it already queued is not recalled. A run that already ended answers 409. |
GET /automations/{id}/metrics |
Runs started, completed, failed and cancelled, the results of the email it sent, and for each step how many entered, completed, failed in and skipped it. Defaults to the last seven UTC days; start_date and end_date change that. |
curl -X POST https://api.billionsend.com/automations/AUTOMATION_ID/simulate \
-H "Authorization: Bearer $BILLIONSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contact": { "email": "success@simulator.amazonses.com", "first_name": "Ana" },
"payload": { "plan": "pro" },
"events": [{ "name": "user.activated", "after": "1 day" }]
}'
Who can use it
- API keys. The automation and event routes need a full-access key that is not limited to one domain; a restricted key gets
403 restricted_api_key.POST /events/sendis open to any such key. - Roles. In the dashboard and on MCP, creating, changing, stopping and deleting automations and event definitions is for owners, admins and marketing members; every member can read them. An API key is not checked against a role. See Team roles.
- MCP. The tools are under the
automations:read,automations:writeandevents:sendpermissions. See MCP. - Webhooks. An automation’s contact changes fire the usual contact events with
source: "automation". See Webhooks.
Limits
| What | Limit |
|---|---|
| Steps and connections in one automation | 100 and 200 |
| Automations per team | 500 |
| Step key | 1 to 64 characters, A-Z a-z 0-9 _ . - |
delay and wait_for_event timeout |
1 second to 30 days; a wait without a timeout lasts 30 days |
| Rule nesting and rule nodes in one condition | 5 and 50 |
Variables on a send_email step, properties on a contact_update step |
100 each |
| Text value | 10,000 characters |
| Open runs of one automation for one contact | 20 |
| A run’s whole life | 90 days |
| A team’s automation sends | 20 per second |
| Runs | not metered |