---
title: getRun
description: Retrieve workflow run metadata and status without waiting for completion.
docs_index: /llms.txt
lastUpdated: 2026-11-26
type: reference
summary: "Use getRun to check a workflow run's status and metadata without blocking on completion."
prerequisites:
  - /docs/foundations/starting-workflows
related:
  - /docs/foundations/idempotency
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

Retrieves workflow run metadata and status information for a given run ID. This function provides immediate access to workflow run details without waiting for completion.

Use this function when you need to check workflow status, get timing information, or access workflow metadata without blocking on workflow completion.

> `getRun()` retrieves a run when you already have its `runId`. It does not look up runs by a business key. For retried requests that should route to one active workflow, use a deterministic hook token and [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token). After a hook conflict, `HookConflictError.conflictingRunId` can be passed to `getRun()` to inspect, stream, or return the active owner. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).

```typescript lineNumbers
import { getRun } from "workflow/api";

const run = getRun("my-run-id");
```

## API signature

### Parameters

### Returns

Returns a `Run` object:

#### WorkflowReadableStream

`run.getReadable()` returns a `WorkflowReadableStream`, a standard `ReadableStream` extended with a `getTailIndex()` helper:

`getTailIndex()` returns the index of the last known chunk (0-based), or `-1` when no chunks have been written. This is useful when building [reconnection endpoints](/docs/ai/resumable-streams) that need to inform clients where the stream starts.

#### WorkflowReadableStreamOptions

#### WorkflowRunWritableStreamOptions

Use `run.writable` for the default stream or `run.getWritable(options)` to configure it. See [Writing to another run's stream](/docs/foundations/streaming#writing-to-another-runs-stream) for lifecycle details.

#### StopSleepOptions

#### StopSleepResult

## Examples

### Check if a run exists

Use the `exists` getter to check whether a workflow run exists without throwing when the run is not found:

```typescript lineNumbers
import { getRun } from "workflow/api";

export async function GET(req: Request) {
  const url = new URL(req.url);
  const runId = url.searchParams.get("runId");

  if (!runId) {
    return Response.json({ error: "No runId provided" }, { status: 400 });
  }

  const run = getRun(runId);

  if (!(await run.exists)) { // [!code highlight]
    return Response.json(
      { error: "Workflow run not found" },
      { status: 404 }
    );
  }

  const status = await run.status;
  return Response.json({ status });
}
```

### Basic status check

Check the current status of a workflow run:

```typescript lineNumbers
import { getRun } from "workflow/api";

export async function GET(req: Request) {
  const url = new URL(req.url);
  const runId = url.searchParams.get("runId");

  if (!runId) {
    return Response.json({ error: "No runId provided" }, { status: 400 });
  }

  try {
    const run = getRun(runId); // [!code highlight]
    const status = await run.status;

    return Response.json({ status });
  } catch (error) {
    return Response.json(
      { error: "Workflow run not found" },
      { status: 404 }
    );
  }
}
```

### Wake up a sleeping workflow

Interrupt pending `sleep()` calls to resume a workflow early. This is useful for testing workflows or building custom UIs that let users skip wait periods:

```typescript lineNumbers
import { getRun } from "workflow/api";

export async function POST(req: Request) {
  const { runId } = await req.json();
  const run = getRun(runId);

  // Wake up all pending sleep calls
  const { stoppedCount } = await run.wakeUp(); // [!code highlight]

  return Response.json({ stoppedCount });
}
```

You can also target specific sleep calls by correlation ID:

```typescript lineNumbers
import { getRun } from "workflow/api";

const { stoppedCount } = await run.wakeUp({
  correlationIds: ["wait_abc123"],
});
```

### Cancel a run

Cancel a workflow run. You can pass an optional free-text `cancelReason` (up to 512 characters) that is recorded on the run's cancellation event and shown in the run detail view:

```typescript lineNumbers
import { getRun } from "workflow/api";

export async function POST(req: Request) {
  const { runId } = await req.json();
  const run = getRun(runId);

  await run.cancel({ cancelReason: "Superseded by a newer submission" }); // [!code highlight]

  return Response.json({ cancelled: true });
}
```

The options object is optional: `await run.cancel()` cancels the run without recording a reason.

### Delete a finished run's data

Delete the stored data of a run that has finished: its input, output and error, its steps' and events' payloads, its hook payloads, and its stream contents. Metadata is not deleted: the run stays listed, and so do its steps, events and hooks, with their IDs, names, statuses, timestamps and attributes. Only the payloads go, reading back as expired. This cannot be undone. See [Data retention](/docs/observability/retention#deleting-a-finished-runs-data).

```typescript lineNumbers
import { getRun } from "workflow/api";

export async function POST(req: Request) {
  const { runId } = await req.json();

  const result = await getRun(runId).delete(); // [!code highlight]
  switch (result.outcome) {
    case "deleted":
    case "already_deleted":
    case "not_created":
      return Response.json({ deleted: true });
    case "skipped":
      // The run hasn't finished. Cancel it first to delete its data now.
      return Response.json({ deleted: false, status: result.status }, { status: 409 });
    case "not_found":
      return Response.json({ deleted: false }, { status: 404 });
    case "failed":
      // Deletion is idempotent: a retryable failure can be requested again.
      return Response.json(
        { deleted: false, retryable: result.retryable },
        { status: 503 }
      );
  }
}
```

`delete()` never cancels a run: a run that hasn't finished answers `skipped` and keeps running. It runs as a step, so inside a workflow a retryable failure throws a `RetryableError` and the step retries. It throws if the configured World doesn't support deleting run data. To delete the data of many runs in one call, use [`deleteRuns()`](/docs/api-reference/workflow-api/delete-runs).

## Related functions

- [`start()`](/docs/api-reference/workflow-api/start): Start a new workflow and get its run ID.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)