docs/src/content/en/reference/workflows/run-methods/startAsync.mdx
The .startAsync() method starts a workflow run without waiting for completion. It returns immediately with the runId, allowing the workflow to execute in the background. This is useful for long-running workflows, scheduled tasks, or when you want to avoid blocking on workflow completion.
const run = await workflow.createRun()
// Fire-and-forget - returns immediately
const { runId } = await run.startAsync({
inputData: {
value: 'initial data',
},
})
// Optionally poll for completion later
const result = await workflow.getWorkflowRunExecutionResult(runId)
<PropertiesTable content={[ { name: 'inputData', type: 'z.infer<TInput>', description: "Input data that matches the workflow's input schema", isOptional: true, }, { name: 'requestContext', type: 'RequestContext', description: 'Request Context data to use during workflow execution', isOptional: true, }, { name: 'initialState', type: 'z.infer<TState>', description: 'Initial state to use for the workflow execution', isOptional: true, }, { name: 'tracingOptions', type: 'TracingOptions', isOptional: true, description: 'Options for Tracing configuration.', properties: [ { parameters: [ { name: 'metadata', type: 'Record<string, any>', isOptional: true, description: 'Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.', }, ], }, { parameters: [ { name: 'traceId', type: 'string', isOptional: true, description: 'Trace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.', }, ], }, ], }, { name: 'outputOptions', type: 'OutputOptions', isOptional: true, description: 'Options for output configuration.', properties: [ { parameters: [ { name: 'includeState', type: 'boolean', isOptional: true, description: 'Whether to include the workflow run state in the result.', }, ], }, ], }, ]} />
<PropertiesTable content={[ { name: 'runId', type: 'string', description: 'The unique identifier for this workflow run. Use this to check status or retrieve results later.', }, ]} />
startAsync()Use startAsync() instead of start() when:
start() polls for completion which can fail and cause retries. startAsync() avoids this issueAfter calling startAsync(), you can check the workflow status using:
// Get the execution result (including step outputs)
const result = await workflow.getWorkflowRunExecutionResult(runId)
if (result?.status === 'success') {
console.log('Workflow completed:', result.steps)
} else if (result?.status === 'failed') {
console.log('Workflow failed:', result.error)
} else if (result?.status === 'running') {
console.log('Workflow still running...')
}