Amir Kamal
05/25/2026, 6:35 AMMarvin
05/25/2026, 6:35 AMMarvin
05/25/2026, 6:38 AMfrom prefect import get_client
async def delete_flow(flow_id):
async with get_client() as client:
await client.delete_flow(flow_id)
If you need to find old flows first, you can list/filter flows and then delete them.
3. Use the REST API
There’s also a delete endpoint for flows:
Delete flow API
There is also a bulk delete endpoint in the server API, but it’s not as conveniently exposed through the Python client.
A few important notes:
- There is no automatic garbage collection for renamed/deleted flows.
- There is no prefect flow delete CLI command.
- Deleting a flow also deletes its associated deployments.
If you want, I can help you write a small cleanup script to remove:
- flows with no deployments
- flows matching an old naming pattern
- flows older than some date
Relevant docs:
- REST API: delete flow
- Python client reference
- Server flow model reference