import requests
url = "https://platform.ankra.app/api/v1/org/workspaces/{workspace_id}/runs/{run_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://platform.ankra.app/api/v1/org/workspaces/{workspace_id}/runs/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://platform.ankra.app/api/v1/org/workspaces/{workspace_id}/runs/{run_id}/cancel \
--header 'Authorization: Bearer <token>'{
"apply": true,
"argv_preview": "<string>",
"base_ref": "<string>",
"base_sha": "<string>",
"bundle_object_key": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"cwd_prefix": "<string>",
"env_names": [
"<string>"
],
"error_message": "<string>",
"exit_code": 123,
"finished_at": "2023-11-07T05:31:56Z",
"head_sha": "<string>",
"run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"snapshot_sha": "<string>",
"started": true,
"state": "accepted",
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "<string>",
"error_code": "CLUSTER_OFFLINE",
"retry_after": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "<string>",
"error_code": "CLUSTER_OFFLINE",
"retry_after": 123
}Cancel a workspace run
Bearer PAT authentication; RBAC permission workspaces.use for the caller’s own workspace, workspaces.manage for another member’s. Cancels a run: a command that has not started never will, and a running one gets SIGTERM with its whole process group. The run reads cancelled (without finished_at) until a read sees it end. A run that already ended answers as it is.
import requests
url = "https://platform.ankra.app/api/v1/org/workspaces/{workspace_id}/runs/{run_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://platform.ankra.app/api/v1/org/workspaces/{workspace_id}/runs/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://platform.ankra.app/api/v1/org/workspaces/{workspace_id}/runs/{run_id}/cancel \
--header 'Authorization: Bearer <token>'{
"apply": true,
"argv_preview": "<string>",
"base_ref": "<string>",
"base_sha": "<string>",
"bundle_object_key": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"cwd_prefix": "<string>",
"env_names": [
"<string>"
],
"error_message": "<string>",
"exit_code": 123,
"finished_at": "2023-11-07T05:31:56Z",
"head_sha": "<string>",
"run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"snapshot_sha": "<string>",
"started": true,
"state": "accepted",
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "<string>",
"error_code": "CLUSTER_OFFLINE",
"retry_after": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"detail": "Cluster not found"
}{
"detail": "Cluster not found"
}{
"detail": "<string>",
"error_code": "CLUSTER_OFFLINE",
"retry_after": 123
}Authorizations
Response
The run
One command run in a workspace.
Why the run ended without an exit code, when the platform could tell: a command that ran the workspace's main container out of memory (it was OOMKilled, which ends every run in it) carries a message naming the container's memory limit and pointing at resources.memory in the repository's workspace profile, and a run ended by the kubelet evicting the workspace pod (an emptyDir volume past its size limit, the node short of memory or disk) carries a message saying so and quoting the kubelet's reason. Null for every other run, which says nothing about how it ended.