Source: Mastra docs: Workflows overview
Mastra workflows: createStep/createWorkflow with typed schemas, shared state, nested workflows, run statuses, suspend/resume, and crash recovery via storage leases.
Contents
- What: official documentation page
- Author: Mastra
- Date: read 2026-11-14
- Original: https://mastra.ai/docs/workflows/overview
Summary
Workflows are typed, explicit step graphs: steps are defined with createStep, composed with createWorkflow and chaining methods, and finalised with .commit(). Runs can stream events, suspend for input and be resumed, and are recovered after a crash from persisted state.
Key claims
createStep({ id, inputSchema, outputSchema, execute, stateSchema? }); schemas accept Standard JSON Schema (Zod, Valibot, ArkType).executereceivesinputData,state/setState,mastra,writer,requestContext,runId,workflowId.- Steps can call registered agents and tools; a workflow can itself be a step (
.then(childWorkflow));cloneWorkflowcopies one. - Run with
createRun()thenstart({ inputData })orstream(...);resumeStream(...)resumes a suspended run or reattaches to a stream. - Result
statusis one ofsuccess,failed,suspended,tripwire,paused. - Shared
statepersists across suspend/resume without threading through every schema. - Recovery:
run.restart(),restartAllActiveWorkflowRuns()on server boot; runs hold a storage lease; restarted steps may run again, so side-effecting steps must be idempotent (keys fromrunId,workflowId, stepid). recovery.workflowConcurrencydefaults to 5 andrecovery.workflowGraceMsto 2 s.