Tutorials

How to Delete Vercel Workflow Run Data with TypeScript

Workflow SDK 5.7 lets you delete the stored inputs, outputs, and event payloads of finished runs while preserving execution metadata. Here's how the API behaves, including skipped runs and batch failures.

A workflow finishes processing a document. The result is saved, the application receives its notification, and the job is complete.

But what happens to the information the workflow used while running?

The document’s contents may still exist in stored inputs, intermediate step outputs, or event payloads. Even when the application no longer needs that information, the Workflow SDK can retain it for debugging and observability.

That is useful when investigating a failed execution. It becomes less desirable when the workflow processes personal information or other data that should not remain accessible indefinitely.

On November 24, 2026, Vercel introduced on-demand run data deletion in Workflow SDK 5.7.0.

Developers can now remove the stored data of finished workflow runs through TypeScript, the CLI, or the Vercel Dashboard.

The interesting detail is what deletion means here.

The workflow’s stored payloads disappear, but its execution record remains available.

What gets deleted?

Consider a workflow that processes a customer document.

It might receive the document text as input, extract information in several steps, and return a structured result.

The Workflow SDK may retain data associated with each stage.

Calling the new deletion API removes stored data from the run and its related entities.

However, it does not remove every record of the execution.

Deleted Preserved
Workflow inputs and outputs Run ID and status
Workflow and step errors Run and step timestamps
Step inputs and outputs Step names and IDs
Event and hook payloads Event and hook records
Stream contents Attributes and hook tokens

After deletion, the run remains visible in observability tools, but its deleted payloads are no longer readable.

This is useful when you want to preserve information such as whether a workflow completed successfully and how long its steps took, without retaining the data those steps processed.

There is a limitation worth considering: attributes and other preserved metadata may themselves contain information you consider sensitive.

Deleting payloads does not automatically sanitize everything associated with a run.

The distinction should influence what your application stores in attributes in the first place.

1. Update Workflow SDK

In an existing project using the Workflow SDK, update the package:

pnpm add workflow@^5.7.0

The deletion API requires version 5.7.0 or later.

You can inspect the installed version with:

pnpm list workflow

The examples below assume your project already has a configured Workflow SDK backend and existing workflow runs.

There is no need to create another workflow merely to delete data from one that has already completed.

2. Delete the data of a single run

The simplest method is getRun().delete().

import { getRun } from "workflow/api";

const runId = "YOUR_RUN_ID";

const result = await getRun(runId).delete();

console.log(result);

Replace YOUR_RUN_ID with an actual run identifier returned by your application.

For example, when starting a workflow:

const run = await start(processDocument, [documentId]);

const runId = run.runId;

Here, processDocument represents a workflow already defined in your project.

The deletion call uses the run ID to identify the stored data.

But notice that we store the result of delete() instead of assuming the operation succeeded.

A run might still be active, might already have been deleted, or might not exist.

The method reports those situations through an outcome.

For example:

import { getRun } from "workflow/api";

async function deleteRunData(runId: string) {
  const result = await getRun(runId).delete();

  switch (result.outcome) {
    case "deleted":
      console.log("Stored run data deleted");
      break;

    case "already_deleted":
      console.log("Run data was already removed");
      break;

    case "skipped":
      console.log(
        `Run is still active: ${result.status}`
      );
      break;

    case "not_found":
      console.log("Run not found");
      break;

    case "not_created":
      console.log("Run was cancelled before creation");
      break;

    case "failed":
      console.error(
        "Deletion failed; retryable:",
        result.retryable
      );
      break;
  }

  return result;
}

This is a better approach for administrative tools, where the interface needs to show whether the requested operation actually happened.

The deletion itself cannot be undone.

Once the payloads have been removed, the SDK does not provide an API to recover them.

3. Delete several runs at once

What if your application processes hundreds of documents every day?

Deleting each run individually would require many separate calls.

Workflow SDK 5.7 adds deleteRuns() for batch deletion.

import { deleteRuns } from "workflow/api";

const { summary, results } = await deleteRuns([
  "run-id-1",
  "run-id-2",
  "run-id-3"
]);

console.log(summary);

for (const result of results) {
  console.log(result.runId, result.outcome);
}

A single call supports up to 100 run IDs.

The method returns a summary and individual results in the same order as the supplied IDs.

Possible outcomes include:

Outcome Meaning
deleted Data was successfully removed
already_deleted Data had already been removed
skipped The run has not finished
not_created The run was cancelled before creation
not_found No run matches the ID
failed The deletion did not complete

This matters when a batch contains runs in different states.

Suppose you submit ten IDs, but two workflows are still processing data.

The SDK does not cancel those workflows to complete your request.

Instead, the active runs are skipped.

