Skip to main content

Input and Output

Stepflow flows define clear input and output contracts using JSON Schema. This ensures data validation, type safety, and clear documentation of what data flows into and out of your flows.

  • The Input Schema describes the expected structure of input data.
  • The Output section maps step results to the flow output.
  • The Output Schema defines the structure of the output data.

Flow Input Schema

Every flow should define an input schema that describes the expected structure of input data:

inputSchema:
type: object
properties:
user_id:
type: string
description: "Unique identifier for the user"
preferences:
type: object
properties:
theme:
type: string
enum: ["light", "dark"]
notifications:
type: boolean
required: ["theme"]
data_files:
type: array
items:
type: string
description: "List of file paths to process"
required: ["user_id"]

Flow Output

Map workflow output to step results:

output:
summary:
total_processed: { $from: { step: count_items } }
success_count: { $from: { step: analyze_results }, path: "success_count" }
error_count: { $from: { step: analyze_results }, path: "error_count" }
results: { $from: { step: collect_results } }

The output section uses Expressions to reference data from steps within the flow.

Flow Output Schema

Define the structure of data your workflow produces:

outputSchema:
type: object
properties:
summary:
type: object
properties:
total_processed:
type: integer
success_count:
type: integer
error_count:
type: integer
required: ["total_processed", "success_count", "error_count"]
results:
type: array
items:
type: object
properties:
id:
type: string
status:
type: string
enum: ["success", "error", "skipped"]
data:
type: object
required: ["id", "status"]
required: ["summary", "results"]