Live
Batch Deleting Cloudflare Workflow Instances via API and WranglerAI‑driven Rust migrations: GitHub Copilot runtime and Anthropic’s Bun rewriteMigrating to Managed Airflow Gen 3: Practical Takeaways from Pine59’s Airflow 3 UpgradeGoogle Threat Intelligence Achieves Forrester Leader Rating – What Engineers Need to KnowClaude Projects redesign adds parallel session coordination and shared memory – token impact and workflow changes for engineersR2 Data Catalog introduces UI for table maintenance and on‑demand compactionElastic Beanstalk Cluster Mode: Shared EKS Infra for Multi‑App DeploymentsScaling Secure Self‑Service AI Agents with Bedrock AgentCore, Strands, and LibreChatBatch Deleting Cloudflare Workflow Instances via API and WranglerAI‑driven Rust migrations: GitHub Copilot runtime and Anthropic’s Bun rewriteMigrating to Managed Airflow Gen 3: Practical Takeaways from Pine59’s Airflow 3 UpgradeGoogle Threat Intelligence Achieves Forrester Leader Rating – What Engineers Need to KnowClaude Projects redesign adds parallel session coordination and shared memory – token impact and workflow changes for engineersR2 Data Catalog introduces UI for table maintenance and on‑demand compactionElastic Beanstalk Cluster Mode: Shared EKS Infra for Multi‑App DeploymentsScaling Secure Self‑Service AI Agents with Bedrock AgentCore, Strands, and LibreChat
Cloudflare

Batch Deleting Cloudflare Workflow Instances via API and Wrangler

AI SummaryPowered by AI

Cloudflare now lets you delete a single Workflow instance or up to a hundred at once through the Workflows API or Wrangler 4.125.0 and later. This gives engineers a programmatic way to free stored state, stop running executions, and control storage‑related billing.

Cloudflare now lets you delete a single Workflow instance or up to a hundred at once through the Workflows API or Wrangler 4.125.0 and later. This gives engineers a programmatic way to free stored state, stop running executions, and control storage‑related billing.

API‑level deletion

Each instance can be obtained from the binding and removed with its delete() method. The call returns only when the platform has cleared the instance’s state and halted any in‑flight execution. If a workflow calls await instance.delete() on its own handle, the script stops at that point; any code after the call never runs.

const instance = await env.MY_WORKFLOW.get("instance-abc");
await instance.delete();

For bulk cleanup, the binding exposes deleteBatch(). The method accepts an array of up to 100 instance IDs and returns an object containing two arrays: deleted (the IDs that were successfully removed) and errors (per‑ID error details). Non‑existent IDs appear in errors. Duplicate IDs count toward the 100‑ID limit, are removed once, and the result entry is repeated for each occurrence in the input list.

const result = await env.MY_WORKFLOW.deleteBatch([
  "instance-abc",
  "instance-def",
]);
console.log(result.deleted);
console.log(result.errors);

Wrangler command‑line support

Wrangler 4.125.0+ mirrors the API capabilities. You can pass IDs directly on the command line, reference a JSON file that contains a top‑level array of strings, or combine both, as long as the total does not exceed 100 IDs.

npx wrangler workflows instances delete my-workflow instance-abc
npx wrangler workflows instances delete my-workflow instance-abc instance-def
npx wrangler workflows instances delete my-workflow latest

The special identifier latest targets the most recently created instance. When running against a local wrangler dev session, add the --local flag to operate on the in‑process emulator.

[
  "instance-abc",
  "instance-def"
]

Operational considerations

Deleting an instance immediately releases the storage allocated to that instance, which can affect the average daily peak metric used for billing. Because the deletion stops the workflow’s execution, any in‑progress tasks, timers, or external calls are aborted. Teams should therefore ensure that cleanup logic does not interrupt critical work or leave external systems in an inconsistent state.

The batch API’s error reporting lets you detect stale or misspelled IDs without failing the entire request. However, the limit of 100 IDs means very large fleets still require pagination or multiple calls. Duplicate IDs are tolerated but count against the limit, so callers should deduplicate inputs when possible to avoid unnecessary request overhead.

Related CloudNinjas coverage: hands-on guides.

What This Means For Practitioners

In practice, you can now embed instance cleanup into CI pipelines, scheduled jobs, or self‑healing scripts. Verify that any workflow that may delete itself does not rely on post‑deletion logic, and monitor the deleted and errors arrays to catch orphaned IDs. Use the latest shortcut for quick removal of test runs, and remember to run deletions with --local when debugging locally to avoid affecting production state.

Originally published atCloudflare Developer Platform