Functions
client.cancel
Cancel one or more workflow runs. You can pass IDs directly, use filters, or cancel all at once.
Arguments
The cancel method accepts one of the following:
By ID
Pass a single workflow run ID or an array of IDs directly:
await client.cancel("<WORKFLOW_RUN_ID>");await client.cancel(["<ID_1>", "<ID_2>"]);By filters
Pass an object with a filter field containing one or more filter criteria:
filterbodyobject
countbodynumber
Maximum number of workflow runs to cancel per call. Defaults to 100.
Cancel all
allbodyboolean
Set to true to cancel all pending and active workflow runs.
Response
cancellednumber
The number of workflow runs that were cancelled.
Usage
Cancel by ID
// cancel a single workflowawait client.cancel("<WORKFLOW_RUN_ID>");// cancel a set of workflow runsawait client.cancel(["<WORKFLOW_RUN_ID_1>", "<WORKFLOW_RUN_ID_2>"]);Cancel with URL filter
Cancel all workflow runs on a specific endpoint using a URL prefix:
await client.cancel({ filter: { workflowUrlStartingWith: "https://your-endpoint.com" }});For an exact URL match:
await client.cancel({ filter: { workflowUrl: "https://your-endpoint.com/api/workflow" }});Cancel with filters
You can combine multiple filter parameters:
// cancel by labelawait client.cancel({ filter: { label: "my-label" } });// cancel by label and date rangeawait client.cancel({ filter: { label: "my-label", fromDate: 1640995200000, }});// cancel by URL and date rangeawait client.cancel({ filter: { workflowUrl: "https://your-endpoint.com/api/workflow", fromDate: new Date("2024-01-01"), toDate: new Date("2024-06-01"), }});Cancel all workflows
let cancelled: number;do { const result = await client.cancel({ all: true }); cancelled = result.cancelled;} while (cancelled > 0);