Automations
An automation walks each person through a flow of emails, waits and conditions. Something starts it, such as an event from your app, and from there it runs by itself.
What an automation is made of
- A trigger: what starts a run. An event you send, a built-in event, a schedule, a date on each contact, or nothing but your own call.
- Steps: what a run does, in order. The first step in the list is where every run starts.
- Rules: the time zone, the sending hours, who may enter again, and what ends a run early.
Each time a person enters, a run is made for them. A run remembers where the person is, the data that started it and what every step did.
You always edit a copy. Publishing makes that copy the one that runs, as a new version, and a run finishes on the version it entered on. So an edit never changes a flow under the people who are in it.
Create and publish
An automation starts as a draft. A step names the step that follows it with next, and a step that goes two ways names both with yes and no. Without next, the step after it in the list follows, and null ends the run there.
curl -X POST "$OPENSEND_API_URL/v1/automations" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Welcome", "trigger": { "kind": "event", "event": "user.signed_up" }, "steps": [ { "id": "welcome", "kind": "send_email", "from": "Acme <hello@mail.example.com>", "subject": "Welcome to Acme", "html": "<p>Glad you are here.</p>" } ]}'The answer lists problems: what is missing or wrong, with the step and the field each one is about. A draft can be saved with problems. It cannot be published while one of them is blocking.
curl -X POST "$OPENSEND_API_URL/v1/automations/auto_teams/publish" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'- Publishing a draft also starts it. Publishing an active or a paused automation keeps its state.
automation_incomplete: something blocks the publish. The message names the step and says what is missing.- A sender has to be on a verified domain, a template has to be published, and an audience or a webhook a step names has to exist.
Start it with an event
An event says that something happened to one person. Send it from your app with an address, or the id of a contact, and any data that belongs to it.
curl -X POST "$OPENSEND_API_URL/v1/events/send" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "order.paid", "email": "ada@example.com", "data": { "order_id": "1042", "total": 49 }}'{ "object": "event_receipt", "id": "rcp_04", "name": "order.paid", "email": "ada@example.com", "contactId": null, "data": { "order_id": "1042", "total": 49 }, "started": 1, "resumed": 0, "exited": 0, "createdAt": "2026-11-27T09:30:00.000Z"}- Every active automation whose trigger names the event starts a run. The answer counts them as
started. - When a contact has the address, the run is for that contact: its names fill the email and its subscription is respected. Without one, the run is for the bare address.
- The data takes up to 10 KB. Its values fill
{{name}}slots and can be tested by conditions. - With
idempotencyKey, or theIdempotency-Keyheader, a repeat of the request answers with the first result and starts nothing.
These events are sent by the workspace itself. A trigger or a wait can name them.
- Event
contact.created- Sent when
- A person becomes a contact of the workspace. It is sent once for an address.
- Event
contact.joined- Sent when
- A contact is added to an audience, when they are new and when they were a contact already. Its data has
audience_id.
- Event
contact.left- Sent when
- A contact is taken out of an audience. They stay a contact.
- Event
contact.updated- Sent when
- A name or a property of a contact changes. Its data has
changed, the names that changed, so a condition can ask whetherchangedcontainsplan.
- Event
contact.subscribed- Sent when
- A contact who had unsubscribed is subscribed again.
- Event
contact.unsubscribed- Sent when
- A contact unsubscribes.
- Event
email.delivered- Sent when
- An email to the person is delivered.
- Event
email.opened- Sent when
- The person opens an email.
- Event
email.clicked- Sent when
- The person follows a link in an email.
- Event
email.bounced- Sent when
- An email to the person bounces.
- Event
email.complained- Sent when
- The person marks an email as spam.
- Event
email.received- Sent when
- The person writes to an address on one of your domains.
A trigger can carry conditions, so only some events start a run, and audienceId, so only contacts of one audience enter. For contact.joined and contact.left that is the audience they joined or left. For every other event it is an audience the contact is in.
Other ways to start
- Kind
event- Starts a run
- When the event it names arrives, for the person the event is about.
- Kind
schedule- Starts a run
- At a time that repeats every day, week or month, for every subscribed contact of an audience.
- Kind
date- Starts a run
- On a date each contact carries in a property, or a number of days before or after it. With
yearly, every year.
- Kind
manual- Starts a run
- Only when you enrol someone.
Enrolling starts a run for one person in any active automation, whatever its trigger.
curl -X POST "$OPENSEND_API_URL/v1/automations/auto_welcome/enroll" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "email": "ada@example.com"}'Start a flow from a payment
Your payment provider tells your server what happened with a webhook. Send that on as an event, and an automation can act on it: notices while a payment is open, a reminder before a renewal, a note after a cancellation.
import { OpenSend } from '@open-send/opensend' const opensend = new OpenSend() export async function paymentFailed(noticeId: string, email: string, payUrl: string) { const receipt = await opensend.events.send( { name: 'payment.failed', email, data: { pay_url: payUrl } }, { idempotencyKey: noticeId }, ) console.log(receipt.started)}- Check the signature of the request first, the way your provider describes, and call this from its handler.
- The id the provider gives its event is the idempotency key, so a delivery it repeats starts nothing twice.
- With Polar,
subscription.past_dueis the payment that failed andorder.paidthe one that went through.
The dashboard has a starter for each of these flows. A starter listens for the names below, which you can change to the ones your app sends.
- Starter
- Failed payment
- Starts on
payment.failed- Also listens for
payment.succeeded- What it does
- Three notices that stop once the payment goes through.
- Starter
- Abandoned checkout
- Starts on
checkout.started- Also listens for
order.paid- What it does
- A reminder when a checkout stays unpaid for an hour.
- Starter
- Renewal reminder
- Starts on
invoice.upcoming- Also listens for
- Nothing else
- What it does
- A note before a subscription renews.
- Starter
- Cancellation
- Starts on
subscription.canceled- Also listens for
subscription.started- What it does
- A goodbye, then one invitation to come back.
Steps
- Kind
send_email- What it does
- Sends an email to the person, or to the address in
to. Written in the step, or built from a published template.
- Kind
delay- What it does
- Waits for an amount of minutes, hours, days or weeks, up to 365 days.
- Kind
wait_until- What it does
- Waits until a time of day, on the days of the week you allow. With
dateit waits for a date in place of that: one you write, or one a slot holds, such as{{starts_at}}, with anamountof timebeforeor after it. A date that has passed lets the run go on at once, and a run with no date there fails.
- Kind
wait_for_event- What it does
- Waits for an event about the person.
yeswhen it arrives,nowhen the time is up.
- Kind
condition- What it does
- Tests the person, the data or what happened so far.
yeswhen it holds,nootherwise.
- Kind
branch- What it does
- Sends the run down one of up to 8 named paths: the first one in
brancheswhose conditions hold, ornowhen none does.
- Kind
split- What it does
- Sends a share of people down
yesand the rest downno. A person always lands on the same side.
- Kind
update_contact- What it does
- Changes the names, the properties or the subscription of the contact.
- Kind
delete_contact- What it does
- Deletes the contact for good. The run ends there.
- Kind
send_event- What it does
- Sends an event of your own about the person, with
datawhose text can hold{{name}}slots. It is recorded like one you sent yourself, so it starts the automations that listen for it, lets their waits go on and applies their exit events. A chain of automations that start each other this way ends after three.
- Kind
add_to_audience- What it does
- Adds the person to an audience, and makes them a contact first when they are not one. It sends
contact.joined, andcontact.createdfor a new contact.
- Kind
remove_from_audience- What it does
- Takes the person out of an audience, which sends
contact.left. They stay a contact.
- Kind
webhook- What it does
- Posts a signed
automation.stepevent to one of your webhooks, with the data of the run.
- Kind
exit- What it does
- Ends the run.
Paths can meet again: two steps may name the same next. A flow cannot loop back to a step it has passed.
More than two ways
A condition step has two ways out. A branch step has as many as you name: each entry of branches has a name, its own conditions with match, and to, the step that follows. The paths are tested from the top and the first that holds is taken. no is where a run goes when none holds.
import { OpenSend } from '@open-send/opensend' const opensend = new OpenSend() export async function welcomeByPlan(from: string) { const flow = await opensend.automations.create({ name: 'Welcome by plan', trigger: { kind: 'event', event: 'plan.chosen' }, steps: [ { id: 'plan', kind: 'branch', branches: [ { name: 'Pro', conditions: [{ kind: 'data', field: 'plan', operator: 'equals', value: 'pro' }], to: 'pro', }, { name: 'Team', conditions: [{ kind: 'data', field: 'plan', operator: 'equals', value: 'team' }], to: 'team', }, ], no: 'free', }, { id: 'pro', kind: 'send_email', from, subject: 'Welcome to Pro', text: 'Pro is on.', next: null }, { id: 'team', kind: 'send_email', from, subject: 'Welcome to Team', text: 'Your team has its space.', next: null }, { id: 'free', kind: 'send_email', from, subject: 'Welcome', text: 'You are on the free plan.', next: null }, ], }) await opensend.automations.publish(flow.id) console.log(flow.steps.length) return flow.id}- The run says which way it went: the step answers
yeswith the name of the path, ornowhen none matched. - A path needs a name of its own and at least one condition.
toandnoend the run when they arenullor left out.
Conditions
A condition step, a trigger and a wait for an event take a list of conditions. match says whether all of them have to hold or any one is enough.
- Kind
data- Tests
- A value in what started the run, such as
planororder.total. In a wait for an event it reads the event that arrives.
- Kind
waited- Tests
- A value in an event a wait step received earlier in the run.
- Kind
contact- Tests
- A field of the contact:
email,first_name,last_name,statusor one of its properties.
- Kind
email- Tests
- Whether an email a step of this run sent was delivered, opened, clicked, bounced or complained about.
- Kind
event- Tests
- Whether the person sent an event since the run started, or within a number of days.
- Kind
audience- Tests
- Whether the person is in an audience.
- Kind
subscribed- Tests
- Whether the contact is subscribed.
- Kind
group- Tests
- Several of the above as one, with a
matchof its own.
- The operators are
equals,not_equals,greater_than,greater_or_equal,less_than,less_or_equal,contains,not_contains,starts_with,ends_with,exists,is_empty. - Text is compared without regard to capitals, and numbers and dates by their value.
- A value that is not there never matches, apart from
is_empty. not: trueturns a test around.- A
valuecan hold{{name}}slots. In a wait for an event that is how the event is tied to the run:{ "kind": "data", "field": "order_id", "operator": "equals", "value": "{{order_id}}" }.
The emails of a run
A send step fills {{name}} slots in its subject, HTML and text. What goes into HTML is escaped.
- Slot
{{first_name}},{{last_name}}- Filled with
- The names of the contact, or the same names in the data.
- Slot
{{email}}- Filled with
- The address of the person.
- Slot
{{unsubscribe_url}}- Filled with
- The unsubscribe link of the contact.
- Slot
- A property of the contact
- Filled with
- Its value, by its name.
- Slot
- A value in the data of the event
- Filled with
- Its value, by its name. It wins over a property.
- Slot
- A name in
variablesof the step - Filled with
- What you wrote there, which can hold slots itself.
- A slot with no value fails that one run with
missing_variable, so nobody gets an email with a hole in it. - With
template, the step sends the published copy of a template.variablesgives its values. - An email that is due outside the sending hours waits until they open.
- Every email a run sends is in the emails, with its status and events.
Rules
- Setting
timezone- What it decides
- The time zone its times of day are read in.
UTCto begin with.
- Setting
reentry- What it decides
after_exit: a person can enter again once their run has ended.once: never again.always: every time, even while a run is going.
- Setting
reentryAfterDays- What it decides
- With
after_exit, how many days have to pass after a run ends.
- Setting
window- What it decides
- The sending hours: days of the week, and a time they open and close.
- Setting
exitOn- What it decides
- Events that take a person out of the automation the moment they arrive.
- Setting
respectUnsubscribes- What it decides
- Whether unsubscribed contacts are left alone.
Pause, resume and test
Pausing stops new people from entering. runs says what happens to the people already inside: hold keeps them where they are until you resume, finish lets them go on to the end, cancel ends their runs.
curl -X POST "$OPENSEND_API_URL/v1/automations/auto_welcome/pause" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'An automation also pauses itself, and holds its runs, when something it depends on stops working: a sender whose domain is no longer verified, a template that is gone, an audience or a webhook that was deleted. It does the same on a plan that stops at its limits, once the emails of the month are used up. pausedReason and pausedDetail say which. Fix it and resume, and everybody goes on from where they stopped.
A test walks the copy you are editing, now, for one address. Its emails are really sent, with "[Test]" before the subject. Waits are skipped, a wait for an event takes its no path, and steps that change contacts or call webhooks are skipped. Nothing is counted.
curl -X POST "$OPENSEND_API_URL/v1/automations/auto_teams/test" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "email": "ada@example.com"}'Runs
curl "$OPENSEND_API_URL/v1/automations/auto_welcome/runs?status=waiting" \ -H "Authorization: Bearer $OPENSEND_API_KEY"- Status
running- Meaning
- It is due to go on.
- Status
waiting- Meaning
- It is at a wait.
wakeAtsays until when.
- Status
completed- Meaning
- It reached the end of its path.
- Status
exited- Meaning
- It left early.
reasonsays why:exit_step,goal,unsubscribed,contact_deleted,automation_deleted.
- Status
failed- Meaning
- A step failed:
missing_variable,send_refused,step_failed.detailhas the sentence.
- Status
canceled- Meaning
- You cancelled it, or stopped the automation.
One run has the data that started it and what each step did.
curl "$OPENSEND_API_URL/v1/automations/auto_welcome/runs/run_01" \ -H "Authorization: Bearer $OPENSEND_API_KEY"Cancelling takes one person out. Emails already sent are not recalled.
curl -X POST "$OPENSEND_API_URL/v1/automations/auto_welcome/runs/run_02/cancel" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'A run that failed can be tried again once what broke it is fixed: a value that was missing is on the contact now, or the provider answers again. It goes on from the step that failed, on the version it entered with, and an email it failed to send is really sent this time. A run that did not fail is refused with run_not_failed.
curl -X POST "$OPENSEND_API_URL/v1/automations/auto_receipt/runs/run_03/retry" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'An automation answers with the same numbers added up: how many entered, how many are inside now, and for each step how many it reached, sent, and saw opened and clicked.
Define an event
An event needs no definition: a new name defines itself the first time it is sent. Defining it lets you fix the type of each value in its data.
curl -X POST "$OPENSEND_API_URL/v1/events" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "trial.started", "schema": { "plan": "string", "ends_at": "date" }}'- The types are
string,number,booleananddate. - A value that can be read as its type is converted:
"49"becomes49, and a date becomes an ISO 8601 time. event_data: a value does not fit. The message names it.
An event answers with the latest times it was sent and what each one set off.
curl "$OPENSEND_API_URL/v1/events/order.paid" \ -H "Authorization: Bearer $OPENSEND_API_KEY"Hear about runs
A webhook can ask for automation.entered and automation.finished, sent when a person enters and when their run ends, and for automation.step, sent by a webhook step.
Limits
- An automation takes up to 200 steps, and 1 MB in all. Keep long emails in templates.
- A wait is at most 365 days.
- The first step of a run is done while the event is answered. After that a schedule moves runs along once a minute, 50 at a time, so a step can start up to a minute after it is due.
- Automations can start each other through the mail they send. Such a chain stops after 3 links.