Cancelling a Job
curl --request POST \
--url https://api.sutro.sh/job-cancel/{job_id} \
--header 'Authorization: <authorization>'import requests
url = "https://api.sutro.sh/job-cancel/{job_id}"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.sutro.sh/job-cancel/{job_id}', 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.sutro.sh/job-cancel/{job_id}",
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: <authorization>"
],
]);
$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.sutro.sh/job-cancel/{job_id}"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.sutro.sh/job-cancel/{job_id}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sutro.sh/job-cancel/{job_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"cancelled": true,
"message": "Job batch_job_12345 has been successfully cancelled"
}
{
"cancelled": false,
"message": "Job batch_job_12345 could not be cancelled because it has already completed"
}
{
"cancelled": false,
"message": "Job batch_job_12345 not found"
}
Batch API
Cancelling a Job
Cancel a batch inference job by its job_id
POST
/
job-cancel
/
{job_id}
Cancelling a Job
curl --request POST \
--url https://api.sutro.sh/job-cancel/{job_id} \
--header 'Authorization: <authorization>'import requests
url = "https://api.sutro.sh/job-cancel/{job_id}"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.sutro.sh/job-cancel/{job_id}', 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.sutro.sh/job-cancel/{job_id}",
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: <authorization>"
],
]);
$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.sutro.sh/job-cancel/{job_id}"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.sutro.sh/job-cancel/{job_id}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sutro.sh/job-cancel/{job_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"cancelled": true,
"message": "Job batch_job_12345 has been successfully cancelled"
}
{
"cancelled": false,
"message": "Job batch_job_12345 could not be cancelled because it has already completed"
}
{
"cancelled": false,
"message": "Job batch_job_12345 not found"
}
Using the API directly is not recommended for most users. Instead, we recommend using the Python SDK.
Request Parameters
string
required
The job_id returned when you submitted the batch inference job
Headers
string
required
Your Sutro API key using Key authentication scheme.Format:
Key YOUR_API_KEYExample: Authorization: Key sk_live_abc123...Response
Returns the cancellation status of the job.boolean
True if the job was cancelled, False otherwise
string
Verbose message describing the job’s cancellation status
{
"cancelled": true,
"message": "Job batch_job_12345 has been successfully cancelled"
}
{
"cancelled": false,
"message": "Job batch_job_12345 could not be cancelled because it has already completed"
}
{
"cancelled": false,
"message": "Job batch_job_12345 not found"
}
Code Examples
import requests
job_id = "batch_job_12345"
response = requests.post(
f'https://api.sutro.sh/job-cancel/{job_id}',
headers={
'Authorization': 'Key YOUR_SUTRO_API_KEY',
'Content-Type': 'application/json'
}
)
result = response.json()
if result['cancelled']:
print(f"Job {job_id} was successfully cancelled")
else:
print(f"Failed to cancel job: {result['message']}")
const jobId = 'batch_job_12345';
const response = await fetch(`https://api.sutro.sh/job-cancel/${jobId}`, {
method: 'POST',
headers: {
'Authorization': 'Key YOUR_SUTRO_API_KEY',
'Content-Type': 'application/json'
}
});
const result = await response.json();
if (result.cancelled) {
console.log(`Job ${jobId} was successfully cancelled`);
} else {
console.log(`Failed to cancel job: ${result.message}`);
}
curl -X POST https://api.sutro.sh/job-cancel/batch_job_12345 \
-H "Authorization: Key YOUR_SUTRO_API_KEY" \
-H "Content-Type: application/json"
Notes
- Jobs can only be cancelled if they are in a cancellable state (e.g., pending, submitted, starting, or running)
- Jobs that have already completed, failed, or been previously cancelled cannot be cancelled
- The cancellation is asynchronous - the job may take a moment to fully stop after receiving the cancellation request
⌘I