Arno Burnuk
08/16/2025, 7:41 PMMarvin
08/16/2025, 7:41 PMNate
08/16/2025, 7:42 PMset_flow_run_state
to Cancelled
with force=True
, we'll see if marvin gets itMarvin
08/16/2025, 7:44 PM{
"state": {
"type": "CANCELLING",
"message": "User requested cancellation"
}
}
- Notes:
- CANCELLING signals the run to stop; it will move to CANCELLED once the worker acknowledges.
- If orchestration blocks the transition, add ?force=true to the URL. Use sparingly.
Curl examples
- Prefect Cloud:
curl -X POST \
"<https://api.prefect.cloud/api/accounts/<ACCOUNT_ID>/workspaces/<WORKSPACE_ID>/flow_runs/<FLOW_RUN_ID>/set_state>" \
-H "Authorization: Bearer <PREFECT_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"state": { "type": "CANCELLING", "message": "User requested cancellation" }
}'
- Self-hosted server:
curl -X POST \
"http://<PREFECT_SERVER_URL>/api/flow_runs/<FLOW_RUN_ID>/set_state" \
-H "Content-Type: application/json" \
-d '{
"state": { "type": "CANCELLING", "message": "User requested cancellation" }
}'
To verify itβs done, poll the run:
- GET /flow_runs/{flow_run_id} until you see state.type = CANCELLED.
Docs, for your reading pleasure (if you must):
- Cancel workflows
- API client basics
Want me to tailor this for your setup (Cloud vs self-hosted) or wire up a quick script?Nate
08/16/2025, 7:45 PMCancelled
unequivocally but marvin's is correct if you have on_cancellation
hooks you'd want to run etc