Skip to main content
There are multiple ways you can cancel workflow runs. You can filter by IDs, URLs, dates, labels, or cancel all at once.

Arguments

ids
string | string[]
The workflow run ID or set of IDs you want to cancel.
urlStartingWith
string
Cancel workflows whose URL starts with this prefix. Cannot be combined with workflowUrl.
workflowUrl
string
Cancel workflows matching this exact URL. Cannot be combined with urlStartingWith.
fromDate
Date | number | string
Cancel workflows created after this date. Accepts Date objects, Unix timestamps (number), or numeric strings.
toDate
Date | number | string
Cancel workflows created before this date. Accepts Date objects, Unix timestamps (number), or numeric strings.
label
string
Cancel workflows with this label.
all
bool
Whether you want to cancel all workflow runs without any filter.

Response

Returns an object with the number of cancelled workflows:
cancelled
number
The number of workflow runs that were cancelled.

Usage

Cancel a set of workflow runs

// cancel a single workflow
await client.cancel({ ids: "<WORKFLOW_RUN_ID>" });

// cancel a set of workflow runs
await client.cancel({ ids: ["<WORKFLOW_RUN_ID_1>", "<WORKFLOW_RUN_ID_2>"] });

Cancel workflow runs with URL filter

If you have an endpoint called https://your-endpoint.com and you want to cancel all workflow runs on it, you can use urlStartingWith. Note that this will cancel workflows in all endpoints under https://your-endpoint.com.
await client.cancel({ urlStartingWith: "https://your-endpoint.com" });
For an exact URL match, use workflowUrl instead:
await client.cancel({ workflowUrl: "https://your-endpoint.com/api/workflow" });

Cancel with filters

You can combine multiple filter parameters:
// cancel by label
await client.cancel({ label: "my-label" });

// cancel by label and date range
await client.cancel({
  label: "my-label",
  fromDate: 1640995200000,
});

// cancel by URL and date range
await client.cancel({
  workflowUrl: "https://your-endpoint.com/api/workflow",
  fromDate: new Date("2024-01-01"),
  toDate: new Date("2024-06-01"),
});

Cancel all workflows

To cancel all pending and currently running workflows, you can do it like this:
await client.cancel({ all: true });