惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
美团技术团队
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
有赞技术团队
有赞技术团队
GbyAI
GbyAI
宝玉的分享
宝玉的分享
腾讯CDC
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
月光博客
月光博客
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog

Workflow SDK Documentation

Patterns for Defining Tools Human-in-the-Loop Building Durable AI Agents Queueing User Messages Resumable Streams Sleep, Suspense, and Scheduling Streaming Updates from Tools API Reference Workflow Globals Changelog Resilient run start Cookbook Building a World Deploying Astro Express Fastify Hono Getting Started NestJS Next.js Nitro Nuxt Python SvelteKit Vite corrupted-event-log fetch-in-workflow hook-conflict Errors
start
2026-05-31 · via Workflow SDK Documentation

Start and enqueue a new workflow run.

Start/enqueue a new workflow run.

import { start } from "workflow/api";
import { myWorkflow } from "./workflows/my-workflow";

const run = await start(myWorkflow); 

Parameters

This function has multiple signatures.

Signature 1

NameTypeDescription
workflowWorkflowFunction<TArgs, TResult> | WorkflowMetadataThe imported workflow function to start.
argsunknown[]The arguments to pass to the workflow (optional).
optionsStartOptionsWithDeploymentIdThe options for the workflow run (optional).

Signature 2

NameTypeDescription
workflowWorkflowMetadata | WorkflowFunction<[], TResult>
optionsStartOptionsWithDeploymentId

Signature 3

NameTypeDescription
workflowWorkflowMetadata | WorkflowFunction<TArgs, TResult>
argsTArgs
optionsStartOptionsWithoutDeploymentId

Signature 4

NameTypeDescription
workflowWorkflowMetadata | WorkflowFunction<[], TResult>
optionsStartOptionsWithoutDeploymentId

StartOptions

NameTypeDescription
deploymentId"latest" | (string & {}) | undefinedThe deployment ID to use for the workflow run. By default, this is automatically inferred from environment variables when deploying to Vercel. Set to 'latest' to automatically resolve the most recent deployment for the current environment (same production target or git branch). This is currently a Vercel-specific feature. **Note:** When deploymentId is provided, the argument and return types become unknown since there is no guarantee the types will be consistent across deployments.
worldWorldThe world to use for the workflow run creation, by default the world is inferred from the environment variables.
specVersionnumberThe spec version to use for the workflow run. Defaults to the latest version.
attributesRecord<string, string>Plaintext attributes to seed on the run as it is created. Available for native-attributes runs (spec version 4 and later).
allowReservedAttributesbooleanPermit reserved $-prefixed keys in attributes. The $ namespace is reserved for framework/library code built on top of the workflow SDK (telemetry, agent metadata, platform-emitted tags, etc.); user code MUST NOT write keys in it, and validation rejects them so accidental collisions with tooling-owned keys can't slip through. Only flip this to true if your caller is itself a framework or library that owns a $-prefixed sub-namespace and knows the conventions of any other tools writing into it. Same semantics as the experimental_setAttributes option of the same name.

Returns

Returns a Run object:

NameTypeDescription
#privateany
runIdstringThe ID of the workflow run.
wakeUp(options?: StopSleepOptions | undefined) => Promise<StopSleepResult>Interrupts pending sleep() calls, resuming the workflow early.
cancel() => Promise<void>Cancels the workflow run.
existsPromise<boolean>Whether the workflow run exists.
statusPromise<"pending" | "running" | "completed" | "failed" | "cancelled">The status of the workflow run.
returnValuePromise<TResult>The return value of the workflow run. Polls the workflow return value until it is completed.
workflowNamePromise<string>The name of the workflow.
createdAtPromise<Date>The timestamp when the workflow run was created.
startedAtPromise<Date | undefined>The timestamp when the workflow run started execution. Returns undefined if the workflow has not started yet.
completedAtPromise<Date | undefined>The timestamp when the workflow run completed. Returns undefined if the workflow has not completed yet.
readableWorkflowReadableStream<any>The readable stream of the workflow run.
getReadable<R = any>(options?: WorkflowReadableStreamOptions | undefined) => WorkflowReadableStream<R>Retrieves the workflow run's default readable stream, which reads chunks written to the corresponding writable stream getWritable . The returned stream has an additional WorkflowReadableStream.getTailIndex getTailIndex() helper that returns the index of the last known chunk. This is useful when building reconnection endpoints that need to inform clients where the stream starts.

Learn more about WorkflowReadableStreamOptions.

  • The start() function is used in runtime/non-workflow contexts to programmatically trigger workflow executions.
  • This is different from calling workflow functions directly, which is the typical pattern in Next.js applications.
  • The function returns immediately after enqueuing the workflow - it doesn't wait for the workflow to complete.
  • All arguments must be serializable.
  • When deploymentId is provided, the argument types and return type become unknown since there is no guarantee the workflow function's types will be consistent across different deployments.

If start() throws 'start' received an invalid workflow function. Ensure the Workflow Development Kit is configured correctly and the function includes a 'use workflow' directive., the passed function was not transformed as a workflow. The two most common causes are a missing "use workflow" directive or missing framework integration. See start-invalid-workflow-function.

With Arguments

import { start } from "workflow/api";
import { userSignupWorkflow } from "./workflows/user-signup";

const run = await start(userSignupWorkflow, ["user@example.com"]); 

With StartOptions

import { start } from "workflow/api";
import { myWorkflow } from "./workflows/my-workflow";

const run = await start(myWorkflow, ["arg1", "arg2"], { 
  deploymentId: "custom-deployment-id"
}); 

Using deploymentId: "latest"

Set deploymentId to "latest" to automatically resolve the most recent deployment for the current environment. This is useful when you want to ensure a workflow run targets the latest deployed version of your application rather than the deployment that initiated the call. For when to use this and how it fits with default run pinning, see Versioning.

import { start } from "workflow/api";
import { myWorkflow } from "./workflows/my-workflow";

const run = await start(myWorkflow, ["arg1", "arg2"], { 
  deploymentId: "latest"
}); 

The deploymentId option is currently a Vercel-specific feature. Other Worlds may implement this option differently to match their own deployment runtimes, and the World spec may rename it from deploymentId to version in a future SDK version. On Vercel, "latest" resolves to the most recent deployment matching your current environment — the same production target for production deployments, or the same git branch for preview deployments.

When using deploymentId: "latest", the workflow run will execute on a potentially different deployment than the one calling start(). Be mindful of forward and backward compatibility:

  • Workflow identity: The workflow ID is derived from the function name and file path. If the latest deployment has renamed the workflow function or moved it to a different directory, the workflow ID will no longer match and the run will fail to start.
  • Input and output compatibility: The arguments passed to start() are serialized by the calling deployment but deserialized by the target deployment. Similarly, the workflow's return value is serialized by the target deployment but deserialized by the caller. If the workflow's expected arguments or return type have changed (e.g. added required fields, removed fields, or changed types), the run may fail or behave unexpectedly. Ensure that input and output schemas remain backward-compatible across deployments.