Shubham
07/13/2026, 3:01 AMMarvin
07/13/2026, 3:01 AMMarvin
07/13/2026, 3:04 AMbash
prefect deployment run "my-flow/my-deployment"
Useful options available on this command include:
* --param / -p to pass parameters
* --job-variable / -jv to override job variables
* --start-in to schedule it in the future
* --start-at to run at a specific time
* --watch to wait and stream status until completion
* --watch-timeout to limit how long to wait
* --flow-run-name to set a custom run name
* --id to run by deployment ID instead of flow/deployment name
Example:
bash
prefect deployment run "my-flow/my-deployment" \
-p customer_id=123 \
-p force=true \
--watch
If you want the CLI to block until the run finishes, --watch is the easiest option.
You can inspect the command here:
prefect deployment run
---
## 2) Python SDK option
This is usually the best choice if you want to trigger a deployment from another app/service and programmatically get the result back.
### Trigger the deployment
python
import asyncio
from prefect.client.orchestration import get_client
from prefect.states import get_state_result
async def main():
async with get_client() as client:
flow_run = await client.create_flow_run_from_deployment(
deployment_id="YOUR-DEPLOYMENT-ID",
parameters={"customer_id": 123}
)
print("Created flow run:", flow_run.id)
while True:
flow_run = await client.read_flow_run(flow_run.id)
if flow_run.state.is_terminal():
break
await asyncio.sleep(2)
print("Final state:", flow_run.state.name)
if flow_run.state.is_completed():
result = await get_state_result(flow_run.state)
print("Result:", result)
asyncio.run(main())
### What this gives you
* create_flow_run_from_deployment(...) → starts the run
* read_flow_run(...) → polls until complete
* get_state_result(...) → fetches the returned flow result
---
## 3) REST API option
If you're calling Prefect from a non-Python system, use the API.
### Start a flow run from a deployment
bash
curl -X POST "<YOUR_PREFECT_API_URL>/deployments/<DEPLOYMENT_ID>/create_flow_run" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"parameters": {
"customer_id": 123
}
}'
This returns a flow run object including the new flow run ID.
### Then poll the flow run
bash
curl -X GET "<YOUR_PREFECT_API_URL>/flow_runs/<FLOW_RUN_ID>" \
-H "Authorization: Bearer <YOUR_API_KEY>"
From that response, check the run state until it reaches a terminal state like:
* COMPLETED
* FAILED
* CANCELLED
* CRASHED
---
## 4) Prefect UI option
From the UI you can:
* open the deployment
* click Run
* pass parameter values
* monitor the run live
This is the easiest manual option, but less suitable if you want to integrate with another system that expects a returned result automatically.
UI:
Prefect Cloud
---
## 5) Automations / event-driven option
A deployment can also be triggered indirectly by events or automations. This is useful if you want:
* another flow finishing to trigger this deployment
* a webhook/event to trigger a deployment
* scheduled or conditional orchestration
Docs:
Automations
---
# How do you “get the results back”?Marvin
07/13/2026, 3:04 AMpython
result = await get_state_result(flow_run.state)
Important caveat:
This works best when the flow result is persisted and retrievable from the environment where you’re reading it.
If your flow returns something simple like a dict/string/list, that’s straightforward.
If it returns large/custom Python objects, you need to think about serialization and result storage.
Docs:
Results and result persistence
---
# Best options by use case
## Option 1: “I just want to start it manually and watch”
Use:
bash
prefect deployment run "my-flow/my-deployment" --watch
## Option 2: “I want another Python app to trigger and wait for the result”
Use:
* Python SDK
* poll read_flow_run
* call get_state_result
## Option 3: “I want a remote service in another language to trigger it”
Use:
* REST API to create the flow run
* REST API to poll status
* optionally store outputs somewhere explicit like S3 / DB / object storage
## Option 4: “I need a robust machine-to-machine pattern”
A very common production pattern is:
* trigger deployment remotely
* let the flow write its business output to durable storage
* database
* S3/GCS/Azure Blob
* warehouse
* API callback
* use Prefect only for orchestration/state
This is often better than relying on the returned Python object as the integration boundary.
---
# Recommended architecture
If your question is specifically “run remotely and get results back”, the cleanest options are:
### Simple synchronous-style integration
* trigger deployment
* poll until terminal
* fetch get_state_result(...)
### Production integration
* trigger deployment
* poll for completion
* read output from external durable storage written by the flow itself
That second option is usually more reliable for larger or long-running workflows.
---
# Practical summary
Available ways to run a deployment remotely:
* prefect deployment run
* Python SDK create_flow_run_from_deployment(...)
* REST API POST /deployments/{id}/create_flow_run
* Prefect UI
* Automations/events
Ways to get something back:
* watch/poll run state
* fetch final result with get_state_result(...)
* or have the flow write outputs to external storage and read them there
---
If you want, I can give you one of these next:
1. a full Python example that waits for completion and returns the flow result
2. a REST API example for use from another service
3. the best pattern for large results (S3/DB/etc.)Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by