curl --request POST \
--url https://api.context.dev/v1/batch/{batch_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.context.dev/v1/batch/{batch_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.context.dev/v1/batch/{batch_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://api.context.dev/v1/batch/{batch_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 => [
"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.context.dev/v1/batch/{batch_id}/cancel"
req, _ := http.NewRequest("POST", 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.post("https://api.context.dev/v1/batch/{batch_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.context.dev/v1/batch/{batch_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "batch_9f2c8a",
"status": "cancelling",
"mode": "scrape",
"format": "markdown",
"tags": [
"docs"
],
"crawl": {
"source": {
"type": "start_url",
"url": "https://example.com/docs"
},
"max_pages": 500,
"max_depth": 0,
"follow_subdomains": true,
"url_pattern": "^https://example\\.com/docs/"
},
"input": {
"reserved": 24817,
"reserved_is_ceiling": false,
"submitted": 25000,
"duplicates": 183,
"invalid": 0
},
"progress": {
"succeeded": 4120,
"failed": 37,
"pending": 20660
},
"credits": {
"reserved": 24817
},
"timing": {
"created_at": "<string>",
"started_at": "<string>"
},
"page_errors": [
{
"code": "WEBSITE_ACCESS_ERROR",
"count": 204
}
],
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"required_permission": "logs:read",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"required_permission": "logs:read",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"required_permission": "logs:read",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}Cancel a Batch
Stop a batch from starting new pages. In-progress pages finish, and unused credits are refunded.
curl --request POST \
--url https://api.context.dev/v1/batch/{batch_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.context.dev/v1/batch/{batch_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.context.dev/v1/batch/{batch_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://api.context.dev/v1/batch/{batch_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 => [
"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.context.dev/v1/batch/{batch_id}/cancel"
req, _ := http.NewRequest("POST", 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.post("https://api.context.dev/v1/batch/{batch_id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.context.dev/v1/batch/{batch_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "batch_9f2c8a",
"status": "cancelling",
"mode": "scrape",
"format": "markdown",
"tags": [
"docs"
],
"crawl": {
"source": {
"type": "start_url",
"url": "https://example.com/docs"
},
"max_pages": 500,
"max_depth": 0,
"follow_subdomains": true,
"url_pattern": "^https://example\\.com/docs/"
},
"input": {
"reserved": 24817,
"reserved_is_ceiling": false,
"submitted": 25000,
"duplicates": 183,
"invalid": 0
},
"progress": {
"succeeded": 4120,
"failed": 37,
"pending": 20660
},
"credits": {
"reserved": 24817
},
"timing": {
"created_at": "<string>",
"started_at": "<string>"
},
"page_errors": [
{
"code": "WEBSITE_ACCESS_ERROR",
"count": 204
}
],
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"required_permission": "logs:read",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"required_permission": "logs:read",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}{
"request_id": "3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91",
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"required_permission": "logs:read",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}Authorizations
Bearer authentication header of the form Bearer <API_KEY>. Keys have full access by default.
Path Parameters
ID of the batch to retrieve or cancel.
"batch_9f2c8a"
Response
Cancellation started. Poll GET /batch/{batch_id} until the batch settles.
Acknowledgement that cancellation was requested. The batch has not settled, so it carries no results, no failure, no refund and no finish time; poll GET /batch/{batch_id} for those.
Batch ID.
"batch_9f2c8a"
Always cancelling. Work already in flight finishes; the batch reaches cancelled shortly after.
cancelling How pages were selected.
scrape, crawl What each page is returned as.
markdown, html Tags stored on the batch at submission.
["docs"]
How the crawl was configured. Null for scrape batches.
Show child attributes
Show child attributes
What submission took in, and what it charged for.
Show child attributes
Show child attributes
How far the batch got before cancellation.
Show child attributes
Show child attributes
What this batch cost so far.
Show child attributes
Show child attributes
There is no finish time yet — the batch is still winding down.
Show child attributes
Show child attributes
Page failures so far, grouped by error code and sorted by count.
Show child attributes
Show child attributes
Unique id of this API call, also sent in the X-Request-Id response header. Quote it when contacting support about a failed request.
"3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91"
API key usage for this request.
Show child attributes
Show child attributes
Was this page helpful?