function createWorkflow<TInputSchema, TOutputSchema, TStateSchema>(config): WorkflowBuilder<TInputSchema, TOutputSchema, TStateSchema>;Defined in: packages/workflow-core/src/define/define-workflow.ts:198
Define a workflow. Returns a builder chain:
export const onboard = createWorkflow({ id: 'onboard', input: z.object({ userId: z.string() }), }) .middleware([requireUser, traced]) .handler(async (ctx) => { const profile = await ctx.step('load', () => loadProfile(ctx.user.id)) await ctx.sleep(60_000) const decision = await ctx.approve({ title: 'Continue?' }) return { ok: decision.approved } })
The handler's ctx argument carries everything: input, state, durable primitives (step, sleep, waitForEvent, ...), and any fields added by registered middleware. Helpers should accept a typed Ctx<...> argument to compose cleanly.
TInputSchema extends SchemaInput | undefined = undefined
TOutputSchema extends SchemaInput | undefined = undefined
TStateSchema extends SchemaInput | undefined = undefined
CreateWorkflowConfig<TInputSchema, TOutputSchema, TStateSchema>
WorkflowBuilder<TInputSchema, TOutputSchema, TStateSchema>