# Jobs and batches

> Send up to 50,000 requests in one call with POST /v1/jobs (also as an NDJSON file), let them run in the background and fetch the results page by page, as one download or by webhook; or a few at once with POST /v1/batch.

Source: https://docs.virginproxy.com/jobs/

A job is a list of requests that runs in the background. You send it in one call and get an id back at once; we work through it within your plan's limits and keep the results for you for 24 hours. Ideal for nightly price checks, large crawls and anything you do not want to wait for.

## Create a job

`POST /v1/jobs` takes a list of `requests`, each exactly what you would send to `POST /v1/requests`. Use `request` instead for a single one.

**cURL**

```bash
curl https://api.virginproxy.com/v1/jobs \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Idempotency-Key: nightly-2026-11-18" \
  -H "Content-Type: application/json" \
  -d '{
    "requests": [
      {
        "url": "https://shop.example/product/1",
        "extract": {
          "price": {
            "selector": ".price",
            "type": "number"
          }
        },
        "echo": {
          "sku": "TR-1"
        }
      },
      {
        "url": "https://shop.example/product/2",
        "extract": {
          "price": {
            "selector": ".price",
            "type": "number"
          }
        },
        "echo": {
          "sku": "TR-2"
        }
      },
      {
        "url": "https://shop.example/product/3",
        "extract": {
          "price": {
            "selector": ".price",
            "type": "number"
          }
        },
        "echo": {
          "sku": "TR-3"
        }
      }
    ],
    "webhook": {
      "url": "https://example.com/hooks/virginproxy",
      "events": [
        "item",
        "done"
      ]
    },
    "tag": "nightly-prices"
  }'
```

**Python**

```python
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/jobs",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"], "Idempotency-Key": "nightly-2026-11-18"},
    json={
        "requests": [
            {
                "url": "https://shop.example/product/1",
                "extract": {"price": {"selector": ".price", "type": "number"}},
                "echo": {"sku": "TR-1"},
            },
            {
                "url": "https://shop.example/product/2",
                "extract": {"price": {"selector": ".price", "type": "number"}},
                "echo": {"sku": "TR-2"},
            },
            {
                "url": "https://shop.example/product/3",
                "extract": {"price": {"selector": ".price", "type": "number"}},
                "echo": {"sku": "TR-3"},
            },
        ],
        "webhook": {
            "url": "https://example.com/hooks/virginproxy",
            "events": ["item", "done"],
        },
        "tag": "nightly-prices",
    },
    timeout=30,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["id"], data["status"], data["total"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/jobs", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json", "Idempotency-Key": "nightly-2026-11-18" },
  body: JSON.stringify({
    requests: [
      {
        url: "https://shop.example/product/1",
        extract: { price: { selector: ".price", type: "number" } },
        echo: { sku: "TR-1" },
      },
      {
        url: "https://shop.example/product/2",
        extract: { price: { selector: ".price", type: "number" } },
        echo: { sku: "TR-2" },
      },
      {
        url: "https://shop.example/product/3",
        extract: { price: { selector: ".price", type: "number" } },
        echo: { sku: "TR-3" },
      },
    ],
    webhook: {
      url: "https://example.com/hooks/virginproxy",
      events: ["item", "done"],
    },
    tag: "nightly-prices",
  }),
  signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.id, data.status, data.total);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.create_job({
    "requests": [
        {
            "url": "https://shop.example/product/1",
            "extract": {"price": {"selector": ".price", "type": "number"}},
            "echo": {"sku": "TR-1"},
        },
        {
            "url": "https://shop.example/product/2",
            "extract": {"price": {"selector": ".price", "type": "number"}},
            "echo": {"sku": "TR-2"},
        },
        {
            "url": "https://shop.example/product/3",
            "extract": {"price": {"selector": ".price", "type": "number"}},
            "echo": {"sku": "TR-3"},
        },
    ],
    "webhook": {
        "url": "https://example.com/hooks/virginproxy",
        "events": ["item", "done"],
    },
    "tag": "nightly-prices",
})
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.createJob({
  requests: [
    {
      url: "https://shop.example/product/1",
      extract: { price: { selector: ".price", type: "number" } },
      echo: { sku: "TR-1" },
    },
    {
      url: "https://shop.example/product/2",
      extract: { price: { selector: ".price", type: "number" } },
      echo: { sku: "TR-2" },
    },
    {
      url: "https://shop.example/product/3",
      extract: { price: { selector: ".price", type: "number" } },
      echo: { sku: "TR-3" },
    },
  ],
  webhook: {
    url: "https://example.com/hooks/virginproxy",
    events: ["item", "done"],
  },
  tag: "nightly-prices",
});
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/jobs");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
        "Idempotency-Key: nightly-2026-11-18",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "requests" => [
            [
                "url" => "https://shop.example/product/1",
                "extract" => ["price" => ["selector" => ".price", "type" => "number"]],
                "echo" => ["sku" => "TR-1"],
            ],
            [
                "url" => "https://shop.example/product/2",
                "extract" => ["price" => ["selector" => ".price", "type" => "number"]],
                "echo" => ["sku" => "TR-2"],
            ],
            [
                "url" => "https://shop.example/product/3",
                "extract" => ["price" => ["selector" => ".price", "type" => "number"]],
                "echo" => ["sku" => "TR-3"],
            ],
        ],
        "webhook" => [
            "url" => "https://example.com/hooks/virginproxy",
            "events" => ["item", "done"],
        ],
        "tag" => "nightly-prices",
    ], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["id"], " ", $data["status"], " ", $data["total"], PHP_EOL;
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	payload := []byte(`{
  "requests": [
    {
      "url": "https://shop.example/product/1",
      "extract": {
        "price": {
          "selector": ".price",
          "type": "number"
        }
      },
      "echo": {
        "sku": "TR-1"
      }
    },
    {
      "url": "https://shop.example/product/2",
      "extract": {
        "price": {
          "selector": ".price",
          "type": "number"
        }
      },
      "echo": {
        "sku": "TR-2"
      }
    },
    {
      "url": "https://shop.example/product/3",
      "extract": {
        "price": {
          "selector": ".price",
          "type": "number"
        }
      },
      "echo": {
        "sku": "TR-3"
      }
    }
  ],
  "webhook": {
    "url": "https://example.com/hooks/virginproxy",
    "events": [
      "item",
      "done"
    ]
  },
  "tag": "nightly-prices"
}`)
	req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/jobs", bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Idempotency-Key", "nightly-2026-11-18")

	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["id"], data["status"], data["total"])
}
```

