API Reference

Add Automation Step

POST /automations/:id/steps — append a step to a disabled automation.

POST/automations/:id/steps

Appends a step to an automation. The automation must be disabledstop or disable it first. Returns the created step.

Supported step types (see the Steps page for full config shapes):

  • [send_email](/docs/automations/send-email) — send a published template; config.template.id is required, with optional variables, from, subject, and reply_to.
  • [delay](/docs/automations/delay) — pause for a natural-language duration (e.g. "1 day"). Maximum 30 days.
  • [wait_for_event](/docs/automations/wait-for-event) — pause until event_name is received, with an optional timeout and filter_rule.
  • [condition](/docs/automations/condition) — branch on a rule (or an and/or group of rules) evaluated against event.* / contact.* data.
  • [contact_update](/docs/automations/contact-update) — update the contact's first_name, last_name, unsubscribed, or properties.
  • [contact_delete](/docs/automations/contact-delete) — delete the contact; config is an empty object {}.
  • [add_to_segment](/docs/automations/add-to-segment) — add the contact to a segment; requires config.segment_id.
Add a delay step
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.automations.addStep('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', { "type": "delay", "config": { "duration": "1 day" } });
console.log({ data, error });
Add a send_email step
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.automations.addStep('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', {
  "type": "send_email",
  "key": "welcome",
  "config": { "template": { "id": "34a080c9-b17d-4187-ad80-5af20266e535" } }
});
console.log({ data, error });

Response

{
  "id": "9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d",
  "key": "welcome",
  "type": "send_email",
  "position": 0,
  "config": { "template": { "id": "34a080c9-b17d-4187-ad80-5af20266e535" } }
}