CRM automations (web, API and MCP)

Invariant: an organization should admit each event once per workflow version, keep CRM effects and asynchronous staging in that event's transaction, stop recursive or excessive runs, and retain an organization-scoped account of the outcome.

automations.enabled defaults ON. An organization entitlement override of false stops new admission and hides the routes and MCP tools. crm.enabled must also be on. Each workflow has an independent enabled kill switch. API keys additionally require the existing crm.api.enabled gate and CRM org scope. Reading needs crm:read; authoring needs crm:edit. Execution rechecks the current author's membership and permissions under the role ceiling that approved this workflow version. Creating or editing with a capped API key retains that ceiling for lifecycle expansion, dry-run and delivery. A triggering caller supplies the event; its credentials do not become the workflow's authority. Workflows are user-owned configurations; editing reassigns the author and the approving ceiling. Task creation also needs crm:create, including dry-run and lifecycle-expanded tasks.

Use /v1/orgs/{orgId}/automations to list (GET) or create (POST), /{workflowId} to update (PATCH with expectedVersion), /{workflowId}/enable to stop or enable (POST with enabled), and /{workflowId}/runs to read run history in 1–100-entry pages (GET, default 50; pass nextCursor as cursor to read older runs). MCP exposes automation_list, automation_create, automation_update, automation_enable, and automation_runs through these same routes. Run pages return runs and nextCursor; an empty terminal page returns null. Cursors belong to one org/workflow, and SQL compares full timestamp precision.

PATCH preserves every omitted field, including enabled, dryRun and conditions. Creation defaults do not apply to edits. Configuration creation, edits and enable/stop changes record an audit event in the same transaction; an audit failure rolls back the configuration change.

{
  "name": "Label a new lead",
  "trigger": "contact_created",
  "conditions": [{"kind": "field", "key": "firstName", "operator": "contains", "value": "Pat"}],
  "actions": [{"kind": "set_field", "key": "title", "value": "Review new lead"}],
  "dryRun": true
}

Triggers: manual (Started by hand (Run now or Test on a record)) starts a workflow manually on one chosen record; webhook_received (signed inbound requests; see inbound webhook triggers), contact_created, tag_added, tag_removed, record_updated, deal_stage_changed, form_submitted, appointment_booked, reply_received, and lifecycle_stage. These subscribe to existing writer seams. Form submissions require a CRM mapping; bookings require CRM invitee linkage; distinct inbound reply IDs remain distinct and replayed IDs coalesce. This engine does not create new provider event sources.

Conditions are ANDed: field (built-in or custom key), tag (id/key/name or boolean presence using key), stage (event destination, deal stage or legacy lifecycle; resumed lifecycle events use their bound instance’s current stage), and lead_level (custom field key, default lead_level). Operators are case-sensitive equals, contains, and in (array operand). Missing fields fail; false tag presence can match false. Conditions use typed comparisons. The HTTP, code and set_data nodes additionally support the bounded data model below.

Actions: add_tag/remove_tag (tagId); set_field (key, value); create_task (title, ownerUserId, optional dueInMinutes); move_deal_stage (stageId, optional lostReason, needs crm:change_stage); assign_owner (userId); notify_member (userId, title, in-app only); webhook_out (endpointId); lifecycle_actions. Field writes reuse typed CRM services; generic writes cannot alter consent/protection flags. Taxonomy, member and endpoint references must belong to the org. The ownerUserId field alias uses the same member validation as assign_owner; null clears an owner on contacts, companies and deals. Stage actions apply to deals only.

lifecycle_actions reads the instance's pinned definition and selects actions whose trigger is its current stage or on_enter:<stage>. It executes only the supported actions above and refuses recursive/unknown actions. Existing stored lifecycle actions stay inert until an explicit workflow requests them.

webhook_out actions enqueue through the existing signed dispatcher: previously registered endpoint only, existing CRM contact/company event subscription, no arbitrary URL or persona endpoint, IDs-only payload. Existing SSRF, signing, registrant and CRM webhook gates still apply. The dispatcher rechecks workflow/org switches, current version and author at delivery. A step is queued until the delivery log (the returned deliveryId) confirms the transport result. The separate http_request node supports public HTTPS requests under its own safety checks.

Limits: 100 workflows/org, 20 configured actions (50 after lifecycle expansion), depth 3, 10 admitted runs per record/workflow/hour across versions, and 1,000 admitted runs/org/hour. Nonblocking transaction try-locks reserve individual quota slots; run rows retain those reservations for the rolling hour after commit. Execution does not hold an org-wide lock while CRM actions run. Admission requires the application's READ COMMITTED isolation; stronger snapshots cannot safely recheck slots and fail closed. Idempotency is (org, workflow, version, eventId). Skipped runs name max_depth, record_hour_limit, org_hour_limit, or conditions_not_met. Failed actions roll back the entire action batch; step history names rolled_back, failed, and not_started. Error logs store a code without ORM messages or bound values. Admission faults roll back the subscriber's savepoint and preserve the source CRM write.

