# Crawl a batch

`POST /v1/crawls/batch`

Queue up to 100 URLs in one request; poll the job or get it at your webhook.

Family: Crawl API

## Price

Unit: page

| Mode | Price (USD) |
|---|---|
| Live | $0.00011 |

| Fetch level | Price (USD) |
|---|---|
| standard | $0.00011 |
| rendered | $0.0011 |
| protected | $0.003 |

Per page, at the level that delivered it.

## Description

Returns 202 with a `job_id` straight away. Read the results with GET /v1/crawls/{id}, or set `webhook_url` and we POST the finished job to it. Options apply to every target. If any target isn't a valid public URL, nothing is queued and the response lists each bad target.

The wallet check reserves the worst case for every target (or `max_cost` each). **Billing.** One page at the price of the fetch level that delivered it (Standard $0.00011, Rendered $0.0011, Protected $0.003). Blocked, failed and non-substantive pages cost $0.

## Authentication

HTTP Basic auth: any login, with your `dg_` API key as the password. A `Bearer` token header with the key also works.

## Request

Send a JSON object.

| Field | Type | Required | Description |
|---|---|---|---|
| `targets` | array<object> | yes | The pages to fetch, 1 to 100. min 1; max 100 |
| `targets.url` | string | yes | An absolute http(s) URL on a public host. max 2000 |
| `webhook_url` | string | no | We POST the finished job (the GET /v1/crawls/{id} body) here. Must be https on a public host. max 2000 |
| `auto_upgrade` | boolean | no | Lets a blocked page move to a higher fetch level, billed at the level that delivered it. `false` stops at the requested level and returns the failure at $0. default `true` |
| `max_level` | string | no | The highest fetch level Auto-upgrade may use. default `protected`; one of `standard`, `rendered`, `protected` |
| `max_cost` | number\|null | no | The most one page may cost, in USD, up to 6 decimal places. The wallet check reserves this instead of the worst-case price, and a fetch never upgrades past it. min 0 |
| `output_format` | string | no | What `content` holds: Markdown text, the page HTML, or a JSON object of the page's title, text and metadata. default `markdown`; one of `markdown`, `html`, `json` |
| `engine` | string | no | The level to start at. `rendered` runs JavaScript from the first fetch and needs `max_level` rendered or protected. `browser` is accepted as an older name for `rendered`. default `standard`; one of `standard`, `rendered` |
| `render_js` | boolean | no | `true` is the same as `engine: rendered`. default `false` |
| `include_receipt` | boolean | no | Include the receipt on each task. default `true` |
| `project_id` | string\|null | no | A project in your organization to file this under. Leave it out for the default project. |

### Example request

```bash
curl -X POST "https://api.dataforgaio.com/v1/crawls/batch" \
  -u "api:$DATAFORGAIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "targets": [
    {
      "url": "https://summitrunning.example/trail-shoes"
    },
    {
      "url": "https://summitrunning.example/stores"
    }
  ],
  "webhook_url": "https://hooks.summitrunning.example/crawls"
}'
```

## Response

| Field | Type | Description |
|---|---|---|
| `job_id` | string | Job id, `job_…`. |
| `tasks_count` | integer | Number of targets queued. |
| `status` | string | Always `queued`. |

### Example response

```json
{
  "job_id": "job_8cbb5b5c8e155c82995945f93cdad009",
  "tasks_count": 2,
  "status": "queued"
}
```

## Errors

| Code | When |
|---|---|
| invalid_request | HTTP 400. Invalid options, an empty list, or more than 100 targets. |
| unauthorized | HTTP 401. Missing, malformed or revoked API key. |
| balance_required | HTTP 402. Your wallet balance is below the most this request could cost. Nothing ran. |
| invalid_target | HTTP 422. A URL is not an absolute public http(s) URL. Nothing was fetched. |
| rate_limited | HTTP 429. Too many requests, or too many inline requests in flight for your organization. Honor `Retry-After`. |

## Related

- [Crawl a page](https://dataforgaio.com/docs/api/crawls-create.md): Fetch one page now and get its content with a receipt: where and when it was fetched, what robots.txt and the site's AI-use signals said, a content hash and the cost.
- [Get a crawl](https://dataforgaio.com/docs/api/crawls-get.md): A batch job and its tasks, or one task, with content and receipts.
- [Get crawl receipts](https://dataforgaio.com/docs/api/crawls-receipt.md): Just the receipts for a job or task, one per page.