POST`/v1/jobs`[≈ 3 credits](https://docs.virginproxy.com/billing/#cost)

The answer is `202 Accepted` with the job's state:

*Response · 202 Accepted:*

```json
{
  "id": "job_8fK2pQ7wLz3nVd0sXa4T",
  "status": "queued",
  "total": 3,
  "succeeded": 0,
  "failed": 0,
  "canceled": 0,
  "pending": 3,
  "credits": 0,
  "tag": "nightly-prices",
  "webhook": { "url": "https://example.com/hooks/virginproxy", "events": ["item", "done"] },
  "created_at": "2026-11-18T09:00:00.000Z",
  "started_at": null,
  "finished_at": null,
  "expires_at": null,
  "last_progress_at": null
}
```

| Field | Type | Meaning |
| --- | --- | --- |
| `requests` | list | 1 up to your plan's limit, see [Limits](#limits). Every request is checked when the job is created: if one is invalid, nothing is created and you get `invalid_job` with its `index`. |
| `request` | object | A single request instead of `requests`. |
| `webhook` | object | Optional. Where we send results as they arrive, see [Webhooks](https://docs.virginproxy.com/webhooks/). |
| `tag` | string | Optional. Marks the job (same rules as a request's [`tag`](https://docs.virginproxy.com/account/#tags)) and comes back in its state. |

> **Tip:** Put your own reference into each request's `echo` – an id, a SKU, a row number. It comes back unchanged in the result, so you never have to match results by URL.

## Safe to retry: Idempotency-Key

Send an `Idempotency-Key` header of your choice with `POST /v1/jobs`. If the same key arrives again within 24 hours – because your network dropped the first answer, for example – you get the same job back instead of a second one: HTTP 200 instead of 202 and the header `Idempotent-Replayed: true`.

## Follow its progress

**cURL**

```bash
curl https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T \
  -H "Authorization: Bearer $VP_KEY"
```

**Python**

```python
import os, requests

r = requests.get(
    "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    timeout=30,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["succeeded"], data["failed"], data["pending"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T", {
  headers: { Authorization: "Bearer " + process.env.VP_KEY },
  signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.succeeded, data.failed, data.pending);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("GET", "/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T")
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.call("GET", "/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T");
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
    ],
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["succeeded"], " ", $data["failed"], " ", $data["pending"], PHP_EOL;
```

**Go**

```go
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))

	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["status"], data["succeeded"], data["failed"], data["pending"])
}
```

GET`/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T`

*Response · 200 OK:*

```json
{
  "id": "job_8fK2pQ7wLz3nVd0sXa4T",
  "status": "done",
  "total": 3,
  "succeeded": 2,
  "failed": 1,
  "canceled": 0,
  "pending": 0,
  "credits": 2,
  "tag": "nightly-prices",
  "webhook": { "url": "https://example.com/hooks/virginproxy", "events": ["item", "done"] },
  "created_at": "2026-11-18T09:00:00.000Z",
  "started_at": "2026-11-18T09:00:00.214Z",
  "finished_at": "2026-11-18T09:00:04.512Z",
  "expires_at": "2026-11-19T09:00:04.512Z",
  "last_progress_at": "2026-11-18T09:00:04.512Z"
}
```

| Field | Meaning |
| --- | --- |
| `status` | `queued` → `running` → `done`, or `canceled`. `done` means every item has finished, whether or not some failed. After 24 hours: `expired`. |
| `succeeded`, `failed`, `canceled`, `pending` | How many items ended which way, and how many are still waiting or running. Together they add up to `total`. |
| `credits` | Credits charged for the job so far. |
| `webhook` | The webhook as you set it, or `null`. |
| `created_at`, `started_at`, `finished_at`, `expires_at` | When the job was created, when its first item started, when its last item finished, and when its results will be deleted (24 hours after `finished_at`). `null` until then. |
| `last_progress_at` | When an item of the job last finished – while it runs, this shows whether it is still moving. `null` until the first item finishes. |

## Fetch the results

`GET /v1/jobs/{id}/results` returns the items in pages of up to 100, in the order of your list. Results are available while the job is still running.

**cURL**

```bash
curl "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded" \
  -H "Authorization: Bearer $VP_KEY"
```

**Python**

```python
import os, requests

r = requests.get(
    "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    timeout=30,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["next_offset"])
print(data["items"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded", {
  headers: { Authorization: "Bearer " + process.env.VP_KEY },
  signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.next_offset);
console.log(data.items);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("GET", "/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded")
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.call("GET", "/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded");
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
    ],
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["next_offset"], PHP_EOL;
echo json_encode($data["items"], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), PHP_EOL;
```

**Go**

```go
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))

	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["next_offset"])
	fmt.Println(data["items"])
}
```

GET`/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/results?offset=0&limit=100&status=succeeded`

*Response · 200 OK (shortened):*

```json
{
  "job": { "id": "job_8fK2pQ7wLz3nVd0sXa4T", "status": "done", "total": 3, "succeeded": 2, "failed": 1, "canceled": 0, "pending": 0, "credits": 2, "…": "…" },
  "items": [
    {
      "index": 0,
      "status": "succeeded",
      "request_id": "req_Qm4tY8bN2xLs0Pd7Wk3e",
      "credits": 1,
      "finished_at": "2026-11-18T09:00:02.088Z",
      "response": {
        "id": "req_Qm4tY8bN2xLs0Pd7Wk3e",
        "status": 200,
        "final_url": "https://shop.example/product/1",
        "extracted": { "price": 129 },
        "echo": { "sku": "TR-1" },
        "cost": { "credits": 1 },
        "…": "…"
      }
    },
    {
      "index": 2,
      "status": "failed",
      "request_id": "req_Lx9cV2nB5mQ8sT1wR6yA",
      "credits": 0,
      "finished_at": "2026-11-18T09:00:04.512Z",
      "error": { "code": "timeout", "message": "The target did not answer within 30000 ms." }
    }
  ],
  "next_offset": null
}
```

| Parameter | Meaning |
| --- | --- |
| `offset` | Where to start, default 0. Use `next_offset` from the previous page; it is `null` on the last page. |
| `limit` | 1 to 100, default 100. |
| `status` | Only items with this status: `queued`, `running`, `succeeded`, `failed` or `canceled`. |

Each item has its `index` in your list, its `status`, the `url` you sent, the `request_id`, the `credits` it cost, when it `finished_at` (`null` while it waits or runs), and either `response` – exactly the answer `POST /v1/requests` would have given, `echo` included – or `error` with `code` and `message`.

### Item statuses

| Status | Meaning |
| --- | --- |
| `queued` | Waiting for a free slot. |
| `running` | Being fetched right now. |
| `succeeded` | The target answered, whatever its HTTP status. `response` is set. |
| `failed` | The request ended with an error such as `timeout` or `credits_exhausted`. `error` is set. |
| `canceled` | The job was canceled before this item started. |

## Download all results

`GET /v1/jobs/{id}/export` sends every result of a job as one file, read page by page while it streams – also for a job that is still running (what has finished so far).

| format | File |
| --- | --- |
| `ndjson` | Default. One item per line, exactly as in `GET /v1/jobs/{id}/results`. |
| `json` | `{"job": {…}, "items": [ … ]}`. |
| `csv` | One row per item: index, status, URL, final URL, HTTP status, credits, request id, error, and `extracted` / `parsed` as JSON text. Page bodies only with `include_body=true`. Values that a spreadsheet would run as a formula are prefixed with `'`. |

*Download as CSV:*

```bash
curl "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/export?format=csv" \
  -H "Authorization: Bearer $VP_KEY" \
  -o results.csv
```

`status=failed` (or any item status) exports only those items; `include_body=false` leaves out page bodies, screenshots and PDFs. The export is free and works as long as the results are kept (24 hours after the job ended).

## Send the failed requests again

`POST /v1/jobs/{id}/retry` creates a new job from the requests of this job that failed – exactly as they were sent, with the same webhook and tag – and answers `202` with the new job. Requests that succeeded are not sent again. A job without failed requests answers `nothing_to_retry` (409).

## Results as they come: the stream

`GET /v1/jobs/{id}/stream` keeps the connection open and sends one line of JSON for every finished item while the job runs (NDJSON): first `{"type": "start", "job"}`, then `{"type": "item", "index", "status", "response" | "error", …}`, at the end `{"type": "end", "job"}`. Without news a `{"type": "ping"}` line comes every 25 seconds. After 15 minutes a `{"type": "reconnect", "after"}` line ends the call: call again with `?after=` that value and nothing is lost or repeated. `?include_body=false` leaves out page bodies, screenshots and PDFs. Up to 5 streams can be open at once per account.

*Follow a job:*

```bash
curl -N https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T/stream \
  -H "Authorization: Bearer $VP_KEY"
```

## Long lists as a file (NDJSON)

Send up to 32 MB as `Content-Type: application/x-ndjson`: one request per line. An optional first line `{"job": {…}}` carries the job's own options – `webhook`, `tag`, `max_credits`, `delivery`.

*urls.ndjson:*

```json
{"job": {"tag": "nightly", "delivery": {"destination": "dst_9Lk2Vb7Qx0Pm3Rn5Tz8W"}}}
{"url": "https://shop.example/p/1", "auto_extract": "product"}
{"url": "https://shop.example/p/2", "auto_extract": "product"}
```

*Send it:*

```bash
curl https://api.virginproxy.com/v1/jobs \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/x-ndjson" \
  --data-binary @urls.ndjson
```

Results can go straight into your own bucket when the job ends: see [Delivery to your storage](https://docs.virginproxy.com/delivery/).

## List your jobs

`GET /v1/jobs` returns your jobs, newest first: `?limit=1..100&before=<job id>`. The answer is `{"items": [job, …], "next": "<job id>" | null}`; pass `next` as `before` for the next page.

## Cancel a job

**cURL**

```bash
curl -X DELETE https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T \
  -H "Authorization: Bearer $VP_KEY"
```

**Python**

```python
import os, requests

r = requests.delete(
    "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    timeout=30,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["canceled"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T", {
  method: "DELETE",
  headers: { Authorization: "Bearer " + process.env.VP_KEY },
  signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.canceled);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("DELETE", "/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T")
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.call("DELETE", "/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T");
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
    ],
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["canceled"], PHP_EOL;
```

**Go**

```go
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	req, err := http.NewRequest("DELETE", "https://api.virginproxy.com/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))

	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["status"], data["canceled"])
}
```

DELETE`/v1/jobs/job_8fK2pQ7wLz3nVd0sXa4T`

Items that have not started are marked `canceled` and cost nothing; items already running finish normally. The job's status becomes `canceled`.

## Batches: a few requests, answered at once

When you need a handful of pages *now* and do not want to poll a job, send them to `POST /v1/batch`. They run at the same time, up to your plan's parallel limit, and the answer comes when all are done – within about 85 seconds. Send full request bodies in `requests`, or a list of `urls` with the options for every URL in `request`:

**cURL**

```bash
curl https://api.virginproxy.com/v1/batch \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": [
      "https://example.com/",
      "https://example.org/"
    ],
    "request": {
      "format": "markdown",
      "main_content": true
    },
    "max_credits": 50
  }'
```

**Python**

```python
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/batch",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={
        "urls": ["https://example.com/", "https://example.org/"],
        "request": {"format": "markdown", "main_content": True},
        "max_credits": 50,
    },
    timeout=120,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["succeeded"], data["cost"]["credits"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/batch", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    urls: ["https://example.com/", "https://example.org/"],
    request: { format: "markdown", main_content: true },
    max_credits: 50,
  }),
  signal: AbortSignal.timeout(120_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.succeeded, data.cost.credits);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("POST", "/v1/batch", {
    "urls": ["https://example.com/", "https://example.org/"],
    "request": {"format": "markdown", "main_content": True},
    "max_credits": 50,
})
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.batch({
  urls: ["https://example.com/", "https://example.org/"],
  request: { format: "markdown", main_content: true },
  max_credits: 50,
});
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/batch");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 120,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "urls" => ["https://example.com/", "https://example.org/"],
        "request" => ["format" => "markdown", "main_content" => true],
        "max_credits" => 50,
    ], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["succeeded"], " ", $data["cost"]["credits"], PHP_EOL;
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	payload := []byte(`{
  "urls": [
    "https://example.com/",
    "https://example.org/"
  ],
  "request": {
    "format": "markdown",
    "main_content": true
  },
  "max_credits": 50
}`)
	req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/batch", bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 120 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["succeeded"], data["cost"].(map[string]any)["credits"])
}
```

POST`/v1/batch`[≈ 2 credits](https://docs.virginproxy.com/billing/#cost)

*Response · 200 OK (shortened):*

```json
{
  "requests": 2,
  "succeeded": 1,
  "failed": 1,
  "skipped": 0,
  "items": [
    {
      "index": 0,
      "status": "succeeded",
      "response": { "id": "req_Rk2VwP8sLm4nQx7TbZ1c", "status": 200, "final_url": "https://example.com/", "format": "markdown", "body": "# Example Domain\n…", "cost": { "credits": 1 }, "…": "…" }
    },
    {
      "index": 1,
      "status": "failed",
      "request_id": "req_Hd5YtM0qWn3cLs9KpA7e",
      "error": { "code": "timeout", "message": "The target did not answer in time. This request was not charged.", "charged": false }
    }
  ],
  "cost": { "credits": 1, "credits_used": 413, "credits_included": 25000 },
  "duration_ms": 31877
}
```

- Every request is an ordinary request: the same checks, the same charge, its own entry in your request log. One that fails does not stop the others; its `error` says whether it was charged.
- `items` are in the order you sent them. `status` is `succeeded`, `failed` or `skipped`.
- `max_credits` bounds the whole batch. A request that would go beyond what is left, or that could not start in time, is `skipped` with `batch_item_skipped` and costs nothing.
- An invalid request refuses the whole batch before anything runs (`invalid_batch` with `error.index`).
- A batch keeps no answer and takes no `Idempotency-Key`. For more requests, more time or results you can fetch later, use a job.

| Plan | Requests per batch |
| --- | --- |
| Free | 3 |
| Starter | 10 |
| Growth | 20 |
| Scale | 25 |

## Limits

| Plan | Requests per job | Pages per crawl |
| --- | --- | --- |
| Free | 10 | 10 |
| Starter | 1,000 | 100 |
| Growth | 10,000 | 500 |
| Scale | 50,000 | 1,000 |

- Jobs run within your plan's limits: at most as many requests at the same time and per second as your plan allows, across all your jobs together, with your plan's [priority](https://docs.virginproxy.com/priority/).
- Temporary limits never fail an item: when it meets `rate_limited`, `concurrency_limited` or `busy`, it simply waits and runs a little later.
- An account can have 20 jobs that are queued or running. A 21st is refused with `too_many_jobs` (429).

## Cost

Each item costs exactly what the same single request would cost; the job itself is free. Canceled items and items the target never answered cost nothing. When your credits run out during a job, the items that have not run yet fail with `credits_exhausted`. To cap single items, give them `max_credits`, see [Credits and billing](https://docs.virginproxy.com/billing/#max-credits).

## Retention

The results of a job are kept for 24 hours after it finished, then deleted for good; `GET` then answers `job_expired` (404). The request itself – its headers, cookies and body – is deleted as soon as its item has run. See [What we store](https://docs.virginproxy.com/security/#stored).

> **Note:** In the dashboard, the **Jobs** page shows every job with its progress, lets you cancel it, download its results as JSON Lines or as a CSV overview (one line per URL with status, final URL, HTTP status, credits and error code, without the page bodies), copy the URLs that failed and see each webhook delivery.
