ConceptsAutomations

Automations

Rules that run on their own in a Brainerce store. The model (event, trigger, filter, steps, actions, runs), live values versus facts, how a run ends, limits by plan, the safety model, and the four ways to build one.

An automation is a rule a store runs on its own: a trigger (something happened, or the clock struck), an optional filter (only some of those events), then steps (conditions, waits, lookups, and actions that change the store or message someone).

trigger  ->  filter  ->  steps
order.paid@1   total >= 500   [ add_customer_tags@1, add_order_tags@1 ]

Automations are a paid feature. FREE has none. PRO allows 10 active automations and 5,000 actions a month, GROWTH 25 and 50,000, ENTERPRISE is by agreement. See Limits and plans.

Not the same thing as the built-in email sequences. Abandoned-cart recovery, the welcome series and similar fixed flows are configured under Email. An automation is a rule you author. The two can overlap (see RECOVERY_EMAIL_ACTIVE below), and they do not share settings.

The model

Event

Every change an automation can react to is recorded as an event: a small, immutable snapshot of what happened. Events are written in the same database transaction as the change itself, so an automation never misses one and never sees a change that rolled back. An event has a type (order.paid), an entity (the order id), an origin (who made the change) and facts (a fixed set of fields about the change).

Trigger

A definition names one trigger by a versioned id, for example order.paid@1. Use the newest version of a trigger for new work (product.updated@2, not @1).

FamilyTriggers
Ordersorder.created@1, order.paid@1, order.cancelled@1, order.fulfilled@1, order.delivered@1, order.refunded@1, order.edited@1, order.field_set@1
Returnsreturn.requested@1, return.approved@1, return.declined@1, return.received@1, return.completed@1, return.cancelled@1
Customerscustomer.created@1, customer.updated@1, customer.tag_added@1, customer.marketing_consent_changed@1
Cartscheckout.abandoned@1
Productsproduct.created@1, product.updated@2 (with a non-empty fields list), product.metafield_changed@1 (needs a filter on the custom field definition id), inventory.stock_changed@1 (per variant), review.created@1
The clockschedule.fired@1 with schedule of hourly, daily, weekly or monthly, in the store time zone

The facts of each trigger, and the exact variables a text may print, are in the authoring guide (see Get the guide). Do not copy a fact path from memory: a path the trigger does not carry is rejected with a finding.

Origins

trigger.origins says which kinds of write may start a run. Send the same list the dashboard sends:

["USER", "API", "MCP", "ASSISTANT", "BULK", "IMPORT", "DUPLICATE", "SYSTEM", "AUTOMATION"]

Leave out RESTORE, MIGRATION and CLONE: copying a whole store is not a change, and would start every automation at once. SYSTEM covers sales, cancellations and restocks done by the platform itself, so an order automation that omits it never sees a storefront order. schedule.fired@1 must list SYSTEM.

Filter

trigger.filter is an optional group { "op": "all" | "any", "rules": [...] } evaluated against the event facts, and against live values (below). A rule is { "path", "op", "value" }. Number operators include eq, neq, gt, gte, lt, lte, plus crossed_below N and crossed_above N where the guide says so (stock and price on product.updated@2 and inventory.stock_changed@1). Text and list operators are listed per path in the guide.

A filter is also a safety device: five actions refuse to exist without one (see Safety model).

Steps

steps is an ordered list, at most 30 in total and 3 levels deep. Step types:

StepWhat it does
actionCalls one action contract (add_order_tags@1, send_internal_email@1, ...) with an input.
conditionwhen a rule group, then a list of steps, optional else. A false condition without an else ends the run as a success (see below).
waitParks the run for 5 minutes to 90 days. Top level only, at most 3 per definition.
mapLooks a value up in a table you write into the definition (at most 2,000 rows), for product custom fields.
fetchClock automations only. Reads a bounded list of orders, customers or products and publishes steps.<id>.ids, .count, .truncated (and .numbers for orders).
for_eachClock automations only, one per definition. Runs up to 5 actions once per fetched id (at most 200 items), each addressing the item as { "$ref": "loop.item" }.

Values in an action input are either literals or references: { "$ref": "event.entityId" }, { "$ref": "event.facts.customer.id" }, { "$ref": "steps.f1.ids" }. Which reference an action accepts for its target is fixed per action and trigger family; the validator names the exact path when you get it wrong.

