curl --request POST \
--url https://api.example.com/api/v2/responses/{response_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/api/v2/responses/{response_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://api.example.com/api/v2/responses/{response_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v2/responses/{response_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v2/responses/{response_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v2/responses/{response_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v2/responses/{response_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}Post apiv2responses cancel
POST /api/v2/responses/{response_id}/cancel (§30).
§30 offers this endpoint as optional and attaches one condition — if implemented in Phase 3, it must be safe and idempotent — so both properties are structural rather than checked:
Safe. resolve_run runs first and applies the same four bindings
every other read does, so a guessed id answers 404 whether it names
nothing or another tenant’s run. A run that has already reached a terminal
status is left exactly as it is: the conditional UPDATE in
runtime.cancellation.request_stop names the states it is legal to stop
from, so a run that finished between the read and the write is not
reopened by a cancel that lost the race.
Idempotent. Stopping is Event.set() plus that UPDATE; doing either
twice is indistinguishable from doing it once. A second call answers the
same way as the first, and a call for a finished run answers 200 rather
than an error, because “it already stopped” is the outcome the caller
wanted.
Two statuses, and the difference is information rather than success:
202 the run was in flight and will stop at its next checkpoint;
200 there was nothing left to stop. Cancellation is cooperative — see
runtime.cancellation for what that promises at each point of a turn —
so 202 is the honest code for “accepted”, not 204.
Any run this caller may read can be cancelled here, not only those from
POST /v2/responses. The path is §30’s; the ids are one namespace.
Required scope: responses:create. A key without it is a 403 naming the scope; the endpoint is never silently skipped.
curl --request POST \
--url https://api.example.com/api/v2/responses/{response_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/api/v2/responses/{response_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://api.example.com/api/v2/responses/{response_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v2/responses/{response_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v2/responses/{response_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v2/responses/{response_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v2/responses/{response_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}{
"error": {
"code": "agent_not_available",
"message": "<string>",
"request_id": "<string>"
},
"id": "<string>",
"status": "queued",
"trace_id": "<string>"
}Authorizations
A managed API key, sent as Authorization: Bearer <key>. A workspace key is prefixed tgcc_; a reseller key is prefixed tgpk_. Keys carry scopes; the scope each operation demands is on the operation as x-required-scope.
Path Parameters
Response
No response body

