Storage
The World storage interface exposes four sub-interfaces for querying workflow data:
world.events: The append-only event log. This is the source of truth for all workflow state. See Event Sourcing for background.world.runs,world.steps,world.hooks: Materialized views derived from the event log, provided as convenience accessors for the most common query patterns.
world.events
The event log drives all workflow state. Use it for audit trails, debugging, and programmatic run cancellation.
events.create()
Create a new event for a workflow run. Most commonly used to cancel a run.
| Parameter | Type | Description |
|---|---|---|
runId | string | null | The workflow run ID (null only for run_created events, where the server generates an ID) |
data | CreateEventRequest | Event data including eventType |
params | object | Optional parameters |
Returns: EventResult, the created event and the affected entity (run/step/hook)
events.get()
Retrieve a single event by run ID and event ID.
| Parameter | Type | Description |
|---|---|---|
runId | string | The workflow run ID |
eventId | string | The event ID |
Returns: Event
events.list()
List events for a run. Omit pagination.limit to return every remaining event,
or set it to return one bounded page.
| Parameter | Type | Description |
|---|---|---|
params.runId | string | Filter events by run ID |
params.pagination.cursor | string | Cursor for the next page |
params.pagination.limit | number | Maximum events to return. When omitted, returns every remaining event up to the World's event ceiling. |
params.pagination.sortOrder | "asc" | "desc" | Event order |
params.resolveData | "all" | "none" | "skip-step-inputs" | Include or omit event payload data. "skip-step-inputs" is "all" without the input of step_created and step_started events, which replay does not read. |
Returns: { data: Event[], cursor: string | null, hasMore: boolean }
events.listByCorrelationId()
List one run's events that share a correlation ID, useful for tracing a single step, hook or wait through its lifecycle.
A correlation ID is unique within its run, not across runs: two runs can each hold a step_…, hook_… or wait_… ID that reads the same. runId is therefore required, and it is also what makes the pagination cursor unambiguous.
| Parameter | Type | Description |
|---|---|---|
params.runId | string | The run the correlation ID belongs to |
params.correlationId | string | The correlation ID to filter by |
params.pagination.cursor | string | Cursor for the next page |
Returns: { data: Event[], cursor?: string }
Event types
| Category | Types |
|---|---|
| Run | run_created, run_started, run_completed, run_failed, run_cancelled |
| Attribute | attr_set |
| Step | step_created, step_started, step_completed, step_failed, step_retrying |
| Hook | hook_created, hook_received, hook_disposed, hook_conflict |
| Wait | wait_created, wait_completed |
world.runs
Materialized from run events. Use it for canonical operational reads, including
reads that require workflow input or output data. For observability dashboards,
inspection tools, and historical listings, use
world.analytics.runs.list().
runs.get()
| Parameter | Type | Description |
|---|---|---|
runId | string | The workflow run ID |
params.resolveData | 'all' | 'none' | Whether to include input/output data. Default: 'all' |
Returns: WorkflowRun (or WorkflowRunWithoutData when resolveData: 'none')
runs.waitForTerminalStatus()
Optional. Long poll for a run to reach a terminal status (completed,
failed, or cancelled) instead of re-reading it on an interval. This is what
await run.returnValue uses, so a run's result reaches the awaiting side as
soon as it finishes rather than at the next poll tick.
| Parameter | Type | Description |
|---|---|---|
runId | string | The workflow run ID |
params.timeoutMs | number | Upper bound on the wait. The call returns earlier, the moment the run is terminal |
params.signal | AbortSignal | Abandons the wait |
params.resolveData | 'all' | 'none' | Whether to include input/output data. Default: 'all' |
Returns: the same WorkflowRun as runs.get(): terminal if the run
finished within the budget, otherwise the latest snapshot. An expired budget is
a normal return, not an error, and a missing run throws
WorkflowRunNotFoundError exactly as runs.get() does.
Not every backend can hold a read open, so this method is optional and may
also return a non-terminal snapshot before timeoutMs is up. Callers pace
their own retries (await run.returnValue keeps consecutive non-terminal
observations at least one WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS apart), and
worlds that omit the method are polled on that interval instead.
runs.list()
| Parameter | Type | Description |
|---|---|---|
params.workflowName | string | Only return runs of this workflow |
params.status | WorkflowRunStatus | WorkflowRunStatus[] | Only return runs in this status. Pass an array to match any of the listed statuses; an empty array matches no runs. @workflow/world-vercel accepts a single status only and throws WorkflowWorldError (INVALID_ARGUMENT) for an array |
params.pagination.cursor | string | Cursor for the next page |
params.pagination.sortOrder | "asc" | "desc" | Run creation order. Default: "desc" (newest first) |
params.resolveData | 'all' | 'none' | Whether to include input/output data |
Returns: { data: WorkflowRun[], cursor?: string }
The array form of status lets you express set filters without restating the
status vocabulary. @workflow/world exports
TERMINAL_WORKFLOW_RUN_STATUSES (['completed', 'failed', 'cancelled']) for
that purpose:
status: [] matches no runs, mirroring SQL IN (). To leave the filter
unset, omit the field entirely.
Support for the array form is per World. The Local and Postgres Worlds accept
it; the Vercel World's /v2/runs endpoint takes a single status today and
throws a WorkflowWorldError (INVALID_ARGUMENT) when given an array, rather
than silently filtering on something else.
Observability and inspection usage of world.runs.list() is deprecated. Use
world.analytics.runs.list()
for metadata-only, plan-aware queries backed by the observability pipeline.
world.runs.list() remains supported for operational and payload-bearing
reads.
Cancelling runs
To cancel a run, create a run_cancelled event through world.events.create() (see world.events above), or use the Workflow CLI or web interface helpers.
To cancel a batch in one call, a world may implement the optional runs.cancelMany({ runIds }). It returns a summary plus a per-run outcome (cancelled, already_cancelled, not_cancellable, not_found, or failed). Backends that omit it fall back to per-run cancellation automatically.
WorkflowRun type
| Field | Type | Description |
|---|---|---|
runId | string | Unique run identifier |
status | string | 'pending', 'running', 'completed', 'failed', 'cancelled' |
workflowName | string | Machine-readable workflow identifier |
input | any | Workflow input data (when resolveData: 'all') |
output | any | Workflow output data (when resolveData: 'all') |
error | any | Error data if the run failed |
startedAt | string | ISO timestamp when the run started |
completedAt | string | null | ISO timestamp when the run completed |
workflowName is a machine-readable identifier like workflow//./src/workflows/order//processOrder. Use parseWorkflowName() from workflow/observability to extract a display-friendly name.
world.steps
Materialized from step events. Use it to list steps, inspect their input/output, and build progress dashboards.
steps.get()
| Parameter | Type | Description |
|---|---|---|
runId | string | The workflow run ID that owns the step |
stepId | string | The step ID |
params.resolveData | 'all' | 'none' | Whether to include input/output data. Default: 'all' |
Returns: Step (or StepWithoutData when resolveData: 'none')
steps.list()
| Parameter | Type | Description |
|---|---|---|
params.runId | string | Filter steps by run ID |
params.pagination.cursor | string | Cursor for the next page |
params.pagination.sortOrder | "asc" | "desc" | Step creation order. Default: "desc" (newest first) |
params.resolveData | 'all' | 'none' | Whether to include input/output data |
Returns: { data: Step[], cursor?: string }
Step type
| Field | Type | Description |
|---|---|---|
runId | string | Parent workflow run ID |
stepId | string | Unique step identifier |
stepName | string | Machine-readable step identifier |
status | string | 'running', 'completed', 'failed' |
input | any | Step input data (when resolveData: 'all') |
output | any | Step output data (when resolveData: 'all') |
error | any | Error data if the step failed |
attempt | number | Current retry attempt number |
startedAt | string | ISO timestamp when the step started |
completedAt | string | null | ISO timestamp when the step completed |
retryAfter | string | null | ISO timestamp for next retry attempt |
Step input/output (I/O) is serialized using the devalue format. Use hydrateResourceIO() from workflow/observability to deserialize it for display. See hydrateResourceIO().
stepName is a machine-readable identifier like step//./src/workflows/order//processPayment. Use parseStepName() from workflow/observability to extract the shortName for display in a user interface.
world.hooks
Materialized from hook events. Hooks are pause points in workflows that wait for external input. Use this interface to look up hooks by ID or token, inspect metadata, and build UIs for pending approvals.
hooks.get()
| Parameter | Type | Description |
|---|---|---|
hookId | string | The hook ID |
Returns: Hook
hooks.getByToken()
Look up a hook by its token. Useful in webhook resume flows where you receive a token in the callback URL.
For runtime application code, prefer getHookByToken(). Use world.hooks.getByToken() when you are working directly with the World storage interface for custom tooling, admin views, or low-level integrations.
Hook-token lookup is the low-level form of the recommended idempotency flow: if a hook is already registered for your business key, reuse the hook's runId or resume that hook instead of starting another run. If no hook exists yet, start the workflow with start({ experimental_hook: { token } }), which creates the Hook atomically with the run and refuses a duplicate with HookConflictError naming the owner. On a World without atomic start Hooks, have the workflow create the deterministic hook near the beginning and check await hook.getConflict() to detect whether another run claimed the token first. See Run idempotency.
| Parameter | Type | Description |
|---|---|---|
token | string | The hook token |
Returns: Hook
hooks.list()
| Parameter | Type | Description |
|---|---|---|
params.pagination.cursor | string | Cursor for the next page |
Returns: { data: Hook[], cursor?: string }
Hook type
| Field | Type | Description |
|---|---|---|
runId | string | Parent workflow run ID |
hookId | string | Unique hook identifier |
token | string | Hook token for resuming |
ownerId | string | Owner (team/user) ID |
projectId | string | Project ID |
environment | string | Deployment environment |
metadata | object | Custom metadata attached to the hook |
isWebhook | boolean | Whether this is a webhook-style hook |
claimedFrom | { runId: string; hookId: string } | undefined | Set when this hook took its token from another run with experimental_force. Names that run and its hook |
Examples
List runs with pagination
Get a run: full data vs. metadata only
List steps for a progress dashboard
Hydrate step I/O
Cancel a run
Look up hook by token
The World-level Hook carries metadata as the raw serialized (and, on encrypting Worlds, encrypted) value, not the object the workflow passed to createHook(). To read the decoded value, use getHookByToken(), whose hook.metadata is a Promise that hydrates it on first access.
List events for audit trail
Related
- Event sourcing: How the event log powers workflow replay and state
getRun(): Higher-level API for working with individual runsworkflow/observability: Hydrate step I/O and parse display namesresumeHook(): Resume a workflow by sending a payload to a hook- Hooks: Core concepts for hooks and pause points
- Workflows and steps: Core concepts for steps