Actions

Actions are versioned contracts (name@1). The families:

  • Orders: add_order_tags@1, remove_order_tags@1, mark_order_paid@1, cancel_order@1, set_order_hold@1, archive_order@1, set_order_field@1, and the bulk bulk_add_order_tags@1 / bulk_remove_order_tags@1 (clock only).
  • Customers: add_customer_tags@1, remove_customer_tags@1, send_customer_email@1 (a campaign-library template, kind marketing or order), create_customer_coupon@1, adjust_loyalty_points@1.
  • Products and stock: set_product_status@1, add_product_tags@1, remove_product_tags@1, add_product_to_category@1, remove_product_from_category@1, set_product_price@1, set_product_weight@1, set_product_metafield@1, adjust_stock@1, create_purchase_order@1 (a draft only).
  • Discounts: set_coupon_active@1, set_discount_rule_active@1.
  • Messages and integrations: notify_me@1 (a notice to the store's managers; a text that prints order.*, return.*, refund.*, cart.* or a fetched list reaches only managers with VIEW_ORDERS, one that prints customer.* only those with VIEW_CUSTOMERS, never a channel-restricted member, and approving it needs the same permission), send_internal_email@1 (to your own team members, never a customer; on the clock it can carry a report table), send_http_request@1 (through a saved HTTP connection).

Which actions run under which trigger is enforced by the validator (an order action under a product trigger is refused with ACTION_TRIGGER_UNSUPPORTED when you validate, not at run time). The per-action inputs, bounds and skip codes are in the guide topics product, inventory, order-actions, actions, messages and http-and-reports.

Facts versus live values

Two kinds of data reach a rule.

Facts are frozen when the event is recorded: event.facts.order.total, event.facts.customer.isFirstOrder, event.facts.stock. They describe the moment of the change. After a wait they are still the old values.

Live values start with current. and are read from the database when the step runs: current.order.financialStatus, current.cart.status, current.return.status, current.customer.totalSpent, current.product.stock. Use them whenever a rule must see today's state, most often in a condition after a wait. Live values:

  • work in condition steps and in the trigger filter, never in a $ref and never in a text;
  • are never stored in a run or a history row, never printed in a notice or email, never sent in an HTTP body, so a postcode or an email domain can decide a branch but cannot be read back;
  • read as empty when the column has no value, and every rule on an empty value is false;
  • exist for the entities the trigger carries (an order trigger gets current.order.* and current.customer.*, a cart trigger gets current.cart.*, a return trigger gets current.return.*, and so on). The guide topic live-values lists every column.

No name, email, phone number or address is ever in a fact. Texts may print only the variables of their own trigger family ({{order.number}}, {{product.name}}, {{steps.f1.count}}, plus {{store.name}}, {{now.date}}, {{now.time}} everywhere).

Runs and history

Each event that matches an active automation creates one run. A run steps through the definition on a queue, with a lease so a crashed worker cannot lose or double it. The dashboard shows a run's steps (id, status, error code, timings). Run history carries codes and counts only, never values: no event facts, no step inputs or outputs, no names or emails. In the SDK and MCP, getAutomationRun / get_automation_run return the same.

How a run ends

StatusMeaning
QUEUED, RUNNINGIn flight.
WAITINGParked by a wait step, by the backoff after a transient error, or by a rate hold.
SUCCEEDEDEvery step finished. A condition that was false and had no else also ends as SUCCEEDED with the outcome CONDITION_NOT_MET: the rule worked, there was nothing to do.
SKIPPEDA business skip: the run correctly decided not to act, and wrote nothing. The run carries the reason as a code.
FAILEDA permanent error (for example PERMISSION_REVOKED, TAG_NOT_FOUND, HTTP_RESPONSE_NOT_OK), or RETRIES_EXHAUSTED after 5 transient retries. Fix the cause, then retry the run from the dashboard.
NEEDS_REVIEWThe engine cannot tell whether the last step acted (an unknown outcome), the run lost its lease more than 5 times, or it sat queued or waiting for more than 7 days. Check the entity before retrying.
CANCELLEDCancelled by pausing the automation with the cancel option.

Common business skip codes, by action:

  • Entity gone or ineligible: ORDER_NOT_FOUND, CART_NOT_FOUND, PRODUCT_NOT_FOUND, CUSTOMER_NOT_FOUND (a guest order has no customer), SUBJECT_ERASED (a privacy erasure), SUPERSEDED (a newer event or a later change made this one stale).
  • Orders: ORDER_NOT_WRITABLE (for example cancel_order@1 never cancels a paid order, because it refunds nothing), ORDER_NOT_HOLDABLE, ORDER_NOT_ARCHIVABLE, ORDER_FIELD_NOT_FOUND, ORDER_FIELD_REFUSED.
  • Customer email: NO_CUSTOMER_EMAIL, NO_MARKETING_CONSENT, SUPPRESSED, FREQUENCY_CAP, TEMPLATE_NOT_FOUND, EMAILS_DISABLED, NO_POSTAL_ADDRESS, MARKETING_ON_HOLD, PROMOTIONAL_CONTENT, ORDER_FIELD_EMPTY, RECOVERY_EMAIL_ACTIVE (the store's own abandoned-checkout recovery emails are on, so a second reminder would be sent).
  • Stock and purchasing: STOCK_NOT_TRACKED, STOCK_PER_WAREHOUSE, STOCK_NOT_WRITABLE, PO_NO_SUPPLIER, PO_SUPPLIER_NOT_FOUND, PO_ALREADY_OPEN, PO_ITEM_NOT_ORDERABLE.
  • Other: LOYALTY_NOT_ACTIVE, LOYALTY_NOT_MEMBER, COUPON_NOT_FOUND, COUPON_EXPIRED, DISCOUNT_RULE_NOT_FOUND, HTTP_CONNECTION_NOT_FOUND, HTTP_CONNECTION_DISABLED, NO_RECIPIENTS, NOTHING_TO_REPORT.
  • Plan: PLAN_NOT_INCLUDED (the store dropped below PRO) and PLAN_QUOTA_REACHED (this billing cycle's actions are used up). Both end the whole run before any step.

A skip that means the automation itself is misconfigured (a deleted template, switched-off emails, a paused HTTP connection, a missing supplier) is reported to the store's people once a day. A per-record skip (no consent, no address) never is: it would be noise.

Inside a for_each, an item that no longer matches or cannot be reached is skipped and the loop continues with the next one. A missing template or switched-off emails stops the loop at the first item and the run ends SKIPPED. Items already done stay done. A run with a loop cannot be retried, because people already reached would be reached again; the next scheduled run starts from a fresh list.

Limits and plans

PlanActive automationsActions per billing month
FREE00
PRO105,000
GROWTH2550,000
ENTERPRISEby agreementby agreement

The action cap is a soft cap read when a run starts: a run already going may finish past it. A store that drops below PRO keeps its automations and drafts, but its runs end SKIPPED with PLAN_NOT_INCLUDED.

Engine bounds that apply to every plan (AUTOMATION_LIMITS in @brainerce/types):

LimitValue
Automations per store, not archived50
Active automations per trigger type10
Versions per automation100
Drafts from API keys, MCP and the assistant50 per store per rolling 24 hours (QUOTA_EXCEEDED)
Steps per definition, nesting depth30, 3
Definition size262,144 bytes
Name length200 characters
wait steps, one wait3 per definition, 5 minutes to 90 days
fetch steps, items per fetch2 per definition, 1 to 200
Orders in a fetch that feeds a bulk tag50
for_each1 per definition, 5 actions, 200 items
Actions per hour2,000 per automation, 10,000 per store
Chain of automationsstops at 3 links

Over the hourly rate the run waits (WAITING) until the window ends instead of failing.

Safety model

  • Approving is a human act. Creating a version never runs anything. A signed-in dashboard user reviews the exact definition, approves it and turns it on. An API key gets 403 APPROVAL_REQUIRES_DASHBOARD_USER on approve and 403 ACTIVATION_REQUIRES_DASHBOARD_USER on activate and switch-version, whatever its scopes. There is no override and no scope for it. An AI tool gets the same unless the merchant granted it the separate automations:activate scope (on top of automations:read and automations:write) on a signed-in connection, and then only activate_automation works, only for low-risk actions (tags, and notices or emails to the store's own team): see Turning one on from an AI client. Resume, switch-version and un-archive stay dashboard-only for everyone.
  • The approver is the identity the runs act as. At approval the permissions the actions need are bound to that person. If they later lose a permission, the run fails with PERMISSION_REVOKED and the automation is paused automatically. A person limited to some sales channels cannot approve.
  • Versions are immutable and approval binds to a hash. An edit is a new version. The active version keeps running until a person approves the new one and switches to it. Approval is tied to the definitionHash the approver saw (409 DEFINITION_HASH_MISMATCH if it changed under them).
  • Guarded actions need a filter. cancel_order@1, set_order_hold@1, archive_order@1, adjust_stock@1 and create_purchase_order@1 must sit under a trigger filter with at least one rule, or under a condition step. Otherwise the definition is refused with ACTION_NEEDS_GUARD, because they would run on every event of the trigger.
  • No automation loops. An automation never runs on its own change. A change made by an automation carries the origin AUTOMATION and a chain depth, and the relay blocks events at chain depth 3.
  • No personal data in facts or history. Facts hold ids, counts, enums and totals, never a name, email, phone or address. Live values are conditions only. Texts cannot print a field the trigger family does not offer.
  • Customer email respects consent. send_customer_email@1 with kind: "marketing" needs the customer's marketing consent at the moment it sends, carries the unsubscribe link, honours the suppression list and a per-customer frequency cap (frequencyDays, 1 to 90: the cap reads run history, which is kept 90 days). An email about an order that reads like an offer is skipped (PROMOTIONAL_CONTENT).
  • HTTP connections are created in the dashboard only. send_http_request@1 names a saved connection by id, never a URL or a secret. The connection holds the address, header values and a signing secret; the definition adds only a relative path and a body.
  • Money does not move. No action refunds. cancel_order@1 skips a paid order. mark_order_paid@1 books a manual payment like the dashboard button and collects nothing.

Four ways to build one

  1. The dashboard editor. Settings, then Automations. Pick a trigger (When), optionally narrow it (Filter), then add steps (Then). Test on an order (or customer, cart, product, Test now for the clock) shows what the automation would do on a real record and writes and sends nothing. Save, then Approve and turn on.
  2. The admin MCP server. Twelve tools under the automations:read and automations:write scopes. Drafts only. See Automations on the Admin MCP.
  3. The REST API and the SDK. An API key with the automations scopes, routes under /api/stores/{storeId}/automations. See Automations REST API and Automations in the SDK.
  4. BOBO, the in-dashboard assistant. It drafts from a plain-language request, tests, and hands the draft to the merchant. Drafts only: it cannot approve or turn on.

All four create the same objects and run the same validator. Ways 2 to 4 count against the 50 drafts per 24 hours.

The flow for an integration or an AI agent

  1. Get the guide. Once, before writing a definition.
  2. Validate. Fix every finding (code and path) until ok is true.
  3. Test on a real record. Order, customer, product or cart of the store. It writes nothing.
  4. Save a draft. A new automation, or a new version of an existing one.
  5. The merchant approves in the dashboard. Tell them so; never say the automation is live, unless activate_automation just succeeded (only for tag and team-notice automations, only with the automations:activate scope).

Get the guide

get_automation_guide (MCP) and GET /api/stores/{storeId}/automations/guide (REST, scope automations:read) return the same text, the single source of truth for what a definition may contain. With no topic you get an index and the basics. Ask for the topic you need, or all (about 40 KB) when a definition spans several families.

Topic idCovers
basicsThe shape of a definition, origins, steps, map, set_product_metafield@1.
productproduct.updated@2 and the product actions.
reviewsreview.created@1.
inventoryinventory.stock_changed@1, adjust_stock@1, create_purchase_order@1.
order-actionsadjust_loyalty_points@1, set_order_hold@1, archive_order@1, set_order_field@1.
live-valuesEvery current.* column.
triggersOrder, return, refund, customer and cart triggers and their facts.
clockschedule.fired@1, fetch, bulk tag actions, for_each.
factsOrder and customer facts, the variables a text may use per trigger.
actionswait, order and customer tags, mark_order_paid@1, cancel_order@1, coupons on or off.
messagesTeam and customer email, order fields in a text, discount rules.
http-and-reportssend_http_request@1, weight, personal coupons, report tables, every text variable.

Worked examples

Each recipe is a complete definition that passes the validator, with the exact tool calls to create it: