curl --request POST \
--url https://async.api.zenrows.com/v1/jobs/{job_id}/tasks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"tasks": [
{
"url": "<string>",
"external_id": "<string>",
"metadata": {},
"method": "GET",
"body": "<unknown>",
"zenrows_params": {}
}
]
}
'import requests
url = "https://async.api.zenrows.com/v1/jobs/{job_id}/tasks"
payload = { "tasks": [
{
"url": "<string>",
"external_id": "<string>",
"metadata": {},
"method": "GET",
"body": "<unknown>",
"zenrows_params": {}
}
] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tasks: [
{
url: '<string>',
external_id: '<string>',
metadata: {},
method: 'GET',
body: JSON.stringify('<unknown>'),
zenrows_params: {}
}
]
})
};
fetch('https://async.api.zenrows.com/v1/jobs/{job_id}/tasks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://async.api.zenrows.com/v1/jobs/{job_id}/tasks';
const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tasks: [
{
url: '<string>',
external_id: '<string>',
metadata: {},
method: 'GET',
body: JSON.stringify('<unknown>'),
zenrows_params: {}
}
]
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://async.api.zenrows.com/v1/jobs/{job_id}/tasks"
payload := strings.NewReader("{\n \"tasks\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"<string>\",\n \"metadata\": {},\n \"method\": \"GET\",\n \"body\": \"<unknown>\",\n \"zenrows_params\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://async.api.zenrows.com/v1/jobs/{job_id}/tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'tasks' => [
[
'url' => '<string>',
'external_id' => '<string>',
'metadata' => [
],
'method' => 'GET',
'body' => '<unknown>',
'zenrows_params' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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;
}require 'uri'
require 'net/http'
url = URI("https://async.api.zenrows.com/v1/jobs/{job_id}/tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tasks\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"<string>\",\n \"metadata\": {},\n \"method\": \"GET\",\n \"body\": \"<unknown>\",\n \"zenrows_params\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyHttpResponse<String> response = Unirest.post("https://async.api.zenrows.com/v1/jobs/{job_id}/tasks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"tasks\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"<string>\",\n \"metadata\": {},\n \"method\": \"GET\",\n \"body\": \"<unknown>\",\n \"zenrows_params\": {}\n }\n ]\n}")
.asString();{
"accepted_tasks": 123,
"job_status": "open",
"latest_run": {
"run_id": "<string>",
"job_id": "<string>",
"run_sequence": 2,
"status": "running",
"stats": {
"total": 123,
"completed": 123,
"successful": 123,
"failed": 123,
"failure_reasons": {
"blocked": 9,
"gateway_error": 4
},
"spend": {
"credits": 1,
"cost": 1
}
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"trigger": "manual",
"last_batch_received": true,
"pause_state": "active",
"ingest_status": "pending",
"failure_reason": "insufficient_credits",
"failure_detail": "Subscription has no credit available."
}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}Add URLs to an open job
Valid only when the job is open AND its latest run is
run_sequence == 1 AND last_batch_received == false.
Targets the latest (initial) run. Closed jobs and jobs past
their first run reject further adds with 409; a deleted job
is a 404, like every other read of it.
Setting last_batch: true closes the job (status → closed)
and signals the run to flip to completed once tasks drain.
Honors Idempotency-Key, scoped to the caller and the job: a
repeat of a call that answered 200 replays that answer, and a
repeat of a call that failed part-way (a 503 after its tasks
were stored, or a lost response) finishes it without adding,
enqueuing or counting any task twice. Without the header every
call appends its tasks.
curl --request POST \
--url https://async.api.zenrows.com/v1/jobs/{job_id}/tasks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"tasks": [
{
"url": "<string>",
"external_id": "<string>",
"metadata": {},
"method": "GET",
"body": "<unknown>",
"zenrows_params": {}
}
]
}
'import requests
url = "https://async.api.zenrows.com/v1/jobs/{job_id}/tasks"
payload = { "tasks": [
{
"url": "<string>",
"external_id": "<string>",
"metadata": {},
"method": "GET",
"body": "<unknown>",
"zenrows_params": {}
}
] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tasks: [
{
url: '<string>',
external_id: '<string>',
metadata: {},
method: 'GET',
body: JSON.stringify('<unknown>'),
zenrows_params: {}
}
]
})
};
fetch('https://async.api.zenrows.com/v1/jobs/{job_id}/tasks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://async.api.zenrows.com/v1/jobs/{job_id}/tasks';
const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tasks: [
{
url: '<string>',
external_id: '<string>',
metadata: {},
method: 'GET',
body: JSON.stringify('<unknown>'),
zenrows_params: {}
}
]
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://async.api.zenrows.com/v1/jobs/{job_id}/tasks"
payload := strings.NewReader("{\n \"tasks\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"<string>\",\n \"metadata\": {},\n \"method\": \"GET\",\n \"body\": \"<unknown>\",\n \"zenrows_params\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://async.api.zenrows.com/v1/jobs/{job_id}/tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'tasks' => [
[
'url' => '<string>',
'external_id' => '<string>',
'metadata' => [
],
'method' => 'GET',
'body' => '<unknown>',
'zenrows_params' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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;
}require 'uri'
require 'net/http'
url = URI("https://async.api.zenrows.com/v1/jobs/{job_id}/tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tasks\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"<string>\",\n \"metadata\": {},\n \"method\": \"GET\",\n \"body\": \"<unknown>\",\n \"zenrows_params\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyHttpResponse<String> response = Unirest.post("https://async.api.zenrows.com/v1/jobs/{job_id}/tasks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"tasks\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"<string>\",\n \"metadata\": {},\n \"method\": \"GET\",\n \"body\": \"<unknown>\",\n \"zenrows_params\": {}\n }\n ]\n}")
.asString();{
"accepted_tasks": 123,
"job_status": "open",
"latest_run": {
"run_id": "<string>",
"job_id": "<string>",
"run_sequence": 2,
"status": "running",
"stats": {
"total": 123,
"completed": 123,
"successful": 123,
"failed": 123,
"failure_reasons": {
"blocked": 9,
"gateway_error": 4
},
"spend": {
"credits": 1,
"cost": 1
}
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"trigger": "manual",
"last_batch_received": true,
"pause_state": "active",
"ingest_status": "pending",
"failure_reason": "insufficient_credits",
"failure_detail": "Subscription has no credit available."
}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"instance": "<string>",
"invalid_tasks": [
{
"index": 123,
"reason": "malformed_url",
"value": "<string>"
}
]
}Authorizations
Headers
Optional opaque token scoping a single submit / rerun /
add-tasks request, kept for 24 hours. A retry with the same
key and the same body replays the original status and body.
The same key with a different body, or while the original
request is still being processed, returns
409 idempotency_key_conflict. A request that is refused
(any 4xx, or a 503 before the job or run was created)
gives the key back, so a retry with the same key is
processed afresh. A 503 after the job or run was created
keeps the key: a retry under it is 409; check the job
before you resend with a fresh key. On add-tasks a retry
with the same body finishes an attempt that stopped partway
and adds each task once. The credit check runs first, so a
retry of a call that succeeded returns 402 if the account
has run out of credit since. At most 128 characters; a
longer key is 400 invalid_argument.
128Path Parameters
Body
Response
Tasks queued.
open: initial run still acceptingaddBatchTasks. Only meaningful whilelatest_run.run_sequence == 1.closed: no more tasks accepted (created closed, or closed via/close/addTasks{last_batch}//rerun).deleted: never returned. A deleted job disappears from every read and list the momentDELETEis accepted (reads answer 404); its data is cleaned up asynchronously after.
Clients must accept values not listed here.
open, closed, deleted Was this page helpful?