Documentation Index Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
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:
Cancel workflows matching this exact URL. Cannot be combined with workflowUrlStartingWith.
Cancel workflows whose URL starts with this prefix. Cannot be combined with workflowUrl.
Cancel workflows with this label.
Cancel workflows created after this date. Accepts Date objects or Unix timestamps (ms).
Cancel workflows created before this date. Accepts Date objects or Unix timestamps (ms).
Cancel workflows triggered by this IP address.
Cancel workflows with this flow control key.
Maximum number of workflow runs to cancel per call. Defaults to 100.
Cancel all
Set to true to cancel all pending and active workflow runs.
Response
The number of workflow runs that were cancelled.
Usage
Cancel by ID
// cancel a single workflow
await client . cancel ( "<WORKFLOW_RUN_ID>" );
// cancel a set of workflow runs
await 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 label
await client . cancel ({ filter: { label: "my-label" } });
// cancel by label and date range
await client . cancel ({
filter: {
label: "my-label" ,
fromDate: 1640995200000 ,
}
});
// cancel by URL and date range
await 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 );