Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

Run Class

The Run class represents a workflow execution instance, providing methods to start, resume, stream, and monitor workflow execution.

Usage exampleDirect link to Usage example

const run = await workflow.createRunAsync();

const result = await run.start({
inputData: { value: "initial data" },
});

if (result.status === "suspended") {
const resumedResult = await run.resume({
resumeData: { value: "resume data" },
});
}

Run MethodsDirect link to Run Methods

start:

(options?: StartOptions) => Promise<WorkflowResult>
Starts workflow execution with input data

resume:

(options?: ResumeOptions) => Promise<WorkflowResult>
Resumes a suspended workflow from a specific step

stream:

(options?: StreamOptions) => Promise<StreamResult>
Monitors workflow execution as a stream of events

streamVNext:

(options?: StreamOptions) => MastraWorkflowStream
Enables real-time streaming with enhanced features

watch:

(callback: WatchCallback, type?: WatchType) => UnwatchFunction
Monitors workflow execution with callback-based events

cancel:

() => Promise<void>
Cancels the workflow execution

restart:

(options?: RestartOptions) => Promise<WorkflowResult>
Restarts the workflow execution from last active step

timeTravel:

(options?: TimeTravelOptions) => Promise<WorkflowResult>
Re-executes a workflow starting from any specific step, using either stored snapshot data or custom context you provide.

timeTravelStream:

(options?: TimeTravelOptions) => MastraWorkflowStream
Time travels a workflow execution with streaming support

Run StatusDirect link to Run Status

A workflow run's status indicates its current execution state. The possible values are:

success:

string
All steps finished executing successfully, with a valid result output

failed:

string
Workflow execution encountered an error during execution, with error details available

suspended:

string
Workflow execution is paused waiting for resume, with suspended step information

On this page