Akram Gharbi
11/26/2025, 1:11 PMMarvin
11/26/2025, 1:11 PMMarvin
11/26/2025, 1:18 PMdeployment_id and tags.
Useful references:
- Filters API (FlowRunFilterTags, FlowRunFilterDeploymentId, etc.)
- Flow Runs REST API (supports filtering by deployment and tags)
- Saved Searches API
If you’d like, I can file a feature request to:
- Scope tag suggestions to the current context (flow/deployment), and/or
- Add a tags filter to the deployment runs tab.
Would you like me to open that on your behalf?Akram Gharbi
11/26/2025, 1:27 PMMarvin
11/26/2025, 1:27 PMMarvin
11/26/2025, 1:29 PMfrom prefect.client.orchestration import get_client
from prefect.client.schemas.filters import FlowRunFilter, FlowRunFilterTags, FlowRunFilterDeploymentId, DeploymentFilter
async def runs_for_deployment_with_tag(deployment_id: str, tag: str):
async with get_client() as client:
return await client.read_flow_runs(
flow_run_filter=FlowRunFilter(
tags=FlowRunFilterTags(all_=[tag]),
deployment_id=FlowRunFilterDeploymentId(any_=[deployment_id]),
)
)
- You can also pull the unique tags from those runs to build your own context-scoped tag list.
What are Saved Searches?
- Saved Searches let you store a set of filters (deployment, states, tags, time windows, etc.) and reuse them in the UI with one click.
- Typical flow:
1) Build the filters you want on the Runs page
2) Click “Save search”, give it a name (e.g., “Flow 1 – Prod tag”)
3) Reuse it anytime from the Saved Searches dropdown
Docs:
- Filters API: Filter schemas (FlowRunFilterTags, FlowRunFilterDeploymentId, etc.)
- Flow Runs REST: Flow Runs REST API
- Saved Searches API: Saved Searches API
Feature request filed
- I’ve opened a discussion/feature request to:
- Scope tag suggestions to the current context (flow/deployment)
- Add a Tags filter on the Deployment Runs tab
- You can follow and add details here: Prefect Discussion #19556
If you share your workflow details (e.g., specific tags, flows, or screenshots), I can tailor a Saved Search or a short script that lists the tags seen for just that deployment.Akram Gharbi
11/26/2025, 1:41 PMMarvin
11/26/2025, 1:41 PMMarvin
11/26/2025, 1:44 PM# Create or update a saved search
curl -X PUT "$PREFECT_API_URL/api/saved_searches/" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PREFECT_API_KEY" \
-d '{
"name": "My Deployment + Tag",
"filters": [
{
"object": "deployment",
"property": "id",
"type": "string",
"operation": "any_",
"value": ["<your-deployment-id>"]
},
{
"object": "flow_run",
"property": "tags",
"type": "array",
"operation": "all_",
"value": ["<your-tag>"]
}
]
}'
# List saved searches
curl -X POST "$PREFECT_API_URL/api/saved_searches/filter" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PREFECT_API_KEY"
Using Python (async)
import httpx
import os
api_url = os.environ.get("PREFECT_API_URL", "<http://localhost:4200>")
api_key = os.environ.get("PREFECT_API_KEY") # required for Cloud
payload = {
"name": "My Deployment + Tag",
"filters": [
{
"object": "deployment",
"property": "id",
"type": "string",
"operation": "any_",
"value": ["<your-deployment-id>"]
},
{
"object": "flow_run",
"property": "tags",
"type": "array",
"operation": "all_",
"value": ["<your-tag>"]
}
]
}
headers = {"Content-Type": "application/json"}
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
async def create_saved_search():
async with httpx.AsyncClient() as client:
r = await client.put(f"{api_url}/api/saved_searches/", json=payload, headers=headers)
r.raise_for_status()
return r.json()
Notes and limitations
- Some 3.x Server UIs don’t currently expose “Save search” in the Runs page. The API works regardless, and those saved searches will appear once the UI control is available.
- You can still avoid Saved Searches altogether by querying runs directly via filters:
- Filters reference: Filter schemas (FlowRunFilterTags, FlowRunFilterDeploymentId, etc.)
- Flow Runs REST: Flow Runs REST API
Feature request
- I opened this request to improve the UI:
- Scope tag suggestions to current flow/deployment
- Add a Tags filter to the deployment’s Runs tab
- Track it here: Prefect Discussion #19556
If you share your environment (Cloud vs Server + version) and your deployment name/tag, I’ll craft the exact JSON and POST it for you, and also show how to find the deployment ID quickly if you don’t have it.