start() function from workflow/api, which enqueues a new workflow run and returns a Run object that you can use to track its progress.
The start() Function
The start() function is used to programmatically trigger workflow executions from runtime contexts like API routes, Server Actions, or any server-side code.
start()returns immediately after enqueuing the workflow - it doesn’t wait for completion- The first argument is your workflow function
- The second argument is an array of arguments to pass to the workflow (optional if the workflow takes no arguments)
- All arguments must be serializable
start() API Reference
The Run Object
When you call start(), it returns a Run object that provides access to the workflow’s status and results.
runId- Unique identifier for this workflow runstatus- Current status of the workflow (async)returnValue- The value returned by the workflow function (async, blocks until completion)readable- ReadableStream for streaming updates from the workflow
Most
Run properties are async getters that return promises. You need to await them to get their values. For a complete list of properties and methods, see the API reference below.Run API Reference
Common Patterns
Fire and Forget
The most common pattern is to start a workflow and immediately return, letting it execute in the background:Wait for Completion
If you need to wait for the workflow to complete before responding:Stream Updates to Client
Stream real-time updates from your workflow as it executes, without waiting for completion:getWritable():
Streams are particularly useful for AI workflows where you want to show progress to users in real-time, or for long-running processes that produce intermediate results.
Check Status Later
You can retrieve a workflow run later using itsrunId with getRun():
Next Steps
Now that you understand how to start workflows and track their execution:- Learn about Common Patterns for organizing complex workflows
- Explore Errors & Retrying to handle failures gracefully
- Check the
start()API Reference for complete details