Skip to content
TTopMail

Automations

Create, manage, and trigger automations programmatically. Build complete workflows with steps via the API or manage them individually.

POST
/automations

Create a new automation with optional inline steps.

Request Body

NameTypeRequiredDescription
namestringRequiredName for the automation.
trigger_typestringRequiredTrigger type (e.g. "signup", "purchase", "tag_added", "custom"). See trigger types table below.
trigger_configobjectOptionalConfiguration for the trigger (e.g. list ID, tag name). Defaults to {}.
stepsarrayOptionalArray of steps to create inline. Each step has step_type, optional config, and optional position.

Inline Steps

Steps can be provided inline during creation or added separately via the POST /automations/:id/steps endpoint. New automations always start in draft status.

curl -X POST https://api.topmail.so/api/v1/automations \
-H "Authorization: Bearer tm_live_abc123" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Series",
"trigger_type": "signup",
"steps": [
{ "step_type": "email", "config": { "templateId": "tpl_abc", "subject": "Welcome!" } },
{ "step_type": "delay", "config": { "duration": 2, "unit": "days" } },
{ "step_type": "email", "config": { "templateId": "tpl_def", "subject": "Getting Started" } }
]
}'
GET
/automations

List all automations with optional status filtering.

Query Parameters

NameTypeRequiredDescription
statusstringOptionalFilter by status: "draft", "active", or "paused".
limitintegerOptionalNumber of automations to return (default: 100, max: 1000).
offsetintegerOptionalNumber of automations to skip for pagination (default: 0).
curl "https://api.topmail.so/api/v1/automations?status=active&limit=10" \
-H "Authorization: Bearer tm_live_abc123"
GET
/automations/:id

Retrieve a single automation with steps and run count.

curl https://api.topmail.so/api/v1/automations/AUTOMATION_ID \
-H "Authorization: Bearer tm_live_abc123"
PATCH
/automations/:id

Update an automation name or status.

Request Body

NameTypeRequiredDescription
namestringOptionalUpdated automation name.
statusstringOptionalSet to "active" or "paused". See status lifecycle below.

Status Lifecycle

Automations follow a strict status lifecycle: draftactive (requires at least one step). Active automations can be toggled: activepaused.

curl -X PATCH https://api.topmail.so/api/v1/automations/AUTOMATION_ID \
-H "Authorization: Bearer tm_live_abc123" \
-H "Content-Type: application/json" \
-d '{"status": "paused"}'
DELETE
/automations/:id

Delete an automation (soft delete).

curl -X DELETE https://api.topmail.so/api/v1/automations/AUTOMATION_ID \
-H "Authorization: Bearer tm_live_abc123"
POST
/automations/:id/steps

Add a step to an automation.

Request Body

NameTypeRequiredDescription
step_typestringRequiredType of step to add. See step types below.
configobjectOptionalStep configuration. Defaults are provided if omitted.
positionintegerOptionalPosition to insert the step (0-indexed). Appends to end if omitted.

Step Types

TypeDescription
emailSend an email using a template
smsSend an SMS message
pushSend a push notification
delayWait for a specified duration
conditionBranch based on a contact field condition
actionPerform an action (add/remove from list, update attribute, webhook)
tagAdd or remove a tag from the contact
trigger_splitSplit contacts into branches based on a field
add_to_listAdd the contact to a list
remove_from_listRemove the contact from a list
update_attributeUpdate a contact attribute
webhookSend a webhook to an external URL
wait_for_eventWait for a specific event before continuing
move_to_flowMove the contact to another automation

Step Config Reference

Each step type accepts specific config fields. Defaults are provided if config is omitted.

