curl --request POST \
--url https://agent.tinyfish.ai/v1/runs/{id}/cancel \
--header 'X-API-Key: <api-key>'import requests
url = "https://agent.tinyfish.ai/v1/runs/{id}/cancel"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://agent.tinyfish.ai/v1/runs/{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://agent.tinyfish.ai/v1/runs/{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 => [
"X-API-Key: <api-key>"
],
]);
$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://agent.tinyfish.ai/v1/runs/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://agent.tinyfish.ai/v1/runs/{id}/cancel")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agent.tinyfish.ai/v1/runs/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"run_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "CANCELLED",
"cancelled_at": "2024-01-01T00:00:00Z",
"message": null
}Cancel run by ID
Cancel a run by ID. Only runs created via /v1/automation/run-async or /v1/automation/run-sse can be cancelled. Runs created via the synchronous /v1/automation/run endpoint cannot be cancelled.
curl --request POST \
--url https://agent.tinyfish.ai/v1/runs/{id}/cancel \
--header 'X-API-Key: <api-key>'import requests
url = "https://agent.tinyfish.ai/v1/runs/{id}/cancel"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://agent.tinyfish.ai/v1/runs/{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://agent.tinyfish.ai/v1/runs/{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 => [
"X-API-Key: <api-key>"
],
]);
$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://agent.tinyfish.ai/v1/runs/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://agent.tinyfish.ai/v1/runs/{id}/cancel")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agent.tinyfish.ai/v1/runs/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"run_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "CANCELLED",
"cancelled_at": "2024-01-01T00:00:00Z",
"message": null
}Authorizations
API key for authentication. Get your key from the API Keys page.
Path Parameters
Run ID
^[A-Za-z0-9_-]+$"a1b2c3d4-e5f6-7890-abcd-ef1234567890"
Response
Run cancelled successfully, or already in terminal state (idempotent)
Response from cancel run endpoint
The unique identifier of the run
"a1b2c3d4-e5f6-7890-abcd-ef1234567890"
The current status of the run. Returns actual status for idempotent responses (e.g., COMPLETED if run already finished)
CANCELLED, COMPLETED, FAILED "CANCELLED"
ISO 8601 timestamp when the run was cancelled, or null if not cancelled
"2026-01-14T10:30:55Z"
Additional context about the cancellation result (e.g., "Run already cancelled", "Run already finished")
"Run already cancelled"
Was this page helpful?