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
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
PAT organisation override.
Response
The run
One command run in a workspace.
The command line with secret-shaped arguments masked, at most 200 characters.
The names of the forwarded environment variables, never their values.
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.
The command's exit code, or with started false why it never started (197: resend the full history, 75: the sync failed, 78: the workspace profile's setup failed, 130: cancelled first).
When the run ended; null while it has not.
Whether the command itself started; null when the record alone cannot tell (a cancelled or lost run).
accepted, running, finished, not_started, cancelled, lost