> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Zenrows HTTP API serves Fetch and Extract (extract=auto) at https://api.zenrows.com/v1/, Crawl at https://api.zenrows.com/v1/crawls, and Batch at https://async.api.zenrows.com/v1. Fetch, Extract, Crawl and Batch are described in OpenAPI 3.1 at https://www.zenrows.com/openapi.json and listed in the RFC 9727 API catalog at https://www.zenrows.com/.well-known/api-catalog. Every endpoint also has its own page under /api-reference with its schema. Use the spec for exact parameter names and types. Crawl's endpoints, parameters and errors are also at https://docs.zenrows.com/crawl/endpoints.md. To call Zenrows from an agent, connect the MCP server at https://mcp.zenrows.com/mcp. To search these docs from an agent, connect the docs MCP server at https://docs.zenrows.com/mcp. Agent skills for Zenrows are published at https://github.com/ZenRows/cli and install with `npx skills add ZenRows/cli`.

# Batch

> Process thousands of URLs reliably, in one job, and check the cost before you spend a single credit.

`zenrows batch` runs the same fetch or extract job across a list of URLs as a single, trackable job on [Batch](https://docs.zenrows.com/batch/introduction.md): submit once, then check status, collect results, or recover the tasks that didn't finish whenever you want.

```bash theme={"theme":"css-variables"}
zenrows batch <estimate|create|list|status|wait|results|content|cancel|pause|resume|rerun|retry-failed|delete> [flags]
```

This page describes `@zenrows/cli` 1.8.0 or later. `list`, `content`, `pause`, `resume`, `rerun` and `delete`, the `job_id` key in `--json` output and the 10,000 URL default cap arrived in 1.8.0.

`jobs.jsonl` is one JSON object per line, each with a `url` and optional per-line overrides: scrape params such as `js_render`, `premium_proxy`, `proxy_country`, `mode` or `extract` (flat on the line or in a nested `zenrows_params`), an `external_id`, string `metadata`, and `"method": "POST"` with a `body` of up to 16 KiB. `"body": null` is the same as no body.

Every task uses [Adaptive Stealth Mode](https://docs.zenrows.com/fetch/features/adaptive-stealth-mode.md) (`mode=auto`) by default, like `zenrows fetch` and `zenrows extract`. A line that sets `js_render`, `premium_proxy`, or `mode` keeps its own settings. `--js-render` or `--premium-proxy` forces that configuration on every task, and `--manual` turns Adaptive Stealth Mode off.

## Local, no key needed

```bash theme={"theme":"css-variables"}
zenrows batch estimate jobs.jsonl
```

Checks every line before anything is sent, against the API's limits: a valid `http` or `https` `url` of up to 2,048 bytes, an `external_id` of up to 128 letters, digits, `.`, `_` or `-`, and `metadata` of up to 20 string entries (4 KiB). It then estimates the credit cost with no cloud call. `estimate` takes the same `--manual`, `--js-render`, `--premium-proxy` and `--proxy-country` flags as `create`, so both price the same request. Adaptive Stealth Mode costs 1 to 25 credits per task, so the estimate is a range whose upper bound is the most the job can cost. Parameter names and values are checked by the API when you submit.

> [!NOTE]
>
> The CLI ships with a local safety policy that caps every run at **10,000 URLs** and an estimated **250,000 credits**, so a default run of up to 10,000 URLs passes in any mode. Batch takes up to 100,000 tasks per job: for larger jobs, raise the caps with `zenrows policy set max_pages_per_run 100000` and `zenrows policy set max_credits_per_run 2500000`. A run over a cap stops with `POLICY_LIMIT_EXCEEDED` before anything is sent, and the error prints the `zenrows policy set` command to run. A workspace created by an earlier CLI version keeps its old caps (1,000 URLs and 10,000 credits) in `policy.json`.

## Cloud

```bash theme={"theme":"css-variables"}
# Submit a job and wait for it to finish
zenrows batch create jobs.jsonl --follow

# List your jobs, newest first
zenrows batch list

# Check status, progress and pause state
zenrows batch status <job-id>

# Wait for a run that's already going
zenrows batch wait <job-id> --timeout 30m

# Collect results (paginated), or save every body to a folder
zenrows batch results <job-id> --out results.jsonl
zenrows batch results <job-id> --download ./pages

# Print one task's result body
zenrows batch content <job-id> <task-id>

# Pause the run, then continue it
zenrows batch pause <job-id>
zenrows batch resume <job-id>

# Stop an in-flight run
zenrows batch cancel <job-id>

# Rerun the failed and pending tasks; successful tasks carry over
zenrows batch rerun <job-id>

# Delete the job, its runs and its stored results
zenrows batch delete <job-id> --yes
```

### Waiting

`create --follow`, `rerun --follow` and `wait` poll until the run ends, the run is paused, or `--timeout` runs out. The default timeout is 10 minutes; it takes `30s`, `5m` or `1h`, and a bare number is milliseconds. When the time runs out, or the run is paused, the command exits `0` and prints the run with a `note` and the next command to run; the job keeps going. Ctrl-C stops the wait, not the job, and exits `130`.

### Failed runs and recovery

A run that ends `failed` stopped for an account reason, and the command exits `1` with the same code a refused request gets: `POLICY_MAX_CREDITS_EXCEEDED` when the account ran out of credits, `AUTH_INVALID` for an inactive subscription, `KEY_CREDIT_CAP_REACHED` for an API key's [credit cap](https://docs.zenrows.com/first-steps/api-key-credit-caps.md), and `BATCH_FAILED` otherwise. The error carries the run's `failure_reason` as `server_code`, and the `job_id`. Fix the cause, then run the unfinished tasks again:

```bash theme={"theme":"css-variables"}
zenrows batch rerun <job-id>                                   # failed and pending tasks
zenrows batch rerun <job-id> --status failed,pending,processing # pick the statuses
zenrows batch rerun <job-id> --all                             # every task, a full rerun
zenrows batch retry-failed <job-id> --include-pending          # the same as the --status line above
```

With no flag, `rerun` reruns the `failed` and `pending` tasks, so successful tasks are never billed again by surprise. `retry-failed` reruns only the `failed` ones; `--include-pending` adds the `pending` and `processing` tasks, the same as `--status failed,pending,processing`. A partial rerun works within 10 days of when the run you retry started; `--all` always works.

### Idempotency and retries

`create`, `rerun` and `retry-failed` send an `Idempotency-Key`, generated unless you pass `--idempotency-key`. Network errors and `502`, `503` and `504` answers are retried under that key, so a retry can't start a second job or run. When the outcome stays unknown, the error prints the command that repeats the request with the same key, shell-quoted so you can run it as printed.

### Results

A result's `result_url` is valid for 2 hours. Results are kept 14 days by default; after that a successful task reads `expired`, and `results --download` skips it. `content` on an expired task fails with `BATCH_RESULT_EXPIRED`.

## Flags

`--json` (print structured output) works on every subcommand. With `--json`, `create`, `status`, `wait`, `cancel`, `pause`, `resume` and `rerun` print `{ok, job_id, run_id, status, stats, job}`, plus `paused`, `ingest_status`, `accepted_tasks`, `rerun_of`, `retried_tasks` and `inherited_tasks` when the API sends them. The rest are subcommand-specific:

| Subcommand | Flags |
| - | - |
| `estimate <file.jsonl>` | `--manual`, `--js-render`, `--premium-proxy`, `--proxy-country <cc>` |
| `create <file.jsonl>` | `--manual`, `--js-render`, `--premium-proxy`, `--proxy-country <cc>` (in auto mode, or with `--premium-proxy`), `--output <fmt>` (`markdown`\|`plaintext`\|`pdf`\|`html`), `--name <name>` (up to 100 characters), `--external-id <id>`, `--metadata <key=value>` (repeatable, up to 20), `--idempotency-key <key>`, `--follow` (alias `--wait`), `--timeout <duration>`, `--no-signup` (don't create a Free plan account when no key is configured) |
| `list` | `--status <open\|closed>`, `--type <regular\|scheduled>`, `--limit <n>` (up to 100), `--cursor <c>` |
| `wait <id>` | `--timeout <duration>` (default 10m) |
| `results <id>` | `--status <successful\|failed\|processing\|all>`, `--run <run_id>`, `--out <file>`, `--download <dir>` (fetches each result body, plus a `_manifest.jsonl`) |
| `content <id> <task_id>` | `--run <run_id>`, `--out <file>` |
| `rerun <id>` | `--status <list>`, `--all`, `--idempotency-key <key>`, `--follow`, `--timeout <duration>` |
| `retry-failed <id>` | `--include-pending`, `--idempotency-key <key>`, `--follow`, `--timeout <duration>` |
| `delete <id>` | `--yes` (required) |

> [!NOTE]
>
> Schedules, webhooks, ZIP exports, CSV inputs and open jobs (adding tasks over time) are available through the [Batch API](https://docs.zenrows.com/batch/developer-guide-restapi.md) and the [SDKs](https://docs.zenrows.com/batch/sdk/python.md), not this CLI.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.