<@ULVA73B9P> i will run prefect flows(deployemnts)...
# ask-marvin
m
@Marvin i will run prefect flows(deployemnts) via api, i want to change the flow run name based on flow paramerts passed through api , so i can easily see the each run specificaly in the prefect ui
m
thought for 439.5 seconds
Yes — you can set the flow run name at creation time, and it’s perfect for surfacing parameter values in the UI. Two common ways (Prefect 3.x): 1) Trigger via REST API (recommended since you’re calling the API) - Use the “create flow run from deployment” endpoint and include both
parameters
and
flow_run_name
in the payload. - Example:
Copy code
curl -X POST "$PREFECT_API_URL/deployments/<deployment_id>/create-flow-run" \
  -H "Content-Type: application/json" \
  -d '{
    "parameters": {
      "env": "prod",
      "customer_id": 1234,
      "run_date": "2025-08-29"
    },
    "flow_run_name": "prod-customer-1234-2025-08-29"
  }'
Docs: - REST: create flow run from deployment - If you are creating a run without a deployment, use the flow-runs endpoint which accepts
name
instead of `flow_run_name`: REST: create flow run 2) Trigger via Python SDK - Use
prefect.deployments.run_deployment
and pass `flow_run_name`:
Copy code
from prefect.deployments import run_deployment

params = {"env": "prod", "customer_id": 1234, "run_date": "2025-08-29"}
flow_run = await run_deployment(
    name="my-flow/my-deployment",
    parameters=params,
    flow_run_name=f"{params['env']}-customer-{params['customer_id']}-{params['run_date']}",
)
print(flow_run.name)
Notes: - The
flow_run_name
you pass when creating the run will override any default run name defined in the flow or deployment. - If you use the non-deployment flow run creation endpoint, the field is
name
(not
flow_run_name
), and you also need to provide
flow_id
(or use a deployment whenever possible). Want me to tailor a
curl
example to your exact deployment and parameter names? If you share the deployment name/ID and the parameters you pass, I’ll format it for you.