Cancel a Batch
curl --request DELETE \
--url https://api.spidra.io/api/batch/scrape/{batchId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.spidra.io/api/batch/scrape/{batchId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.spidra.io/api/batch/scrape/{batchId}', 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.spidra.io/api/batch/scrape/{batchId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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.spidra.io/api/batch/scrape/{batchId}"
req, _ := http.NewRequest("DELETE", 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.delete("https://api.spidra.io/api/batch/scrape/{batchId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.spidra.io/api/batch/scrape/{batchId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": "cancelled",
"cancelledItems": 8,
"creditsRefunded": 16
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "Cannot cancel a batch that is already completed.",
"code": "ALREADY_TERMINAL"
}Scrape Endpoints
Cancel a Batch
Stop a running or pending batch and refund credits for unprocessed items
DELETE
/
batch
/
scrape
/
{batchId}
Cancel a Batch
curl --request DELETE \
--url https://api.spidra.io/api/batch/scrape/{batchId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.spidra.io/api/batch/scrape/{batchId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.spidra.io/api/batch/scrape/{batchId}', 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.spidra.io/api/batch/scrape/{batchId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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.spidra.io/api/batch/scrape/{batchId}"
req, _ := http.NewRequest("DELETE", 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.delete("https://api.spidra.io/api/batch/scrape/{batchId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.spidra.io/api/batch/scrape/{batchId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": "cancelled",
"cancelledItems": 8,
"creditsRefunded": 16
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "Cannot cancel a batch that is already completed.",
"code": "ALREADY_TERMINAL"
}Overview
Cancels a batch that is currentlypending or running. Credits reserved for items that have not yet started are refunded automatically. Items already being processed will complete normally.
curl -X DELETE https://api.spidra.io/api/batch/scrape/YOUR_BATCH_ID \
-H "Authorization: Bearer YOUR_API_KEY"
const res = await fetch(
`https://api.spidra.io/api/batch/scrape/${batchId}`,
{
method: "DELETE",
headers: { Authorization: "Bearer YOUR_API_KEY" },
}
);
const { cancelledItems, creditsRefunded } = await res.json();
console.log(`Cancelled ${cancelledItems} items, refunded ${creditsRefunded} credits`);
import requests
resp = requests.delete(
f"https://api.spidra.io/api/batch/scrape/{batch_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
)
data = resp.json()
print(f"Cancelled {data['cancelledItems']} items, refunded {data['creditsRefunded']} credits")
Response
{
"status": "cancelled",
"cancelledItems": 8,
"creditsRefunded": 16
}
| Field | Type | Description |
|---|---|---|
status | "cancelled" | Confirms the batch was cancelled |
cancelledItems | number | Number of pending items that were stopped. Items already running are not counted |
creditsRefunded | number | Credits returned to your balance. Calculated as cancelledItems × reservedCreditsPerItem |
Items that were already
running when you cancelled will finish processing and consume their credits. Only pending items are cancelled and refunded.Errors
| Code | Reason |
|---|---|
401 | Missing API key authentication header |
403 | Invalid or expired API key |
404 | No batch found with this ID, or it belongs to a different user |
409 | The batch is already in a terminal state (completed, failed, or cancelled) and cannot be cancelled |
{
"status": "error",
"message": "Cannot cancel a batch that is already completed.",
"code": "ALREADY_TERMINAL"
}
Retry Failed Batch Scrapes
Re-queue failed items instead of cancelling
Get Batch Status
Check current status before cancelling
Authorizations
BearerAuthApiKeyAuth
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The batch ID to cancel
Was this page helpful?

