Create Automation
POST /automations — create an entire automation flow in a single request.
/automationsCreates an automation. The trigger is defined as the first item in the steps array with type: "trigger" (its config.event_name is the event that starts a run); a top-level trigger string is also accepted.
namestringrequiredThe name of the automation.
statusstringoptionalThe status of the automation. One of enabled or disabled. Defaults to disabled. Creating with enabled requires at least one step besides the trigger.
domainstringrequiredThe sending domain this automation belongs to (one of your domains, e.g. yourdomain.com). Only events sent with the same domain trigger it.
stepsarrayoptionalThe steps that compose the automation graph. Each step is { key, type, config }; the first item with type: "trigger" defines the trigger.
connectionsarrayoptionalThe connections between steps. Each is { from, to, type }, where from/to are step keys and type is one of default, condition_met, condition_not_met, event_received, or timeout. Cyclic graphs are rejected.
triggerstringoptionalOptional alternative to a trigger step — the event name that starts the automation, as a plain string.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.automations.create({
"name": "Welcome series",
"domain": "yourdomain.com",
"steps": [
{
"key": "start",
"type": "trigger",
"config": { "event_name": "user.created" }
},
{
"key": "welcome",
"type": "send_email",
"config": {
"template": { "id": "34a080c9-b17d-4187-ad80-5af20266e535" }
}
}
],
"connections": [
{ "from": "start", "to": "welcome" }
]
});
console.log({ data, error });Response
Returns the full automation object (HTTP 201). The first entry in steps is the trigger step (with its key preserved), followed by the executable steps.
{
"object": "automation",
"id": "c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd",
"audience_id": "aud_3b1c...",
"domain": "yourdomain.com",
"name": "Welcome series",
"trigger": "user.created",
"status": "disabled",
"steps": [
{
"key": "start",
"type": "trigger",
"config": { "event_name": "user.created" }
},
{
"id": "9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d",
"key": "welcome",
"type": "send_email",
"position": 0,
"config": {
"template": { "id": "34a080c9-b17d-4187-ad80-5af20266e535" }
}
}
],
"connections": [
{ "from": "start", "to": "welcome", "type": "default" }
],
"created_at": "2026-06-23T10:00:00.000Z",
"updated_at": "2026-06-23T10:00:00.000Z"
}