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.

Mastra.getWorkflow()

The .getWorkflow() method is used to retrieve a workflow by its ID. The method accepts a workflow ID and an optional options object.

Usage exampleDirect link to Usage example

mastra.getWorkflow("testWorkflow");

ParametersDirect link to Parameters

id:

TWorkflowId extends keyof TWorkflows
The ID of the workflow to retrieve. Must be a valid workflow ID that exists in the Mastra configuration.

options:

{ serialized?: boolean }
Optional configuration object. When `serialized` is true, returns only the workflow name instead of the full workflow instance.

ReturnsDirect link to Returns

workflow:

TWorkflows[TWorkflowId]
The workflow instance with the specified ID. Throws an error if the workflow is not found.

On this page