brain/wiki/flows-execution/index.md
How flows are authored, triggered, executed, and organized in Activepieces. Skim map of the core automation domain.
Versioned directed graph (trigger + actions) stored as JSONB. All 26 modification types go through ONE endpoint: POST /v1/flows/:id with a FlowOperationRequest discriminated union.
flow (status, folderId, publishedVersionId, externalId, createdBy) + flow_version (immutable once LOCKED; DRAFT is the editable copy). Current schemaVersion '22'.LOCK_AND_PUBLISH snapshots to LOCKED and can enable. Publishing registers the trigger source; disabling unregisters it.createdBy (MCP/AGENT) drives the "AI" badge; distinct from ownerId.One execution instance per flow version, trigger → terminal state. 12 statuses (3 non-terminal: QUEUED/RUNNING/PAUSED; 9 terminal incl. FAILED/TIMEOUT/QUOTA_EXCEEDED/MEMORY_LIMIT_EXCEEDED).
FLOW_RUN_LOG); step outputs >32KB offloaded to FLOW_RUN_LOG_SLICE files (LogSliceRef). State backed up every 15s for crash recovery.executeTrigger: true. Only terminal states within EXECUTION_DATA_RETENTION_DAYS.failedStep JSONB snapshot powers filtered retries, error search, failure emails, jump-to-failed-step.ai_usage_per_run) on terminal runs.Defines how/when a flow starts. Registered as a TriggerSource (unique per projectId/flowId/simulate); dedup state in Redis.
__DEDUPE_KEY_PROPERTY), WEBHOOK (external push), APP_WEBHOOK (routed via AppEventRouting table, e.g. Slack/GitHub), MANUAL.TriggerEvent = captured payload (File ref) used as test/sample data. simulate=true sources are test-mode.Primary entry point for inbound HTTP → flow execution. 5 public routes: sync/async × prod/draft + test-only.
/:flowId/sync) blocks the connection and returns the flow response via engineResponseWatcher (default 30s timeout). Async returns 200 + x-webhook-id and queues a BullMQ job.WEBHOOK_PAYLOAD file; job carries an inline-or-ref JobPayload. Engine resolves the ref at exec time — workers no longer fetch payloads.LOCKED_FALL_BACK_TO_LATEST. Payload cap AP_MAX_WEBHOOK_PAYLOAD_SIZE_MB (5MB → 413).Public read-only endpoints returning UI metadata for flows whose trigger is @activepieces/piece-forms. Triggers: form_submission, file_submission, chat_submission.
GET /v1/human-input/form/:flowId and /chat/:flowId — return title, input schema, platform branding (white-labeled). useDraft=true loads the draft version.useDraft=true.A Subflow is a flow invoked by another flow rather than by its own external trigger — reached by a webhook POST to /v1/webhooks/:flowId, never a dedicated transport. Vocabulary from @activepieces/piece-subflows:
data payload and an optional callbackUrl. Avoid: child flow, nested flow, sub-workflow.Respond callback.{ batchIndex, headers, rows, extraData }. Avoid: chunk, csv table, sub-table, shard.x-parent-run-id, x-fail-parent-on-failure); fan-out sets the latter false. Streaming bounds memory, not time — the step is still capped by FLOW_TIMEOUT_SECONDS.Lightweight per-project grouping for flows and tables. Name unique case-insensitively per project.
folder entity (displayName, projectId, displayOrder). List returns numberOfFlows/numberOfTables via correlated subqueries. Create is an upsert by name."NULL" (UncategorizedFolderId) filters flows with no folder. Deleting a folder does NOT delete its flows — they become uncategorized. Fires FOLDER_CREATED/UPDATED/DELETED audit events.Reusable flow/table blueprints. Types: OFFICIAL (Activepieces-curated, platformId null), CUSTOM (platform-owned, needs manageTemplatesEnabled flag), SHARED (ad-hoc, not listable).
cloud.activepieces.com/api/v1/templates; Cloud stores them in DB. pieces[] and categories[] are denormalized + indexed for fast filtering.{{ ... }} evaluator shared by engine, api and web