<@ULVA73B9P> After suspending a flow run, how can ...
# ask-marvin
j
@Marvin After suspending a flow run, how can I resume it using an automation
m
thought for 302.9 seconds
Short answer: yes—you can resume a suspended/paused flow run with a Prefect 3.x Automation using the built-in “Resume flow run” action. You can also do it via the REST API if you need more control. How to do it in the UI (no code) - Go to Automations → New automation - Trigger - Type: Flow run entered state - State: Paused (this corresponds to the event
prefect.flow-run.paused
) - Add filters as needed (flow name, deployment, tags, etc.) - Action - Choose: Resume flow run - Optional: Provide Run input (JSON) if your flow expects it when resuming - Save Notes - If your flow paused with a required run input schema (e.g., you used a pause step that prompts for input), you must provide matching JSON in the action’s “Run input” or the resume will fail. - You can optionally add a delay to the automation if you want to resume after some time rather than immediately. API option (if you prefer programmatic control) - Use the REST endpoint to resume a flow run. Provide the
flow_run_id
and optional
run_input
. Docs: Resume flow run (REST API) Examples - Prefect Server (local/default):
Copy code
curl -X POST \
  "<http://127.0.0.1:4200/api/flow_runs/<FLOW_RUN_ID>/resume>" \
  -H "Content-Type: application/json" \
  -d '{"run_input": {"approved": true}}'
- Prefect Cloud:
Copy code
curl -X POST \
  "<https://api.prefect.cloud/api/accounts/<ACCOUNT_ID>/workspaces/<WORKSPACE_ID>/flow_runs/<FLOW_RUN_ID>/resume>" \
  -H "Authorization: Bearer <PREFECT_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"run_input": {"approved": true}}'
Follow-up - Do you want the run to resume immediately upon pausing, after a delay, or only when certain conditions are met? - Does your paused step require a specific
run_input
? If so, share the schema or an example and I can help you configure the action JSON.
j
@Marvin, resuming a suspended flow would require the automation to pass the run id as part of the resume flow run action. Does automation actions support this?
m
thought for 67.4 seconds
Yes—when you use the “Resume flow run” action in a Prefect 3 automation, you do not need to pass the flow run ID yourself. The action automatically targets the flow run from the triggering event (e.g., when a run enters the Paused state from the
prefect.flow-run.paused
event). In the UI, the only optional field you’ll typically provide is the “Run input” JSON if your paused step expects input. If you ever need to resume a different flow run (not the one that triggered the automation), use a generic HTTP/Webhook action and call the REST API yourself with the desired `flow_run_id`: - REST docs: Resume flow run (REST API) Example (Cloud):
Copy code
curl -X POST \
  "<https://api.prefect.cloud/api/accounts/<ACCOUNT_ID>/workspaces/<WORKSPACE_ID>/flow_runs/<FLOW_RUN_ID>/resume>" \
  -H "Authorization: Bearer <PREFECT_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"run_input": {"approved": true}}'
j
@Marvin, what would that automation look like in yaml
m
thought for 191.7 seconds
Great question. Two key points up front: - Automations auto-target the flow run from the triggering event, so you do not need to pass a
flow_run_id
in the action. - Prefect 3 doesn’t support creating automations via a YAML-importing CLI command. You create them in the UI or via the REST API (JSON). You can author the payload in YAML if you want, then convert to JSON for the API call. Below is an example “shape” of the automation as YAML, followed by the exact JSON you can POST to the API. The YAML is illustrative; the API accepts JSON. Example YAML (illustrative)
Copy code
name: Resume paused flow runs
enabled: true
description: Automatically resume any flow run when it enters Paused
trigger:
  type: event
  # Listen for flow runs entering the Paused state
  match:
    - event: prefect.flow-run.paused
  # Optional: add narrowing filters (flow name, deployment name, tags, etc.)
  # filters:
  #   flow_names: ["my-flow"]
  #   deployment_names: ["my-deployment"]
actions:
  - type: resume_flow_run
    # Optional input if your pause step expects it
    run_input:
      approved: true
Equivalent JSON to create via REST
Copy code
{
  "name": "Resume paused flow runs",
  "enabled": true,
  "description": "Automatically resume any flow run when it enters Paused",
  "trigger": {
    "type": "event",
    "match": [
      { "event": "prefect.flow-run.paused" }
    ]
    // Optionally add filters here if you want to scope to certain flows/deployments/tags
  },
  "actions": [
    {
      "type": "resume_flow_run",
      "run_input": { "approved": true }
    }
  ]
}
API endpoints - Prefect Cloud: - POST https://api.prefect.cloud/api/accounts/&lt;ACCOUNT_ID&gt;/workspaces/&lt;WORKSPACE_ID&gt;/automations - Prefect Server (local/default): - POST http://127.0.0.1:4200/api/automations Docs - Create automation (REST) - Resume flow run (REST) Example curl (Cloud)
Copy code
curl -X POST \
  "<https://api.prefect.cloud/api/accounts/<ACCOUNT_ID>/workspaces/<WORKSPACE_ID>/automations>" \
  -H "Authorization: Bearer <PREFECT_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Resume paused flow runs",
    "enabled": true,
    "trigger": {
      "type": "event",
      "match": [{ "event": "prefect.flow-run.paused" }]
    },
    "actions": [
      {
        "type": "resume_flow_run",
        "run_input": { "approved": true }
      }
    ]
  }'
Note on CLI: there is no
prefect automation create --from-file
in Prefect 3.x;
prefect automation
currently supports listing, inspecting, enabling/pausing, and deleting existing automations. If you want to scope this automation to only certain flows/deployments or add a delay before resuming, tell me the criteria and I’ll tailor the payload.