Joshua Caskie
11/25/2025, 2:25 PMMarvin
11/25/2025, 2:25 PMMarvin
11/25/2025, 2:27 PMfrom prefect.runtime.flow_run import ui_url
print(ui_url) # e.g., <https://app.prefect.cloud/.../runs/flow-run/<id>>
or
from prefect.runtime.flow_run import get_flow_run_ui_url
print(get_flow_run_ui_url())
- Returns a string or None if you’re not in a flow run context.
- Uses your configured PREFECT_UI_URL (Cloud or Server).
- URL pattern is: {PREFECT_UI_URL}/runs/flow-run/<flow_run_id>
More flexible (when you have the FlowRun object):
from prefect.context import FlowRunContext
from prefect.utilities.urls import url_for
ctx = FlowRunContext.get()
if ctx:
print(url_for(ctx.flow_run)) # UI link
Docs:
- Runtime flow run helpers: prefect.runtime.flow_run
- Generic URL builder: prefect.utilities.urls.url_for
Need the task run or deployment link instead? I can share those snippets too.