Skip to main content

Workflow API

The Workflow API provides the building blocks to create, configure, and connect steps in a workflow.

Classes

Workflow

The main class used to construct and manage a workflow.

Methods:

  • addStep(step: Step): this Adds a single step to the workflow.

    workflow.addStep(myStep);
  • addSteps(...steps: Step[]): this Adds multiple steps to the workflow at once.

    workflow.addSteps(step1, step2, step3);
  • listSteps(): Step[] Returns an array of all steps currently in the workflow.

    const steps = workflow.listSteps();
  • toJSON(): SerializedWorkflow Exports the workflow to a serialized JSON format.

    const definition = workflow.toJSON();
  • toRuntimeWorkflow(): WorkflowRuntimeShape Converts the workflow into a shape ready for the runtime engine. Throws if a connection points at a step that isn't in the workflow.

    const runtimeShape = workflow.toRuntimeWorkflow();

Deploying: Workflow has no save() or deploy method. Workflows are deployed with the culvii CLI — export your Workflow from a .culvii.ts file (or one listed under entrypoints: in culvii.yaml) and run culvii deploy --env <sandbox|prod> --workspace <slug>. See Executing Workflows.

The constructor also reads its config:

  • new Workflow(config: WorkflowConfig) Constructs a workflow. config.id and config.name are required; any steps in config.steps are added immediately.

Step

Represents a single node or action within a workflow.

Methods:

  • connectTo(targetStep: Step, options?: ConnectStepOptions): this Connects this step to another step, defining the execution path.
    triggerStep.connectTo(actionStep);

Types & Interfaces

WorkflowConfig

Configuration object for a complete workflow. id and name are required; active (defaults to true) and steps are optional.

const workflowConfig: WorkflowConfig = {
id: 'status-workflow', // required — stable slug used by the platform
name: 'Status Workflow',
active: true,
steps: [trigger, setStatus],
};

WorkflowStepConfig

Configuration object for an individual step.

const stepConfig: WorkflowStepConfig = {
name: 'Set Status',
type: 'core.set',
params: {
values: {
status: 'ready',
},
},
};

ConnectStepOptions

Options for connecting steps, such as conditional branching.

SerializedWorkflow

The JSON representation of a workflow.

WorkflowRuntimeShape

The internal representation used by the execution engine.