How can I toggle the schedule off for my flow deployment? (pause a schedule)

There are several ways to do it.

UI

API call

Prefect Cloud

import requests

API_KEY = "pnu_xxxx"


def set_schedule_inactive(
    deployment_id: str,
    base_url="https://api.prefect.cloud/api/accounts/c5276cbb-62a2-4501-b64a-74d3d900d781/workspaces/aaeffa0e-13fa-460e-a1f9-79b53c05ab36",
):
    return requests.post(
        url=f"{base_url}/deployments/{deployment_id}/set_schedule_inactive",
        headers={
            "Content-Type": "application/json",
            "Authorization": f"Bearer {API_KEY}",
        },
    )


if __name__ == "__main__":
    r = set_schedule_inactive("e3b5fed7-57a0-46dd-b836-593597da43aa")
    print(r.status_code)
    print(r.text)

Locally running Prefect 2.0

import requests


def set_schedule_inactive(deployment_id: str, base_url="http://127.0.0.1:4200/api"):
    return requests.post(
        url=f"{base_url}/deployments/{deployment_id}/set_schedule_inactive",
        headers={"Content-Type": "application/json"},
    )


if __name__ == "__main__":
    r = set_schedule_inactive("e3b5fed7-57a0-46dd-b836-593597da43aa")
    print(r.status_code)
    print(r.text)

CLI

In the future, we may add a CLI method for that too.

1 Like