Dry-run records planned steps and changes no CRM, task, notification or delivery data. A source transaction's rollback also rolls back its run history.

draft_email (subject, body, ownerUserId) adds a planned outbound email to the contact timeline for a person to review and send, and an in-app notification. Deal events use the primary contact and link the draft to both records. A suppressed contact or email address receives no draft. Draft creation also requires crm:create. Supported merge fields are firstName, lastName, fullName, email, dealTitle, and orgName; {{firstName|there}} supplies a fallback for a blank value.

wait accepts positive integral days, hours, and/or minutes, plus optional cancelOnReply (default true). A workflow may have up to five waits totaling at most 365 days, each followed by another action. Waits cannot coexist with lifecycle expansion, whose positions depend on the current stage. Live runs persist a waiting row; dry runs only record a planned wait and continue previewing subsequent actions. Paused and cancelled admitted runs still consume hourly quota.

POST /v1/cron/run-automation-waits uses the existing cron token gate. Each due wait is claimed and resumed in one transaction. Resumption checks current organization switches, workflow version, enablement, author permissions and record conditions; later actions run only if these still hold. Editing or stopping a workflow cancels its paused runs. Replies and opt-outs cancel matching contact/deal waits unless cancelOnReply is false. Each resumed segment rolls back its own failed effects; previously committed queued webhook steps retain their delivery eligibility under the existing dispatcher checks.

The preserved scheduler cadence is every five minutes (*/5 * * * *), authenticated POST /v1/cron/run-automation-waits, timeout 120 seconds. The endpoint handles at most 200 due waits per sweep. Overlapping sweeps are supported; a committed pause survives process exit and the next process reads the same continuation. Do not infer activation from the endpoint or the legacy scheduler declarations. The release owner must bind this path to the actual supported scheduler, verify its runtime identity/token and read back a controlled wait/resume journey. The documented host wrapper contract is run-cron.sh /v1/cron/run-automation-waits 120; current self-host scheduler activation is a separate integration responsibility. No daemon or production scheduler changes are included here.

CRM navigation exposes Automations at /o/{orgSlug}/crm/automations. The page lists saved workflows and correlated run/step history, and authors sequential definitions through the builder described below. It replaces the fixed new-lead task installation control. The builder exposes waits and planned email drafts; existing Routines, Payments and Conversations remain available.

The page stops a workflow with PATCH { expectedVersion, enabled: false }. This exact stop-only request needs the existing edit authority and matching version, increments the version and audits atomically, and preserves the creator, author ceiling and workflow specification. Mixed edits or enabling still require full authoring validation. Unknown write outcomes are read back without retry; controls stay locked until reload/review. Earlier browser qualification covers the shipped task-only dry/live path, edit-only Stop, reload, stale versions and interrupted responses. Dedicated builder qualification extends that evidence to rendered definition authoring; neither certifies an arbitrary graph editor or connector system.

Sequential workflow builder

The Automations page now has a Create workflow authoring surface and Edit workflow on saved definitions. Choose an available event, schedule or inbound webhook trigger, add up to 30 typed AND conditions and configure up to 20 ordered actions. Use Move up/down controls to change action order; all controls work with a keyboard. Review shows the trigger, conditions, action configuration and saved mode before Save. Editing pins the opened version and submits expectedVersion; a 409 retains the draft and reads the current stored list. Cancel editing and reopen the stored workflow to resolve a conflict deliberately.

Member, tag, deal-stage and registered webhook choices come from the existing organization-scoped reads. Missing/deleted/unavailable selections block saving; failed lookups explain which choices could not load. Field operands distinguish text, finite numbers, booleans, null and bounded scalar lists; in requires a list. Field keys retain the existing built-in/custom-field contract, including record applicability and server validation. Tag presence conditions use the selected tag and a boolean value. Stored tag names and internal keys survive unrelated edits; a saved identity absent from the current id/name lookup is explicitly labeled, rather than guessed or silently replaced. Stage conditions can select a deal stage or name a lifecycle stage key.

Every newly authored workflow is explicitly stopped and in dry run, overriding the API's less conservative creation defaults. Start and mode changes remain separate deliberate actions. Existing stored definitions keep their enabled/mode state while editing. General authoring requires crm:edit; task actions additionally require crm:create, stage actions require crm:change_stage, and webhook actions require org:manage_integrations. Those action choices are unavailable without their grant; saved restricted actions remain visible for removal or replacement with a clear validation message. An edit-only member retains Stop without needing create authority and can author non-task workflows; read-only and foreign-organization users cannot author. The server remains authoritative for entitlements, references, current authorship and permission ceilings. Writes share a synchronous guard, never retry automatically, and an unknown transport outcome locks further writes until reload/review even after a successful reconciliation read.

