I want to cancel every currently scheduled run for...
# prefect-community
I want to cancel every currently scheduled run for one of my flows basically
Hi @Zach - I think the most straightforward way to do this (assuming these were programmatically-created runs and not auto-scheduled runs) would be to use the python graphql client with a query like this:
Copy code
query {
  flow_run(where: { flow_id: { _eq: "<<flow_id>>" }, state: { _eq: "Scheduled" } } ) {
and then map over that list something like this:
Copy code
mutation_contents = ""

for i, id in enumerate(flow_run_ids):
  mutation_contents += f"""
    cancel_{i}: cancel_flow_run(input: { flow_run_id: {id} }) {

mutation = f"""
  mutation {
Oops, the client also exposes that mutation so you could make that even more straightforward:
Copy code
from prefect.client import Client

client = Client()

for id in flow_run_ids: