Skip to main content

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 example

mastra.getWorkflow("testWorkflow");

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.

Returns

workflow:

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