Skip to main content
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 currently pending 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
}
FieldTypeDescription
status"cancelled"Confirms the batch was cancelled
cancelledItemsnumberNumber of pending items that were stopped. Items already running are not counted
creditsRefundednumberCredits 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

CodeReason
401Missing API key authentication header
403Invalid or expired API key
404No batch found with this ID, or it belongs to a different user
409The batch is already in a terminal state (completed, failed, or cancelled) and cannot be cancelled
Already terminal:
{
  "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

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

batchId
string<uuid>
required

The batch ID to cancel

Response

Batch cancelled successfully

status
enum<string>
Available options:
cancelled
cancelledItems
integer

Number of pending items that were stopped

creditsRefunded
integer

Credits returned to your balance