# Source: https://upstash.com/docs/workflow/rest/runs/bulk-cancel.md

> ## 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.

# Bulk Cancel Workflows

> Cancel multiple workflow runs

Bulk cancel allows you to cancel multiple workflow runs at once.

<Warning>
  If you provide a list of workflow run IDs in the request body, only those specific workflow runs will be canceled.

  If you include the workflow URL parameter, all workflow runs matching the URL filter will be canceled.

  If the request body is empty, all workflow runs will be canceled.
</Warning>

This operation scans all your workflow runs and attempts to cancel them.
If a specific workflow run cannot be canceled, it will return an error message.
Therefore, some workflow runs may not be cancelled at the end.
In such cases, you can run the bulk cancel operation multiple times.

## Request

<ParamField body="workflowRunIds" type="Array">
  The list of workflow run IDs to cancel.
</ParamField>

<ParamField body="workflowUrl" type="string">
  The prefix filter to match workflow run URLs. Workflow runs with URLs starting with this prefix will be canceled.
</ParamField>

## Response

A cancelled object with the number of cancelled workflow runs.

```JSON  theme={"system"}
{
  "cancelled": number
}
```

<RequestExample>
  ```sh curl theme={"system"}
  curl -XDELETE https://qstash.upstash.io/v2/workflows/runs \
     -H "Content-Type: application/json" \
    -H "Authorization: Bearer <QSTASH_TOKEN>" \
    -d '{"workflowUrl": "https://example.com"}'
  ```

  ```js Workflow SDK theme={"system"}
  import { Client } from "@upstash/workflow";

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

  // cancel workflows starting with a url
  await client.cancel({ urlStartingWith: "https://your-endpoint.com" })

  // cancel all workflows
  await client.cancel({ all: true })
  ```

  ```js Node theme={"system"}
  const response = await fetch('https://qstash.upstash.io/v2/workflows/runs', {
    method: 'DELETE',
    headers: {
      'Authorization': 'Bearer <token>',
      'Content-Type': 'application/json',
      body: {
          workflowRunIds: [
              "run_id_1",
              "run_id_2",
              "run_id_3",
          ],
      },
    }
  });
  ```

  ```python Python theme={"system"}
  import requests

  headers = {
      'Authorization': 'Bearer <token>',
      'Content-Type': 'application/json',
  }

  data = {
    "workflowRunIds": [
      "run_id_1",
      "run_id_2",
      "run_id_3"
    ]
  }

  response = requests.delete(
    'https://qstash.upstash.io/v2/workflows/runs',
    headers=headers,
    data=data
  )
  ```

  ```go Go theme={"system"}
  var data = strings.NewReader(`{
    "workflowRunIds": [
      "run_id_1",
      "run_id_2",
      "run_id_3"
    ]
  }`)
  req, err := http.NewRequest("DELETE", "https://qstash.upstash.io/v2/workflows/runs", data)
  if err != nil {
    log.Fatal(err)
  }
  req.Header.Set("Authorization", "Bearer <token>")
  req.Header.Set("Content-Type", "application/json")
  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    log.Fatal(err)
  }
  defer resp.Body.Close()
  ```
</RequestExample>

<ResponseExample>
  ```json 202 Accepted theme={"system"}
  {
    "cancelled": 10
  }
  ```
</ResponseExample>