Skip to main content

Overview

start() initiates a new workflow execution and returns a Run object for tracking and interacting with the workflow. It handles argument serialization, event sourcing, and queuing the workflow for execution.

Usage

Signature

Parameters

WorkflowFunction | WorkflowMetadata
required
The workflow function to start. Must have a 'use workflow' directive and be properly compiled.
TArgs
Arguments to pass to the workflow function. Must be serializable.
StartOptions

Returns

Run
A Run object for interacting with the workflow execution. See Run API.

Examples

Basic Workflow Start

No Arguments

With Options

Start and Monitor

Start and Stream Results

Parallel Workflow Starts

Type-Safe Workflow Starts

Using Workflow Metadata

Error Handling

Run ID Generation

Each workflow run gets a unique ID in the format wrun_{ulid}. The ID is:
  • Generated client-side before execution
  • Globally unique and sortable by creation time
  • Used for tracking, logging, and event correlation

Serialization

Workflow arguments must be serializable. Supported types:
  • Primitives: string, number, boolean, null, undefined
  • Objects and arrays
  • Dates
  • URLs
  • Custom classes with proper serialization
  • Streams (automatically handled)

Trace Propagation

start() automatically propagates OpenTelemetry trace context to the workflow:

Best Practices

  1. Await the start call: Always await start() to ensure the workflow is queued
  2. Store run IDs: Save run.runId for later reference and monitoring
  3. Use type inference: Let TypeScript infer return types from workflow functions
  4. Handle start errors: Catch and handle errors from the start call separately from execution errors
  5. Serialize carefully: Ensure all arguments are serializable before passing to workflows
  6. Don’t start workflows from workflows: Use direct function calls or steps instead

See Also