API for cancelling a flow run

I’ve read the api docs and can’t seem to find a way to cancel a run using the API.
I’d ideally like to be able to cancel just like using the cancel button in Prefect Flow Run Page on the top right, but with the API.
https://app.prefect.cloud/api/docs?deviceId=e88f7108-4f0b-4780-80e6-f531d41dd2b5#tag/Flow-Runs

Is there a work around for this?

Hello!
It’s not immediately obvious but you can make a POST request to the flow run’s set_state endpoint.

curl --location 'https://localhost:4200/api/flow_runs/<your-flow-run-id>/set_state' \
--header 'Content-Type: application/json' \
--data '{
    "state": {
        "type": "CANCELLED",
        "name": "Cancelled",
        "message": "cancelled msg tehe"
    },
    "force": false
}'

I’m doing the equivalent of this curl command in node.js and it seems to work as expected.

My guess is this creates a new State entity and binds it to the flow run automatically (verified that the flow run’s state object is using the new properties and state id).