Build automations with AI
Describe a journey to Unit, Claude, ChatGPT or Cursor and get a validated draft: prompts that work and the rules every agent follows.
Say what should happen in plain words. The agent finds your templates, sender and events, builds a draft, checks it, dry-runs it for a contact and tells you what each person would get. It publishes only when you say so.
In the dashboard: Unit
Open Unit and describe the journey. Unit has every automation tool, reads the readiness report before it offers to publish, and every step that can send (publish, resume, enroll, retry, skip a wait) shows you an Approve card first.
From Claude, ChatGPT, Cursor or any MCP client
Connect the Unitpost MCP server (see MCP) with a key or sign-in that has automations:read and automations:write, templates:read, domains:read, and segments:read or topics:read for the journeys that use them, plus automations:publish if the agent may take journeys live and events:emit if it may send test events. Add automations to the URL's toolsets (?toolsets=default,automations) for dry runs, your event list and the publish preview. The server gives the agent the build order in its instructions, a plan_automation prompt, and four resources it can read:
| Resource | What it holds |
|---|---|
unitpost://automations/guide | The recipe, the guards with their current numbers, and complete examples |
unitpost://automations/blocks | Every block's settings, paths out and outputs |
unitpost://automations/paths | The data paths conditions and variables read |
unitpost://automations/errors | Every validation code with its fix, publish refusals, run states and pause reasons |
Prompts that work
Say what starts it, what each person gets, when, and what stops it. Name your templates, segments and events if you have them. These each produce a draft that validates:
- "Send new signups our welcome email right away and getting-started tips two days later."
- "When someone leaves items in their cart, remind them after 4 hours and again the next day, but stop as soon as they order."
- "When a customer emails us, reply that we got their message and will answer within a day."
- "When an appointment is booked, text the customer a reminder at the next 10am in their time zone."
- "Email trial users 3 days before their trial ends (our app keeps trial_ends_at on the contact), at 9am their time, unless they upgrade first."
- "Win back the people our nightly job adds to our Win-back list: one email, and if they don't click within a week, a last-chance email. Skip anyone another journey already emailed that day."
To fix one: "My Abandoned cart automation keeps failing, can you fix it?" The agent reads the failed runs, names the cause, fixes the draft and asks before publishing or retrying. The full bodies are on Automation examples.
The order every agent follows
| Step | MCP tool | REST |
|---|---|---|
| Look before you build. Read the block catalog, the blueprints and the custom events the backend already sends (with their payload keys). Find the real template, topic or segment ids and a sender on a verified domain. Never invent an id, a sender or an event name. | automations_catalog, automations_blueprints, event_definitions_list, email_templates_list, email_domains_list | GET /automations/catalog, GET /automations/blueprints, GET /events/definitions |
Save a draft. Start from a blueprint when one fits. Otherwise send the whole graph in one create call. Leave re-entry to the trigger's default unless the person asked for something else. On a custom-event trigger, runs per person at once is the person's call (readiness asks, runs_per_person): ask whether an event for someone already in the journey should start its own run or be ignored, and set maxConcurrentRunsPerSubject from their answer (1 for one run per person; up to 10 for a run per event, with each wait and the goal matched to {{event.data.<key>}}). For a once-ever journey (a welcome, onboarding or trial series) also set reEntry: "never". Never set it on your own to make the item go away. A policy read back over the API or MCP lists the fields that came from defaults in policy_defaults: leave those out when you send the policy back, or they become choices. A draft never sends anything, and edits replace the graph and the policy whole. | automations_create, automations_update | POST /automations, PATCH /automations/{id} |
Validate until clean. Validate, fix every error by its node_id and path, and validate again until ok is true (ok is false only with errors). You can check a proposed graph before saving it. Then read readiness: blockers, what the person or their developer still has to provide, and what will surprise them. Relay every needs_input and heads_up item to the person, one line each and counted, before you publish: they are the facts they agree to. A needs_input item owned by the user is a question (runs_per_person: one run per person, or one per event?): ask it, set what they answer, and validate again before publishing. | automations_validate | POST /automations/{id}/validate |
| Dry run for one contact. Walk the draft for a real or made-up contact: which messages they would get, when, and which branch they would take. Nothing is sent. | automations_simulate | POST /automations/{id}/simulate |
| Preview an enrollment (manual trigger only). For a manual-enrollment automation, check whether a contact can be enrolled now and which rule would stop it, before enrolling anyone. | automation_runs_enroll_preview | POST /automations/{id}/runs/preview |
Publish only when asked. Go live only when the person asks and readiness.ready is true: only a blocker refuses a publish, needs_input and heads_up items don't. Read the publish preview first when people are mid-journey (it doesn't repeat readiness: validate first). For a segment or topic trigger, ?backfill=true on the preview says how many people already in it a backfill would start; ask, then pass that count as backfill_count. Publishing needs the automations:publish capability. | automations_publish_preview, automations_publish | GET /automations/{id}/publish, POST /automations/{id}/publish |
| Watch the first runs. Read the runs to see who entered and why someone didn't. A run's step timeline names the block it stopped at and the reason. | automation_runs_list, automation_runs_get | GET /automations/{id}/runs, GET /automations/runs/{run_id} |
Ask before anything that sends
Ask the person before anything that can send: publishing, resuming, enrolling, retrying runs, skipping a wait, and emitting a test event. Drafts, validation and dry runs never send. On MCP these are automations_publish, automations_resume, automation_runs_enroll, automation_runs_retry, automation_runs_retry_failed, automation_runs_skip_wait, events_emit.
Give your coding agent the rules
If an agent works on your backend (the code that sends your events), paste this into your repo's AGENTS.md or CLAUDE.md. The agent skill carries the same rules.
## Unitpost automations
- Build and change Unitpost automations through the Unitpost MCP server (`https://mcp.unitpost.com/mcp?toolsets=default,automations`) or the REST API (`https://www.unitpost.com/api/v1`). Never guess a template, segment, topic, sender or event name: read them first.
- Order: `automations_catalog` → `automations_blueprints` → `event_definitions_list` → `automations_create` → `automations_validate` → `automations_simulate` → `automations_publish`. Fix every validation error by its `node_id` and `path`, and repeat every `heads_up` and readiness item to me.
- Ask the person before anything that can send: publishing, resuming, enrolling, retrying runs, skipping a wait, and emitting a test event. Drafts, validation and dry runs never send.
- Our backend starts journeys with `POST /v1/events` (`{ name, email, data, idempotency_key }`). Use the exact event name the automation listens for, lowercase and dot separated (`cart.updated`). An email that isn't a contact yet becomes one when a journey needs it, unless the event says `create_contact: false` (send that for guests).
- Guards already on, don't rebuild them: an automation never starts from its own sends, and a chain of automations stops after 5 hops; auto-replies, bounces and mail marked Precedence bulk or list never start or resume an email-received run (`ignoreAutomaticMail`, on by default); at most 10 runs of one automation per contact per hour, and one live run per contact at a time (a custom event whose waits, goal or exit rule match the run's own event data: up to 10; on a custom event the person chooses, readiness `runs_per_person`); someone every message would skip by consent (unsubscribed, not on the topic) doesn't enter: no run, not billed (`no_consent`); any other action starts the run as usual; a frequency cap of 3 marketing emails per contact per 24 hours, counted across all automations (over-cap sends skip; `maxSendsPerSubjectPerDay` sets the cap one automation's sends check against that same all-automation count; transactional is never capped); waits and wait-for-event timeouts up to 365 days; runs end after 90 days unless `maxRunDuration` says otherwise (at most 365 days); 50 action steps per run (publish refuses a longer path) and 100 blocks per automation; 10,000 live runs per automation by default; a block that fails 3 runs in a row pauses the automation and emails the owners (`onError: pause_run`, the default); deleting, archiving or renaming something a live automation uses, or a template edit that breaks its step, is refused (`409 resource_in_use`, each automation in `error.details`).
- Keys: drafts need `automations:write`, going live `automations:publish`, sending events `events:emit`. Read the key from `UNITPOST_API_KEY`; never put it in code or a client bundle.
- Guides, block reference and examples: https://www.unitpost.com/guides/automations. API reference: https://www.unitpost.com/docs/automations