emaildefault: { templateId: null, subject: "", previewText: "" }
templateIdstring | nullTemplate ID to use for the email content.
subjectstringEmail subject line (required).
previewTextstringPreview text shown in inbox.
delaydefault: { duration: 1, unit: "days" }
durationnumberHow long to wait.
unitstring"minutes", "hours", "days", or "weeks".
conditiondefault: { field: "", operator: "equals", value: "" }
fieldstringContact field to evaluate (e.g. "email", "first_name", or a custom attribute).
operatorstring"equals", "not_equals", "contains", "gt", "lt", "gte", or "lte".
valuestring | number | booleanValue to compare against.
trueBranchStepIdstring | nullStep ID to jump to if condition is true.
falseBranchStepIdstring | nullStep ID to jump to if condition is false.
tagdefault: { action: "add", tagName: "" }
actionstring"add" or "remove".
tagNamestringName of the tag.
add_to_list / remove_from_listdefault: { listId: null }
listIdstringThe list ID to add/remove the contact from.
update_attributedefault: { attributeName: "", attributeValue: "" }
attributeNamestringContact attribute name to update.
attributeValuestringValue to set.
webhookdefault: { url: "", method: "POST", headers: {} }
urlstringWebhook URL (required).
methodstring"GET", "POST", "PUT", or "PATCH".
headersobjectCustom headers as key-value pairs.
bodyobject | stringRequest body.
wait_for_eventdefault: { eventType: "email_opened", timeoutDays: 7, timeoutAction: "continue" }
eventTypestring"email_opened", "email_clicked", "purchase", or "page_viewed".
timeoutDaysnumberDays to wait before timing out.
timeoutActionstring"continue" (proceed to next step), "skip" (skip next step), or "branch" (jump to timeoutBranch).
move_to_flowdefault: { targetFlowId: "", exitCurrentFlow: true }
targetFlowIdstringTarget automation ID to move the contact to.
exitCurrentFlowbooleanIf true, exit current automation. If false, run both in parallel.
curl -X POST https://api.topmail.so/api/v1/automations/AUTOMATION_ID/steps \
-H "Authorization: Bearer tm_live_abc123" \
-H "Content-Type: application/json" \
-d '{
"step_type": "delay",
"config": { "duration": 3, "unit": "days" },
"position": 1
}'
PATCH
/automations/:id/steps/:stepId

Update a step's type or configuration.

Request Body

NameTypeRequiredDescription
step_typestringOptionalNew step type.
configobjectOptionalUpdated step configuration.
curl -X PATCH https://api.topmail.so/api/v1/automations/AUTOMATION_ID/steps/STEP_ID \
-H "Authorization: Bearer tm_live_abc123" \
-H "Content-Type: application/json" \
-d '{ "config": { "duration": 5, "unit": "days" } }'
DELETE
/automations/:id/steps/:stepId

Remove a step from an automation.

curl -X DELETE https://api.topmail.so/api/v1/automations/AUTOMATION_ID/steps/STEP_ID \
-H "Authorization: Bearer tm_live_abc123"
POST
/automations/:id/trigger

Manually trigger an automation for a specific contact.

Request Body

NameTypeRequiredDescription
contact_idstring (UUID)OptionalContact ID to trigger for. Provide either contact_id or email.
emailstringOptionalContact email to trigger for. Provide either contact_id or email.
trigger_dataobjectOptionalAdditional data to pass to the automation run.
curl -X POST https://api.topmail.so/api/v1/automations/AUTOMATION_ID/trigger \
-H "Authorization: Bearer tm_live_abc123" \
-H "Content-Type: application/json" \
-d '{
"contact_id": "c1a2b3c4-d5e6-7890-abcd-ef1234567890",
"trigger_data": {"source": "api", "plan": "pro"}
}'

Trigger Types

Automations support the following trigger types. The API trigger endpoint works with any automation regardless of its configured trigger type.

TypeDescription
signupContact signs up or is created
tag_addedTag is assigned to a contact
added_to_listContact is added to a list
email_openContact opens an email
email_clickContact clicks a link in an email
product_viewedContact views a product (tracking)
purchaseContact completes a purchase
customCustom event triggered via API
GET
/automations/:id/runs

List runs for an automation with optional status filtering.

Query Parameters

NameTypeRequiredDescription
statusstringOptionalFilter by run status: "active", "completed", "failed", or "paused".
limitintegerOptionalNumber of runs to return (default: 100, max: 1000).
offsetintegerOptionalNumber of runs to skip for pagination (default: 0).
curl "https://api.topmail.so/api/v1/automations/AUTOMATION_ID/runs?status=completed&limit=20" \
-H "Authorization: Bearer tm_live_abc123"
Developer Docs - TopMail | TopMail