Cancel an asynchronous job
curl --request DELETE \
--url https://api.runpulse.com/job/{jobId} \
--header 'x-api-key: <api-key>'import requests
url = "https://api.runpulse.com/job/{jobId}"
headers = {"x-api-key": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.runpulse.com/job/{jobId}', 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.runpulse.com/job/{jobId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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://api.runpulse.com/job/{jobId}"
req, _ := http.NewRequest("DELETE", 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.delete("https://api.runpulse.com/job/{jobId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runpulse.com/job/{jobId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"job_id": "<string>",
"message": "<string>"
}Jobs, Results & Webhooks
Cancel Job
Attempts to cancel an asynchronous job that is currently pending or processing. Jobs that have already completed will remain unchanged.
DELETE
/
job
/
{jobId}
Cancel an asynchronous job
curl --request DELETE \
--url https://api.runpulse.com/job/{jobId} \
--header 'x-api-key: <api-key>'import requests
url = "https://api.runpulse.com/job/{jobId}"
headers = {"x-api-key": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.runpulse.com/job/{jobId}', 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.runpulse.com/job/{jobId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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://api.runpulse.com/job/{jobId}"
req, _ := http.NewRequest("DELETE", 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.delete("https://api.runpulse.com/job/{jobId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runpulse.com/job/{jobId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"job_id": "<string>",
"message": "<string>"
}Overview
Cancel an asynchronous job that is currently pending or processing. Jobs that have already completed, failed, or been canceled will remain unchanged.Response
A successful cancellation returns a confirmation message:{
"job_id": "abc123-def456-ghi789",
"message": "Job cancelled successfully"
}
Response Fields
| Field | Type | Description |
|---|---|---|
job_id | string | Identifier of the job that was cancelled. |
message | string | Human-readable confirmation message. |
When to Cancel Jobs
Cancel jobs when:- The extraction is no longer needed
- You submitted a job with incorrect parameters
- You want to stop processing to conserve page usage
Cancellation is best-effort. If a job is already mid-processing, it may complete before the cancellation takes effect. Pages used before cancellation are still counted toward your usage.
Example Usage
Cancel a Job
from pulse import Pulse
client = Pulse(api_key="YOUR_API_KEY")
job_id = "abc123-def456-ghi789"
try:
response = client.jobs.cancel_job(job_id=job_id)
print(f"Job {response.job_id} cancelled successfully")
print(f"Message: {response.message}")
except Exception as e:
print(f"Failed to cancel job: {e}")
import { PulseClient } from 'pulse-ts-sdk';
const client = new PulseClient({
apiKey: 'YOUR_API_KEY'
});
const jobId = "abc123-def456-ghi789";
try {
const response = await client.jobs.cancelJob({ jobId });
console.log(`Job ${response.job_id} cancelled successfully`);
console.log(`Message: ${response.message}`);
} catch (error) {
console.log(`Failed to cancel job: ${error}`);
}
# Cancel a pending or processing job
curl -X DELETE https://api.runpulse.com/job/abc123-def456-ghi789 \
-H "x-api-key: YOUR_API_KEY"
Cancel with Error Handling
from pulse import Pulse
from pulse.core.api_error import ApiError
client = Pulse(api_key="YOUR_API_KEY")
def cancel_job_safely(job_id: str):
"""Cancel a job with comprehensive error handling."""
try:
response = client.jobs.cancel_job(job_id=job_id)
print(f"✓ Job {job_id} cancelled successfully")
return True
except ApiError as e:
if e.status_code == 404:
print(f"✗ Job {job_id} not found")
elif e.status_code == 403:
print(f"✗ You don't have access to job {job_id}")
elif e.status_code == 401:
print(f"✗ Invalid or missing API key")
else:
print(f"✗ Failed to cancel job: {e}")
return False
except Exception as e:
print(f"✗ Unexpected error: {e}")
return False
# Example usage
cancel_job_safely("abc123-def456-ghi789")
import { PulseClient } from 'pulse-ts-sdk';
const client = new PulseClient({
apiKey: 'YOUR_API_KEY'
});
async function cancelJobSafely(jobId: string): Promise<boolean> {
/**
* Cancel a job with comprehensive error handling.
*/
try {
const response = await client.jobs.cancelJob({ jobId });
console.log(`✓ Job ${jobId} cancelled successfully`);
return true;
} catch (error: any) {
if (error.statusCode === 404) {
console.log(`✗ Job ${jobId} not found`);
} else if (error.statusCode === 403) {
console.log(`✗ You don't have access to job ${jobId}`);
} else if (error.statusCode === 401) {
console.log(`✗ Invalid or missing API key`);
} else {
console.log(`✗ Failed to cancel job: ${error.message}`);
}
return false;
}
}
// Example usage
cancelJobSafely("abc123-def456-ghi789");
#!/bin/bash
JOB_ID="abc123-def456-ghi789"
API_KEY="YOUR_API_KEY"
response=$(curl -s -w "\n%{http_code}" -X DELETE \
"https://api.runpulse.com/job/${JOB_ID}" \
-H "x-api-key: ${API_KEY}")
# Split response body and status code
body=$(echo "$response" | head -n -1)
status_code=$(echo "$response" | tail -n 1)
case "$status_code" in
200)
echo "✓ Job ${JOB_ID} cancelled successfully"
echo "$body" | jq .
;;
401)
echo "✗ Invalid or missing API key"
;;
403)
echo "✗ You don't have access to job ${JOB_ID}"
;;
404)
echo "✗ Job ${JOB_ID} not found"
;;
*)
echo "✗ Failed to cancel job (status $status_code)"
echo "$body"
;;
esac
Cancel Multiple Jobs
from pulse import Pulse
client = Pulse(api_key="YOUR_API_KEY")
job_ids = [
"job-111-aaa",
"job-222-bbb",
"job-333-ccc"
]
for job_id in job_ids:
try:
client.jobs.cancel_job(job_id=job_id)
print(f"✓ Cancelled: {job_id}")
except Exception as e:
print(f"✗ Failed to cancel {job_id}: {e}")
import { PulseClient } from 'pulse-ts-sdk';
const client = new PulseClient({
apiKey: 'YOUR_API_KEY'
});
const jobIds = [
"job-111-aaa",
"job-222-bbb",
"job-333-ccc"
];
for (const jobId of jobIds) {
try {
await client.jobs.cancelJob({ jobId });
console.log(`✓ Cancelled: ${jobId}`);
} catch (error: any) {
console.log(`✗ Failed to cancel ${jobId}: ${error.message}`);
}
}
#!/bin/bash
API_KEY="YOUR_API_KEY"
JOB_IDS=("job-111-aaa" "job-222-bbb" "job-333-ccc")
for job_id in "${JOB_IDS[@]}"; do
status=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE \
"https://api.runpulse.com/job/${job_id}" \
-H "x-api-key: ${API_KEY}")
if [ "$status" = "200" ]; then
echo "✓ Cancelled: $job_id"
else
echo "✗ Failed to cancel $job_id (status $status)"
fi
done
Error Responses
| Status | Description |
|---|---|
401 | Invalid or missing API key. |
403 | You don’t have access to this job. |
404 | Job not found. |
500 | Job could not be cancelled or internal server error. |
Authorizations
Path Parameters
Identifier returned from an async job submission.
⌘I