Flow schema — Automation Protocol reference
Flow schemas of the ObjectStack Automation Protocol: Flow, FlowEdge, FlowNode and 3 more — each property with its type, default and a TypeScript example.
Source: packages/spec/src/automation/flow.zod.ts
TypeScript Usage
import { FlowSchema, FlowEdgeSchema, FlowNodeSchema, FlowNodeAction, FlowVariableSchema, FlowVersionHistorySchema } from '@objectstack/spec/automation';
import type { Flow, FlowEdge, FlowNode, FlowNodeAction, FlowVersionHistory } from '@objectstack/spec/automation';
// Validate data
const result = FlowSchema.parse(data);Flow
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Machine name |
| label | string | ✅ | Flow label |
| description | string | optional | |
| successMessage | string | optional | Text for a terminal success, carried on AutomationResult for every terminal run (not only screen flows); the screen-flow UI shows it as a toast instead of a generic "Done". A {{ }} template over the run's variables ({{ enrolledCount }} contacts enrolled), rendered when the run completes. |
| errorMessage | string | optional | Text for a terminal failure, carried on AutomationResult for every terminal run (not only screen flows); the screen-flow UI shows it as a toast instead of the raw error. A {{ }} template over the run's variables, rendered over the variables at the failure point. |
| version | integer | optional (default: 1) | Version number |
| status | Enum<'draft' | 'active' | 'obsolete' | 'invalid'> | optional (default: "draft") | Deployment status |
| defaultActive | boolean | optional | Packaged flows only: false ships the flow switched off, so it is not armed on an installation until an administrator turns it on with the packaged-flow switch (the activation ledger); the administrator's choice, once made, wins over this default across restarts and upgrades. Absent or true: switched on. status stays the author's switch: obsolete/invalid disarm the flow everywhere. A flow authored in the environment is switched by status and may not declare this key. |
| type | Enum<'autolaunched' | 'record_change' | 'schedule' | 'screen' | 'api'> | ✅ | Flow type |
| variables | { name: string; type: string; isInput?: boolean; isOutput?: boolean; … }[] | optional | Flow variables |
| nodes | { id: string; type: string; label: string; config?: Record<string, any>; … }[] | ✅ | Flow nodes |
| edges | { id: string; source: string; target: string; condition?: string | object; … }[] | ✅ | Flow connections |
| runAs | Enum<'system' | 'user'> | optional (default: "user") | Execution identity for the run: system = elevated (bypasses RLS) — system flows keep system privileges; after an approval decision their attribution user is the decider; user = the human whose act is running this segment: the trigger user until a human decision, the decider after it (RLS-respecting; the nodes after an approval decision run with the decider's identity and permissions, so a node the decider may not perform is refused). Elevation does not reach identity assignment: a system run's governed writes (insert, update, delete, transfer, restore, purge) to sys_user_position, sys_user_permission_set, sys_invitation and sys_member are refused with PERMISSION_DENIED; declare user for position holdings and permission-set grants (the ADR-0090 D12 delegated-administration gate then judges the user the run acts for), and change invitations and memberships through the organization endpoints. Nor does it reach a ledger: a system run's update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' (the audit log, the activity feed and their siblings) is refused with PERMISSION_DENIED, and so is its delete of a record such a ledger row references, because that delete would change the ledger row; an insert is not judged by this rule. Nor does it lift the organization wall: a system run for a user has its reads and writes judged by that user's organization wall. A write whose own data names an organization outside it, or empties a record's organization, is refused with PERMISSION_DENIED. Where the wall denies the user (no active organization under isolated, no membership under group), its reads of an organization's records return none, its deletes remove none, and its other writes are refused with PERMISSION_DENIED. A run that began for no caller is not judged by it, after an approval decision too. A run with no trigger user has no identity to scope to, so under user its data operations are REFUSED — declare system to make the elevation explicit. This covers schedule/time-relative/api triggers AND any record-change flow fired by a write that carried no user. Except behind an anonymous door: publish refuses system on a flow that an authRequired: false endpoint of type flow triggers (ADR-0138 D2b); serve that caller through an authenticated endpoint, the flow's signed inbound hook, or a public form. |
| requiredPermissions | string[] | optional | [ADR-0066 D4] Capabilities required to START this flow, the flow-level twin of an action's requiredPermissions. Checked at every door that starts a flow by name (the trigger route, an action of type flow over REST and MCP run_action, a declared endpoint of type flow): a caller that is not the system principal must hold every named capability, or the door answers 403 PERMISSION_DENIED and nothing runs. An action that starts this flow inherits the list even when it declares none; one that declares its own needs both. A parent flow's subflow node is not a door and is not checked again. Use this, not current_user.positions inside the flow, to say who may start an elevated (runAs: system) screen or api flow. |
| errorHandling | { strategy?: Enum<'fail' | 'retry' | 'continue'>; maxRetries?: integer; backoffMs?: integer; backoffMultiplier?: number; … } | optional | Flow-level error handling configuration. A durable pause ends the retry-governed segment: strategy: 'retry' describes one synchronous dispatch, so a run that parks on an approval/screen/wait node and later resumes gets one attempt for anything that fails after the pause. Protect the post-pause half with its own failure handling in the flow — a try_catch node's retry around the post-resume work, or fault edges to a handler node. |
| protection | { lock: Enum<'none' | 'no-overlay' | 'no-delete' | 'full'>; reason: string; docsUrl?: string } | optional | Package author protection block — lock policy for this flow. |
| _lock | Enum<'none' | 'no-overlay' | 'no-delete' | 'full'> | optional | Item-level lock — controls overlay & delete (ADR-0010). |
| _lockReason | string | optional | Human-readable reason shown when a write is refused by _lock. |
| _lockSource | Enum<'artifact' | 'package' | 'env-forced'> | optional | Layer that set _lock (artifact | package | env-forced). |
| _provenance | Enum<'package' | 'org' | 'env-forced' | 'platform'> | optional | Origin of the item (package | org | env-forced | platform). |
| _packageId | string | optional | Owning package machine id. |
| _packageVersion | string | optional | Owning package version. |
| _lockDocsUrl | string | optional | Optional documentation link surfaced next to _lockReason. |
| overrides | { package: string; basedOn: string } | optional | Override declaration (ADR-0146 D2): { package, basedOn } — this item of "<base>.custom" replaces the base package's same-named item whole. basedOn is recorded and never gates; a base's upgrade plan reads it only as advice. |
Nested Shape: Flow.variables[number]
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Variable name — a name without a leading $ (the $ names are the flow engine's own), read as {{ name }} |
| type | string | ✅ | Data type (text, number, boolean, object, list) |
| isInput | boolean | optional (default: false) | Is input parameter |
| isOutput | boolean | optional (default: false) | Is output parameter |
| defaultValue | any | optional | Value bound at run start when no parameter supplies one — this is what makes a declared variable always bound. An explicitly supplied param wins, including false and null; the boundary is params[name] !== undefined. |
| objectName | string | optional | Declares this input a record reference: its value is the id of one record of the named object (the object's snake_case name, e.g. crm_account). Only on an input (isInput: true). The contract: every door that starts the flow by name (the trigger route, an action of type flow over REST and MCP run_action, a declared endpoint of type flow) loads a declared input from this object in the caller's own scope before the run exists; an id the caller cannot read there is refused 404 RECORD_NOT_FOUND, and a value that is not an id is refused 400 naming the input. The load is added beside any read the flow's own definition makes of the input, never in place of one. An input without this declaration is judged as a record only where the flow's own definition reads it as a record id. type stays the data type: the variable holds the id the caller sent. |
Nested Shape: Flow.nodes[number]
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | ✅ | Node unique ID |
| type | string | ✅ | Action type — a built-in FlowNodeAction id or a plugin-registered node type. Validated against the live action registry at registerFlow() (ADR-0018), not by a closed enum. The retired callout names 'http_request', 'http_call' and 'webhook' are reserved and refused: use 'http'. |
| label | string | ✅ | Node label |
| config | Record<string, any> | optional | Node configuration |
| connectorConfig | { connectorId: string; actionId: string; input?: Record<string, any> } | optional | |
| position | { x: number; y: number } | optional | |
| timeoutMs | integer | optional | Maximum execution time for this node in milliseconds |
| inputSchema | Record<string, { type: Enum<'string' | 'number' | 'boolean' | 'object' | 'array'>; required?: boolean; description?: string }> | optional | Input parameter schema for this node |
| waitEventConfig | { eventType: Enum<'timer' | 'signal' | 'webhook' | 'manual' | 'condition'>; timerDuration?: string; signalName?: string } | optional | Configuration for wait node event resumption. REQUIRED on a type: 'wait' node — the block is the whole contract, and a wait node without one parses into a run that parks forever reporting success. Under eventType: 'timer' a timerDuration is required too. |
| boundaryConfig | { attachedToNodeId: string; eventType: Enum<'error' | 'timer' | 'signal' | 'cancel'>; interrupting?: boolean; errorCode?: string; … } | optional | Configuration for boundary events attached to host nodes. REQUIRED on a type: 'boundary_event' node — without it the node names neither the activity it watches nor what fires it. |
Nested Shape: Flow.edges[number]
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | ✅ | Edge unique ID |
| source | string | ✅ | Source Node ID |
| target | string | ✅ | Target Node ID |
| condition | string | { dialect: Enum<'cel' | 'cron' | 'template'>; source: string; ast?: any; meta?: object } | optional | Predicate (CEL) returning boolean used for branching. An evaluated slot: a bare non-blank CEL string, or an envelope carrying a non-blank source — an ast-only envelope, and a source that is blank after trimming, are refused at authoring because the engine evaluates source alone and would otherwise answer a silent false. |
| type | Enum<'default' | 'fault' | 'conditional' | 'back'> | optional (default: "default") | Connection type: default (normal flow), fault (error path), conditional (expression-guarded), or back (ADR-0044 declared back-edge — traversed normally at run time, but excluded from DAG cycle validation so a revise/rework loop can re-enter an earlier node) |
| label | string | optional | Label on the connector |
| isDefault | boolean | optional (default: false) | BPMN default flow: traverse this edge only when no sibling conditional edge of the same source node matched. Mutually exclusive with condition; at most one per source node. |
Nested Shape: Flow.errorHandling
| Property | Type | Required | Description |
|---|---|---|---|
| strategy | Enum<'fail' | 'retry' | 'continue'> | optional (default: "fail") | How to handle node execution errors. 'retry' governs ONE synchronous dispatch: a durable pause (approval/screen/wait) ends the retry-governed segment, so a failure after the run resumes is not retried. |
| maxRetries | integer | optional (default: 0) | Retry attempts after the initial one. Read only under strategy: 'retry', which requires >= 1; 0 (the default) means no retry. |
| backoffMs | integer | optional (default: 1000) | Base delay before the first retry (ms); subsequent delays multiply by backoffMultiplier |
| backoffMultiplier | number | optional (default: 1) | Exponential backoff multiplier; 1 (the default) keeps the delay flat |
| maxRetryDelayMs | integer | optional (default: 30000) | Ceiling for a single backoff delay (ms) |
| jitter | boolean | optional (default: false) | Randomize each delay within [50%, 100%] of its computed value — spreads a thundering herd of simultaneous retries |
Nested Shape: Flow.protection
| Property | Type | Required | Description |
|---|---|---|---|
| lock | Enum<'none' | 'no-overlay' | 'no-delete' | 'full'> | ✅ | Lock policy — none | no-overlay | no-delete | full. |
| reason | string | ✅ | User-visible reason shown when the lock blocks an action. |
| docsUrl | string | optional | Optional URL the Studio banner links to for more context. |
Nested Shape: Flow.overrides
| Property | Type | Required | Description |
|---|---|---|---|
| package | string | ✅ | The base package id whose same-named item this item replaces whole (e.g. "com.acme.crm"). Only an item of the base's paired "<base>.custom" package declares an override. |
| basedOn | string | ✅ | Recorded, never a gate: the base package's manifest.version this override was taken from (e.g. "3.2.0"), not a history version of the item. Nothing is refused, merged or rebased on it; it tells a person re-basing the override where it started. One reader, as advice: a base's upgrade plan lists an override whose basedOn is not the installed base version as stale, beside each override whose base item the upgrade changes (ADR-0146 D2, as amended). |
FlowEdge
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | ✅ | Edge unique ID |
| source | string | ✅ | Source Node ID |
| target | string | ✅ | Target Node ID |
| condition | string | { dialect: Enum<'cel' | 'cron' | 'template'>; source: string; ast?: any; meta?: object } | optional | Predicate (CEL) returning boolean used for branching. An evaluated slot: a bare non-blank CEL string, or an envelope carrying a non-blank source — an ast-only envelope, and a source that is blank after trimming, are refused at authoring because the engine evaluates source alone and would otherwise answer a silent false. |
| type | Enum<'default' | 'fault' | 'conditional' | 'back'> | optional (default: "default") | Connection type: default (normal flow), fault (error path), conditional (expression-guarded), or back (ADR-0044 declared back-edge — traversed normally at run time, but excluded from DAG cycle validation so a revise/rework loop can re-enter an earlier node) |
| label | string | optional | Label on the connector |
| isDefault | boolean | optional (default: false) | BPMN default flow: traverse this edge only when no sibling conditional edge of the same source node matched. Mutually exclusive with condition; at most one per source node. |
FlowNode
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | ✅ | Node unique ID |
| type | string | ✅ | Action type — a built-in FlowNodeAction id or a plugin-registered node type. Validated against the live action registry at registerFlow() (ADR-0018), not by a closed enum. The retired callout names 'http_request', 'http_call' and 'webhook' are reserved and refused: use 'http'. |
| label | string | ✅ | Node label |
| config | Record<string, any> | optional | Node configuration |
| connectorConfig | { connectorId: string; actionId: string; input?: Record<string, any> } | optional | |
| position | { x: number; y: number } | optional | |
| timeoutMs | integer | optional | Maximum execution time for this node in milliseconds |
| inputSchema | Record<string, { type: Enum<'string' | 'number' | 'boolean' | 'object' | 'array'>; required?: boolean; description?: string }> | optional | Input parameter schema for this node |
| waitEventConfig | { eventType: Enum<'timer' | 'signal' | 'webhook' | 'manual' | 'condition'>; timerDuration?: string; signalName?: string } | optional | Configuration for wait node event resumption. REQUIRED on a type: 'wait' node — the block is the whole contract, and a wait node without one parses into a run that parks forever reporting success. Under eventType: 'timer' a timerDuration is required too. |
| boundaryConfig | { attachedToNodeId: string; eventType: Enum<'error' | 'timer' | 'signal' | 'cancel'>; interrupting?: boolean; errorCode?: string; … } | optional | Configuration for boundary events attached to host nodes. REQUIRED on a type: 'boundary_event' node — without it the node names neither the activity it watches nor what fires it. |
Nested Shape: FlowNode.connectorConfig
| Property | Type | Required | Description |
|---|---|---|---|
| connectorId | string | ✅ | Registered connector name |
| actionId | string | ✅ | Action key declared by the connector |
| input | Record<string, any> | optional | Mapped inputs for the action. Each value is a literal, handed to the action as written, or a CEL value envelope { dialect: 'cel', source } evaluated in the run's scope before dispatch; a {…} template token in a string is refused when the flow is registered or validated. The flow definition, this map included, is served to every member who can read flows, so never put a credential here: the connector authenticates through its own auth.credentialRef. |
Nested Shape: FlowNode.inputSchema[string]
| Property | Type | Required | Description |
|---|---|---|---|
| type | Enum<'string' | 'number' | 'boolean' | 'object' | 'array'> | ✅ | Parameter type |
| required | boolean | optional (default: false) | Whether the parameter is required |
| description | string | optional | Parameter description |
Nested Shape: FlowNode.waitEventConfig
| Property | Type | Required | Description |
|---|---|---|---|
| eventType | Enum<'timer' | 'signal' | 'webhook' | 'manual' | 'condition'> | ✅ | What kind of event resumes the execution |
| timerDuration | string | optional | ISO 8601 duration (e.g., "PT1H") or wait time for timer events |
| signalName | string | optional | Named signal or webhook event to wait for |
Nested Shape: FlowNode.boundaryConfig
| Property | Type | Required | Description |
|---|---|---|---|
| attachedToNodeId | string | ✅ | Host node ID this boundary event monitors |
| eventType | Enum<'error' | 'timer' | 'signal' | 'cancel'> | ✅ | Boundary event trigger type |
| interrupting | boolean | optional (default: true) | If true, the host activity is cancelled when this event fires |
| errorCode | string | optional | Specific error code to catch (empty = catch all errors) |
| timerDuration | string | optional | ISO 8601 duration for timer boundary events |
| signalName | string | optional | Named signal to catch |
FlowNodeAction
Allowed Values
startenddecisionassignmentloopcreate_recordupdate_recorddelete_recordget_recordhttpnotifysave_noticescriptscreenwaitsubflowmapconnector_actionparallel_gatewayjoin_gatewayboundary_event
FlowVariable
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Variable name — a name without a leading $ (the $ names are the flow engine's own), read as {{ name }} |
| type | string | ✅ | Data type (text, number, boolean, object, list) |
| isInput | boolean | optional (default: false) | Is input parameter |
| isOutput | boolean | optional (default: false) | Is output parameter |
| defaultValue | any | optional | Value bound at run start when no parameter supplies one — this is what makes a declared variable always bound. An explicitly supplied param wins, including false and null; the boundary is params[name] !== undefined. |
| objectName | string | optional | Declares this input a record reference: its value is the id of one record of the named object (the object's snake_case name, e.g. crm_account). Only on an input (isInput: true). The contract: every door that starts the flow by name (the trigger route, an action of type flow over REST and MCP run_action, a declared endpoint of type flow) loads a declared input from this object in the caller's own scope before the run exists; an id the caller cannot read there is refused 404 RECORD_NOT_FOUND, and a value that is not an id is refused 400 naming the input. The load is added beside any read the flow's own definition makes of the input, never in place of one. An input without this declaration is judged as a record only where the flow's own definition reads it as a record id. type stays the data type: the variable holds the id the caller sent. |
FlowVersionHistory
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| flowName | string | ✅ | Flow machine name |
| version | integer | ✅ | Version number |
| definition | { name: string; label: string; description?: string; successMessage?: string; … } | ✅ | Complete flow definition snapshot |
| createdAt | string | ✅ | When this version was created |
| createdBy | string | optional | User who created this version |
| changeNote | string | optional | Description of what changed in this version |
Nested Shape: FlowVersionHistory.definition
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Machine name |
| label | string | ✅ | Flow label |
| description | string | optional | |
| successMessage | string | optional | Text for a terminal success, carried on AutomationResult for every terminal run (not only screen flows); the screen-flow UI shows it as a toast instead of a generic "Done". A {{ }} template over the run's variables ({{ enrolledCount }} contacts enrolled), rendered when the run completes. |
| errorMessage | string | optional | Text for a terminal failure, carried on AutomationResult for every terminal run (not only screen flows); the screen-flow UI shows it as a toast instead of the raw error. A {{ }} template over the run's variables, rendered over the variables at the failure point. |
| version | integer | optional (default: 1) | Version number |
| status | Enum<'draft' | 'active' | 'obsolete' | 'invalid'> | optional (default: "draft") | Deployment status |
| defaultActive | boolean | optional | Packaged flows only: false ships the flow switched off, so it is not armed on an installation until an administrator turns it on with the packaged-flow switch (the activation ledger); the administrator's choice, once made, wins over this default across restarts and upgrades. Absent or true: switched on. status stays the author's switch: obsolete/invalid disarm the flow everywhere. A flow authored in the environment is switched by status and may not declare this key. |
| type | Enum<'autolaunched' | 'record_change' | 'schedule' | 'screen' | 'api'> | ✅ | Flow type |
| variables | { name: string; type: string; isInput?: boolean; isOutput?: boolean; … }[] | optional | Flow variables |
| nodes | { id: string; type: string; label: string; config?: Record<string, any>; … }[] | ✅ | Flow nodes |
| edges | { id: string; source: string; target: string; condition?: string | object; … }[] | ✅ | Flow connections |
| runAs | Enum<'system' | 'user'> | optional (default: "user") | Execution identity for the run: system = elevated (bypasses RLS) — system flows keep system privileges; after an approval decision their attribution user is the decider; user = the human whose act is running this segment: the trigger user until a human decision, the decider after it (RLS-respecting; the nodes after an approval decision run with the decider's identity and permissions, so a node the decider may not perform is refused). Elevation does not reach identity assignment: a system run's governed writes (insert, update, delete, transfer, restore, purge) to sys_user_position, sys_user_permission_set, sys_invitation and sys_member are refused with PERMISSION_DENIED; declare user for position holdings and permission-set grants (the ADR-0090 D12 delegated-administration gate then judges the user the run acts for), and change invitations and memberships through the organization endpoints. Nor does it reach a ledger: a system run's update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' (the audit log, the activity feed and their siblings) is refused with PERMISSION_DENIED, and so is its delete of a record such a ledger row references, because that delete would change the ledger row; an insert is not judged by this rule. Nor does it lift the organization wall: a system run for a user has its reads and writes judged by that user's organization wall. A write whose own data names an organization outside it, or empties a record's organization, is refused with PERMISSION_DENIED. Where the wall denies the user (no active organization under isolated, no membership under group), its reads of an organization's records return none, its deletes remove none, and its other writes are refused with PERMISSION_DENIED. A run that began for no caller is not judged by it, after an approval decision too. A run with no trigger user has no identity to scope to, so under user its data operations are REFUSED — declare system to make the elevation explicit. This covers schedule/time-relative/api triggers AND any record-change flow fired by a write that carried no user. Except behind an anonymous door: publish refuses system on a flow that an authRequired: false endpoint of type flow triggers (ADR-0138 D2b); serve that caller through an authenticated endpoint, the flow's signed inbound hook, or a public form. |
| requiredPermissions | string[] | optional | [ADR-0066 D4] Capabilities required to START this flow, the flow-level twin of an action's requiredPermissions. Checked at every door that starts a flow by name (the trigger route, an action of type flow over REST and MCP run_action, a declared endpoint of type flow): a caller that is not the system principal must hold every named capability, or the door answers 403 PERMISSION_DENIED and nothing runs. An action that starts this flow inherits the list even when it declares none; one that declares its own needs both. A parent flow's subflow node is not a door and is not checked again. Use this, not current_user.positions inside the flow, to say who may start an elevated (runAs: system) screen or api flow. |
| errorHandling | { strategy?: Enum<'fail' | 'retry' | 'continue'>; maxRetries?: integer; backoffMs?: integer; backoffMultiplier?: number; … } | optional | Flow-level error handling configuration. A durable pause ends the retry-governed segment: strategy: 'retry' describes one synchronous dispatch, so a run that parks on an approval/screen/wait node and later resumes gets one attempt for anything that fails after the pause. Protect the post-pause half with its own failure handling in the flow — a try_catch node's retry around the post-resume work, or fault edges to a handler node. |
| protection | { lock: Enum<'none' | 'no-overlay' | 'no-delete' | 'full'>; reason: string; docsUrl?: string } | optional | Package author protection block — lock policy for this flow. |
| _lock | Enum<'none' | 'no-overlay' | 'no-delete' | 'full'> | optional | Item-level lock — controls overlay & delete (ADR-0010). |
| _lockReason | string | optional | Human-readable reason shown when a write is refused by _lock. |
| _lockSource | Enum<'artifact' | 'package' | 'env-forced'> | optional | Layer that set _lock (artifact | package | env-forced). |
| _provenance | Enum<'package' | 'org' | 'env-forced' | 'platform'> | optional | Origin of the item (package | org | env-forced | platform). |
| _packageId | string | optional | Owning package machine id. |
| _packageVersion | string | optional | Owning package version. |
| _lockDocsUrl | string | optional | Optional documentation link surfaced next to _lockReason. |
| overrides | { package: string; basedOn: string } | optional | Override declaration (ADR-0146 D2): { package, basedOn } — this item of "<base>.custom" replaces the base package's same-named item whole. basedOn is recorded and never gates; a base's upgrade plan reads it only as advice. |