Signed webhooks select an enabled, registered, non-persona CRM endpoint. No URL entry, registration or test-send action is exposed. A dry run records planned steps without dispatching; live compatibility still depends on the endpoint's exact event subscription/filters and current authority. Run history continues to distinguish planned, queued and applied outcomes using the stored step rows. There is no new execution engine, arbitrary branching, parallelism, connector marketplace or email/SMS sending capability. Existing Routines remain distinct.

The builder uses canonical wait limits and requires a continuation. Recipe installation retains its existing admission checks.

Stop one run

The run inspector at /o/{orgSlug}/crm/automations/{workflowId}/runs/{runId} offers Stop this run to a caller with CRM edit access. Supply a reason and confirm. REST uses POST /v1/orgs/{orgId}/automations/{workflowId}/runs/{runId}/cancel; MCP uses automation_run_cancel in the existing automation group. API keys need CRM and write scopes; runner keys are refused. The result is { run, changed }; repeated calls on terminal runs return changed: false and reconcile queued remote recall. The workflow and unrelated runs remain unchanged. Delivered work may finish externally and cannot continue this run.

Schedule and inbound webhook triggers are registered alongside the existing event triggers. Configure their dedicated panels in the workflow editor; the automation entitlement and CRM permissions apply to each.

Reference

Run now and retry

Run a workflow by hand with the manual Started by hand trigger: Test on a record (dry run) or Run now then Confirm run now (live). On the Automations page under CRM > Automations, both controls require one contact, company or deal. Dry run is the default; select Live only when the workflow is enabled with dry run off. A start with no record is not shipped. The selected run inspector also offers Run again on this record and, for failed runs, Retry from the failed step with an explicit confirmation naming the first rolled-back step. Earlier committed steps are skipped. An unknown response locks further submissions until history is reconciled.

REST starts a run with POST /v1/orgs/{orgId}/automations/{workflowId}/runs, { record: { kind, id }, mode: "dry_run" | "live", idempotencyKey }. Retry uses POST /v1/orgs/{orgId}/automations/{workflowId}/runs/{runId}/retry with optional { mode: "same" | "dry_run" }. Both return { run, changed, inspectorPath }; repeated keys or retries return the stored run. Retrying an original dry run remains a dry run. CRM edit permission and write scope are required; runner credentials are refused, and live execution requires a person or normal write-scope key. Event-only triggers refuse manual starts rather than inventing event data. Changed versions, stopped workflows, unknown external outcomes and recorded webhook effects refuse unsafe retries.

MCP tools automation_run_start and automation_run_retry dispatch through the same mounted REST routes inside the automation feature gate. The existing run history and stop controls remain available.

Schedule workflows use five-field cron, a named timezone and an explicit CRM audience. Configure the schedule in the workflow editor; the existing automation sweep admits only the latest due occurrence, once per record, under the normal permissions and dry-run rules. See Scheduled CRM workflows.

HTTP, code and data mapping

The composer offers typed configuration for http_request, code and set_data, with Edit as JSON available for each node. Both CRM and automation entitlements must be enabled. Catalog discovery and compilation grant no execution authority.

http_request resolves its URL, query, headers and body from earlier step data. Authored URL templates remain byte-identical through save/readback. Literal URLs are normalized; resolved targets must pass strict public HTTPS, SSRF and DNS pinning checks before transport. Unresolved delimiters are refused. Credentials reference organization vault secrets subject to the creator's current access; credential IDs and methods are literal. Live requests stage durable waits in the event transaction, then run after commit via the response kick or cron sweep. Unknown writes are never replayed automatically; GET/HEAD recovery is bounded. Dry runs make no transport calls.

code runs JavaScript in a bounded QuickJS worker without host network or filesystem access. Source stays literal. $input receives the run context (trigger record/event, prior steps.s1.output values, run identity and time). Dry runs execute the sandbox and record planned output. Time, memory, output and log limits still apply.

set_data maps safe dot paths to literals or parsed {{ steps.s1.output.value }} expressions. Whole expressions retain JSON types; embedded expressions produce text. Available roots are trigger, steps, run and now. Only applied/planned prior outputs enter the context. Source JavaScript and credential references are never passed through a blanket template resolver. Inputs and outputs are redacted for history. The run inspector and read-only run-context route remain tenant scoped.

Saved branched definitions retain graph context through additive migration 13532; reopening a saved sequence restores editable node and edge identities. Direct action edits without replacement graph context clear stale metadata.

Delete archives a workflow: it stops, leaves the active list and frees its slot in the 100-workflow limit. Its run history is kept. Use Archived to Restore it stopped. History shows saved versions and differences and lets members with crm:edit restore a version or duplicate the workflow. Read-only members can inspect history.

We use essential cookies to keep you signed in. See our Privacy Policy for details.