Cancel many runs
POST/
Cancels up to 200 runs: queued, running or held.
Needs an API token with the Cancel and delete permission for runs (run:manage).
Parameters
Body
idsRequired · array of stringsUp to 200 run IDs. Repeats are taken once.
One by one
A queued run leaves the line and never runs. A held run is settled. A running one is asked to stop. A finished run is left as it is: ok: true, cancelled: false.
An ID from another workspace answers NOT_FOUND and isn’t touched. See Cancel a run.
Responses
- 200OK
Each ID’s answer in
results, as Cancel a run gives it. No IDs, or more than 200.
- 403
FORBIDDENThe token lacks the Cancel and delete permission for runs.
A read or write failed. Try again.
Any call can also answer: 401 UNAUTHORIZED · 401 TOKEN_ENDED · 403 TOKEN_SURFACE_OFF · 403 FEATURE_OFF · 403 EMBED_NOT_ALLOWED · 403 EMBED_NOT_AVAILABLE · 403 ACCOUNT_SUSPENDED · 413 PAYLOAD_TOO_LARGE · 415 INVALID_CONTENT_TYPE · 429 RATE_LIMITED · 503 BUSY · 503 PAUSED · 503 SERVICE_UNAVAILABLE. See Errors.
Request
GORUNNER="https://api.gorunner.io"
GORUNNER_TOKEN="grt_…" # needs Cancel and delete for runs
curl -X POST "$GORUNNER/api/runs/cancel" \
-H "Authorization: Bearer $GORUNNER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ids": [
"8f0c41d2-6b7e-4c1a-9d3f-2a5b7c9e1f04",
"1d7f3b9e-2c4a-4e6b-8d0f-5a3c9e1b7d26"
]
}'const GORUNNER = "https://api.gorunner.io";
const TOKEN = process.env.GORUNNER_TOKEN;
const res = await fetch(`${GORUNNER}/api/runs/cancel`, {
method: "POST",
headers: {
Authorization: `Bearer ${TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
ids: [
"8f0c41d2-6b7e-4c1a-9d3f-2a5b7c9e1f04",
"1d7f3b9e-2c4a-4e6b-8d0f-5a3c9e1b7d26",
],
}),
});
const { data } = await res.json();import os, requests
GORUNNER = "https://api.gorunner.io"
TOKEN = os.environ["GORUNNER_TOKEN"]
res = requests.post(
f"{GORUNNER}/api/runs/cancel",
headers={"Authorization": f"Bearer {TOKEN}"},
json={
"ids": [
"8f0c41d2-6b7e-4c1a-9d3f-2a5b7c9e1f04",
"1d7f3b9e-2c4a-4e6b-8d0f-5a3c9e1b7d26",
],
},
)
data = res.json()["data"]Response · 200 OK
{
"data": {
"results": [
{
"id": "8f0c41d2-6b7e-4c1a-9d3f-2a5b7c9e1f04",
"ok": true,
"status": "cancelling",
"cancelled": true
},
{
"id": "1d7f3b9e-2c4a-4e6b-8d0f-5a3c9e1b7d26",
"ok": true,
"status": "completed",
"cancelled": false
}
],
"done": 2,
"refused": 0
}
}Every field
Body
idsRequired · array of stringsRun ids, in the order to act on them (send oldest first). Duplicates are taken once.
Response · 200 OK
dataobjectresultsarray of objectsEach id’s answer, in the order given; ids that are not UUIDs come last.
idstringokbooleanrunIdUUIDRun again: the new run.
statusstringCancel: the run’s status now (
cancelled,cancelling, or its finished status).cancelledbooleanCancel: whether this call stopped it.
codestringWhy it was refused: NOT_FOUND, ALREADY_RETRIED, RUN_NOT_FINISHED, WORKFLOW_NOT_LIVE, or the Run button’s own code; for Cancel, the cancel’s own code (such as
UNAVAILABLE).messagestringdoneintegerIds this call acted on: a run started, or a run stopped. A finished run left as it is (
ok: true, cancelled: false) is counted neither here nor inrefused.refusedintegerIds answered
ok: false.