<@ULVA73B9P> is there a way to automatically delet...
# ask-marvin
a
@Marvin is there a way to automatically delete flows that have been deleted or renamed in the UI?
m
thought for 154.4 seconds
Not automatically, no. In Prefect 3.x, if you rename a flow or remove it from code, Prefect will generally create/use a flow record by name for new deployments, but it does not automatically remove the old flow entry from the UI. So stale/orphaned flow records can stick around until you delete them. Ways to clean them up: 1. Delete in the UI Open the flow’s detail page and delete it there. 2. Delete with the Python client You can do it programmatically:
Copy code
from 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