The results tell you which operations completed and which require further attention.

There are also input restrictions. deleteRuns() throws if the array is empty, contains duplicate IDs, or exceeds 100 IDs.

For larger cleanup jobs, split the IDs into batches of 100 or fewer.

Deletion is idempotent, so retrying an already deleted run is safe. Outside a workflow step, retryable failures are returned to the caller, which must decide whether and when to retry.

Inside a workflow step, the SDK has additional retry handling for supported failures.

4. Delete run data from the CLI

You do not need to write application code for every one-time cleanup.

The Workflow SDK CLI can delete stored data directly.

For a locally configured workflow backend:

pnpx workflow delete YOUR_RUN_ID

For a run deployed to Vercel’s Preview environment:

pnpx workflow delete YOUR_RUN_ID --backend vercel --env preview

Replace YOUR_RUN_ID with the real identifier.

The backend and environment must correspond to the run you intend to modify.

A local run and a Preview deployment are not necessarily stored in the same backend.

Vercel also supports deleting finished run data through its Dashboard, which can be more convenient when you’re investigating a specific execution.

But the meaning of the operation remains the same: stored payloads are removed while execution metadata is preserved.

5. Why running workflows are skipped

Suppose a workflow is waiting for an external response.

It may still need its stored inputs, intermediate results, or event data to continue.

Deleting those values during execution could leave the workflow without information needed to finish.

For that reason, the new API only deletes the data of finished runs.

A workflow that is running, sleeping, or waiting for a hook is skipped.

Importantly, delete() is not equivalent to cancel().

If you need to stop an active run, the SDK provides a separate operation:

import { getRun } from "workflow/api";

const run = getRun("YOUR_RUN_ID");

await run.cancel();

After the run reaches a terminal state, its stored data can be deleted.

Cancellation is a separate decision because it changes the execution itself.

Deleting data from a completed workflow should not unexpectedly terminate another operation that is still doing useful work.

6. Automatically delete data when a run finishes

On-demand deletion is useful when a user requests removal or when an administrator decides to purge particular runs.

But what if you already know that no workflow payload should remain after completion?

In that case, repeatedly calling deleteRuns() may be unnecessary.

Workflow SDK supports a retention setting when starting a run:

import { start } from "workflow/api";

const run = await start(
  processDocument,
  [documentId],
  {
    experimental_retention: 0
  }
);

Setting experimental_retention to 0 asks the configured Workflow SDK backend, called a World, to delete the run’s user data when it reaches a terminal state.

The alternative value, "default", uses the backend’s normal retention policy.

This setting is experimental, so its name and supported values may change.

There is also a significant consequence.

If the payload is deleted immediately, reading the workflow’s return value afterward may fail with RunExpiredError.

The data can disappear before the application retrieves it.

So do not enable immediate deletion without considering whether another part of your application still needs the result.

If the result must be retained elsewhere, design that transfer explicitly.

Also verify that your chosen World supports the retention feature. The SDK records the preference, but the backend is responsible for enforcing it.

7. Does deletion remove all traces of the data?

No.

The API deletes data stored by the Workflow SDK backend for the selected run.

It does not promise to remove copies that your workflow previously sent elsewhere.

Imagine a document-processing workflow that:

  1. Receives a document.
  2. Sends its contents to an external AI service.
  3. Stores the extracted information in PostgreSQL.
  4. Returns a result.

Deleting the Workflow SDK run payload does not automatically delete the database record or information retained by the external service.

Those systems have their own storage and deletion rules.

The same applies to application logs that may have recorded part of the input or output.

Even inside Workflow SDK, metadata such as attributes and timestamps remains available for the backend’s normal metadata retention period.

This means the new API can be an important part of a data-retention policy, but it is not a complete privacy-compliance solution by itself.

Applications processing sensitive information still need to account for every location where that information may be stored.

When should you use delete() instead of retention?

The two approaches solve slightly different problems.

Use getRun().delete() or deleteRuns() when a particular finished run needs to be cleared on demand.

For example, a customer may request deletion of data associated with a completed document-processing operation.

Use experimental_retention: 0 when the workflow is designed to discard its stored payload automatically after finishing.

The first approach gives you control over specific existing runs.

The second establishes a retention preference before execution begins.

Neither approach removes the execution history itself.

That is intentional.

Vercel’s November 24 release separates the information required to understand that a workflow ran from the data it processed during execution.

For systems that need observability without indefinite payload retention, that separation is useful.

But it also means deletion results must be checked, metadata must be handled carefully, and external copies remain outside the SDK’s responsibility.

The API is small:

await getRun(runId).delete();

What deserves more attention is not the method call, but the precise data it removes—and the data it leaves behind.

External Sources used for this article

Related Articles

View all →