<@ULVA73B9P> Is there a way using the REST API to ...
# ask-marvin
a
@Marvin Is there a way using the REST API to restart a crashed flow run? Or do I need to kick off a new flow run from its parent deployment?
m
thought for 30.2 seconds
Yes, you can restart a crashed flow run using Prefect's REST API. You'll want to use the
POST /flow_runs/{id}/resume
endpoint. This endpoint is specifically designed for resuming/restarting flow runs that have failed or are in a paused state. Here's a quick example using `curl`:
Copy code
bash
curl -X POST '<https://api.prefect.cloud/api/accounts/{account_id}/workspaces/{workspace_id}/flow_runs/{flow_run_id}/resume>' \
  -H 'Authorization: Bearer YOUR_API_KEY'
Or if you're using Python with the
requests
library:
Copy code
python
import requests

response = <http://requests.post|requests.post>(
    f"<https://api.prefect.cloud/api/accounts/{account_id}/workspaces/{workspace_id}/flow_runs/{flow_run_id}/resume>",
    headers={"Authorization": f"Bearer {api_key}"}
)
This means you don't need to create a new flow run from the parent deployment - you can directly restart the failed run. The endpoint is documented in detail at: https://docs-3.prefect.io/v3/api-ref/rest-api/server/flow-runs/resume-flow-run Do note that this will restart the flow run with the same parameters and configuration as the original run. If you need to modify any parameters or configuration, you would indeed need to create a new flow run from the deployment instead.