ObjectStackObjectStack

Automation Api

Automation Api protocol schemas

Automation API Protocol

Defines REST CRUD endpoint schemas for managing automation flows, triggering executions, and querying execution history.

Base path: /api/automation

@example Endpoints GET /api/automation — List flows GET /api/automation/:name — Get flow POST /api/automation — Create flow PUT /api/automation/:name — Update flow DELETE /api/automation/:name — Delete flow POST /api/automation/:name/trigger — Trigger flow execution POST /api/automation/:name/toggle — Enable/disable flow GET /api/automation/:name/runs — List execution runs GET /api/automation/:name/runs/:runId — Get single execution run

Source: packages/spec/src/api/automation-api.zod.ts

TypeScript Usage

import { AutomationApiErrorCode, AutomationFlowPathParamsSchema, AutomationRunPathParamsSchema, CreateFlowRequestSchema, CreateFlowResponseSchema, DeleteFlowRequestSchema, DeleteFlowResponseSchema, FlowSummarySchema, GetFlowRequestSchema, GetFlowResponseSchema, GetRunRequestSchema, GetRunResponseSchema, ListFlowsRequestSchema, ListFlowsResponseSchema, ListRunsRequestSchema, ListRunsResponseSchema, ToggleFlowRequestSchema, ToggleFlowResponseSchema, TriggerFlowRequestSchema, TriggerFlowResponseSchema, UpdateFlowRequestSchema, UpdateFlowResponseSchema } from '@objectstack/spec/api';
import type { AutomationApiErrorCode, AutomationFlowPathParams, AutomationRunPathParams, CreateFlowRequest, CreateFlowResponse, DeleteFlowRequest, DeleteFlowResponse, FlowSummary, GetFlowRequest, GetFlowResponse, GetRunRequest, GetRunResponse, ListFlowsRequest, ListFlowsResponse, ListRunsRequest, ListRunsResponse, ToggleFlowRequest, ToggleFlowResponse, TriggerFlowRequest, TriggerFlowResponse, UpdateFlowRequest, UpdateFlowResponse } from '@objectstack/spec/api';

// Validate data
const result = AutomationApiErrorCode.parse(data);

AutomationApiErrorCode

Allowed Values

  • flow_not_found
  • flow_already_exists
  • flow_validation_failed
  • flow_disabled
  • execution_not_found
  • execution_failed
  • execution_timeout
  • node_executor_not_found
  • concurrent_execution_limit

AutomationFlowPathParams

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)

AutomationRunPathParams

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)
runIdstringExecution run ID

CreateFlowRequest

Properties

PropertyTypeRequiredDescription
namestringMachine name
labelstringFlow label
descriptionstringoptional
successMessagestringoptionalMessage 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".
errorMessagestringoptionalMessage 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.
versionintegeroptional (default: 1)Version number
statusEnum<'draft' | 'active' | 'obsolete' | 'invalid'>optional (default: "draft")Deployment status
templateneveroptional[REMOVED] flow.template was removed in @objectstack/spec 17.0.0 (#3896 audit close-out) — no designer or engine path ever read it, so flagging a flow as a template/subflow did nothing. Delete the key. Shared logic is invoked via a subflow NODE referencing the flow by name. Run os migrate meta --from 16 to list the mechanical edits for existing sources; apply them by hand.
typeEnum<'autolaunched' | 'record_change' | 'schedule' | 'screen' | 'api'>Flow type
variables{ name: string; type: string; isInput?: boolean; isOutput?: boolean; … }[]optionalFlow 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
activeneveroptional[REMOVED] flow.active was removed in @objectstack/spec 17.0.0 (#3896 audit close-out) — it never had an effect: the engine arms flows from status, and active: false did NOT stop a flow (worse, the default read as disabled while the engine treated unset as enabled). Delete the key. Use status: 'obsolete' (or 'invalid') to unbind and disable a flow, status: 'active' to arm it. Run os migrate meta --from 16 to list the mechanical edits for existing sources; apply them by hand.
runAsEnum<'system' | 'user'>optional (default: "user")Execution identity for the run: system = elevated (bypasses RLS), user = the triggering user (RLS-respecting). 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.
errorHandling{ strategy?: Enum<'fail' | 'retry' | 'continue'>; maxRetries?: integer; backoffMs?: integer; backoffMultiplier?: number; … }optionalFlow-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 }optionalPackage author protection block — lock policy for this flow.
_lockEnum<'none' | 'no-overlay' | 'no-delete' | 'full'>optionalItem-level lock — controls overlay & delete (ADR-0010).
_lockReasonstringoptionalHuman-readable reason shown when a write is refused by _lock.
_lockSourceEnum<'artifact' | 'package' | 'env-forced'>optionalLayer that set _lock (artifact | package | env-forced).
_provenanceEnum<'package' | 'org' | 'env-forced'>optionalOrigin of the item (package | org | env-forced).
_packageIdstringoptionalOwning package machine id.
_packageVersionstringoptionalOwning package version.
_lockDocsUrlstringoptionalOptional documentation link surfaced next to _lockReason.

CreateFlowResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ name: string; label: string; description?: string; successMessage?: string; … }The created flow definition

DeleteFlowRequest

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)

DeleteFlowResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ name: string; deleted: boolean }

FlowSummary

Properties

PropertyTypeRequiredDescription
namestringFlow machine name
labelstringFlow display label
typestringFlow type
statusstringFlow deployment status
versionintegerFlow version number
enabledbooleanWhether the flow is enabled for execution
nodeCountintegeroptionalNumber of nodes in the flow
lastRunAtstringoptionalLast execution timestamp

GetFlowRequest

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)

GetFlowResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ name: string; label: string; description?: string; successMessage?: string; … }Full flow definition

GetRunRequest

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)
runIdstringExecution run ID

GetRunResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ id: string; flowName: string; flowVersion?: integer; status: Enum<'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled' | …>; … }Full execution log with step details

ListFlowsRequest

Properties

PropertyTypeRequiredDescription
statusEnum<'draft' | 'active' | 'obsolete' | 'invalid'>optionalFilter by flow status
typeEnum<'autolaunched' | 'record_change' | 'schedule' | 'screen' | 'api'>optionalFilter by flow type
limitintegeroptional (default: 50)Maximum number of flows to return
cursorstringoptionalCursor for pagination

ListFlowsResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ flows: object[]; total?: integer; nextCursor?: string; hasMore: boolean }

ListRunsRequest

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)
statusEnum<'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled' | 'timed_out' | 'retrying'>optionalFilter by execution status
limitintegeroptional (default: 20)Maximum number of runs to return
cursorstringoptionalCursor for pagination

ListRunsResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ runs: object[]; total?: integer; nextCursor?: string; hasMore: boolean }

ToggleFlowRequest

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)
enabledbooleanWhether to enable (true) or disable (false) the flow

ToggleFlowResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ name: string; enabled: boolean }

TriggerFlowRequest

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)
recordRecord<string, any>optionalRecord that triggered the automation
objectstringoptionalObject name the record belongs to
eventstringoptionalTrigger event type
userIdstringoptionalUser who triggered the automation
paramsRecord<string, any>optionalAdditional contextual data

TriggerFlowResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ success: boolean; output?: any; error?: string; durationMs?: number }

UpdateFlowRequest

Properties

PropertyTypeRequiredDescription
namestringFlow machine name (snake_case)
definition{ name?: string; label?: string; description?: string; successMessage?: string; … }Partial flow definition to update

UpdateFlowResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ name: string; label: string; description?: string; successMessage?: string; … }The updated flow definition

On this page