Skip to Content

Workflow.execute()

The .execute() method executes a workflow directly and returns the output, allowing you to run a workflow without creating a separate run instance.

Usage example

await workflow.execute({ inputData: { value: "hello world" } });

Parameters

inputData:

z.infer<TInput>
Input data that matches the workflow's input schema

resumeData?:

any
Data for resuming a suspended workflow

suspend:

(suspendPayload: any) => Promise<any>
Function to suspend workflow execution

resume?:

object
Configuration for resuming workflow execution
string[]
any
string

emitter:

object
Event emitter object for workflow events
(event: string, data: any) => void

mastra:

Mastra
Mastra instance

runtimeContext?:

RuntimeContext
Runtime context data to use during workflow execution

abort:

() => any
Function to abort workflow execution

abortSignal:

AbortSignal
Abort signal for workflow execution

runCount?:

number
Number of times the workflow has been run

Returns

result:

Promise<z.infer<TOutput>>
A promise that resolves to the output of the executed workflow