# POST /v2/crawl

> Start a crawl of one onion site. It returns a job id to read.

POST `/v2/crawl`

**Authentication:** your key as a [bearer token](https://darkcrawl.dev/docs/api-reference/authentication/).

## Body

| Field                                | Type                                                                                                                                                                                                                                | Required | Default        |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |
| `url`                                | `string`                                                                                                                                                                                                                            | Required |                |
| `allowExternalLinks`                 | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `allowSubdomains`                    | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `crawlEntireDomain`                  | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `deduplicateSimilarURLs`             | `boolean`                                                                                                                                                                                                                           | Optional | `true`         |
| `delay`                              | `number \| null`                                                                                                                                                                                                                    | Optional |                |
| `excludePaths`                       | `string[]`                                                                                                                                                                                                                          | Optional | `[]`           |
| `ignoreQueryParameters`              | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `ignoreRobotsTxt`                    | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `includePaths`                       | `string[]`                                                                                                                                                                                                                          | Optional | `[]`           |
| `limit`                              | `integer`                                                                                                                                                                                                                           | Optional | `10000`        |
| `maxConcurrency`                     | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `maxDiscoveryDepth`                  | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `maxPagesPerPattern`                 | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `regexOnFullURL`                     | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `scrapeOptions`                      | `object \| null`                                                                                                                                                                                                                    | Optional |                |
| `scrapeOptions.checkPromptInjection` | `boolean \| null`                                                                                                                                                                                                                   | Optional |                |
| `scrapeOptions.excludeTags`          | `string[]`                                                                                                                                                                                                                          | Optional | `[]`           |
| `scrapeOptions.formats`              | `(string \| object)[]`                                                                                                                                                                                                              | Optional | `["markdown"]` |
| `scrapeOptions.headers`              | `object`                                                                                                                                                                                                                            | Optional | `{}`           |
| `scrapeOptions.includeTags`          | `string[]`                                                                                                                                                                                                                          | Optional | `[]`           |
| `scrapeOptions.maxTextBytes`         | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `scrapeOptions.onlyMainContent`      | `boolean`                                                                                                                                                                                                                           | Optional | `true`         |
| `scrapeOptions.parsers`              | `(string \| object)[]`                                                                                                                                                                                                              | Optional |                |
| `scrapeOptions.redactPII`            | `boolean \| object`                                                                                                                                                                                                                 | Optional |                |
| `scrapeOptions.render`               | `string` Values: `auto`, `never`, `always`                                                                                                                                                                                          | Optional | `"auto"`       |
| `scrapeOptions.skipTlsVerification`  | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `scrapeOptions.timeout`              | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `scrapeOptions.waitFor`              | `integer`                                                                                                                                                                                                                           | Optional | `0`            |
| `sitemap`                            | `string` Values: `skip`, `include`, `only`                                                                                                                                                                                          | Optional | `"include"`    |
| `webhook`                            | `string \| object \| null`                                                                                                                                                                                                          | Optional |                |
| `webhook.url`                        | `string`                                                                                                                                                                                                                            | Required |                |
| `webhook.events`                     | `string[] \| null` Values: `started`, `page`, `completed`, `failed`, `crawl.started`, `crawl.page`, `crawl.completed`, `crawl.failed`, `batch_scrape.started`, `batch_scrape.page`, `batch_scrape.completed`, `batch_scrape.failed` | Optional |                |
| `webhook.headers`                    | `object \| null`                                                                                                                                                                                                                    | Optional |                |
| `webhook.metadata`                   | `object \| null`                                                                                                                                                                                                                    | Optional |                |

Firecrawl compatibility fields

Firecrawl fields DarkCrawl does not offer. It takes them so the Firecrawl SDKs keep working, then ignores or refuses each one as the table says.

| Field                              | What DarkCrawl does                                   |
| ---------------------------------- | ----------------------------------------------------- |
| `integration`                      | Accepted and ignored.                                 |
| `origin`                           | Accepted and ignored.                                 |
| `prompt`                           | Ignored, with a warning when set.                     |
| `robotsUserAgent`                  | Ignored, with a warning when set.                     |
| `scrapeOptions.actions`            | Answers 400 NOT_IMPLEMENTED when not empty.           |
| `scrapeOptions.auditMetadata`      | Accepted and ignored.                                 |
| `scrapeOptions.blockAds`           | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.domainTools`        | Accepted and ignored.                                 |
| `scrapeOptions.fastMode`           | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.integration`        | Accepted and ignored.                                 |
| `scrapeOptions.location`           | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.lockdown`           | Answers 400 BAD_REQUEST when true.                    |
| `scrapeOptions.maxAge`             | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.minAge`             | Answers 400 BAD_REQUEST when set.                     |
| `scrapeOptions.mobile`             | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.onlyCleanContent`   | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.origin`             | Accepted and ignored.                                 |
| `scrapeOptions.profile`            | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.proxy`              | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.removeBase64Images` | Accepted and ignored.                                 |
| `scrapeOptions.safeMode`           | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.storeInCache`       | Ignored, with a warning when not Firecrawl's default. |
| `scrapeOptions.threatProtection`   | Accepted and ignored.                                 |
| `scrapeOptions.toolDetail`         | Accepted and ignored.                                 |
| `scrapeOptions.useMock`            | Accepted and ignored.                                 |
| `scrapeOptions.zeroDataRetention`  | Ignored, with a warning when not Firecrawl's default. |
| `zeroDataRetention`                | Ignored, with a warning when set.                     |

## Request

**curl**

```bash
curl -X POST https://api.darkcrawl.dev/v2/crawl \
  -H "Authorization: Bearer $DARKCRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice","limit":20}'
```

**Python**

```python
import os
import requests

resp = requests.post(
    "https://api.darkcrawl.dev/v2/crawl",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    json={
        "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
        "limit": 20,
    },
    timeout=330,
)
print(resp.json())
```

**Node**

```javascript
const resp = await fetch("https://api.darkcrawl.dev/v2/crawl", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.DARKCRAWL_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
    "limit": 20
  }),
  signal: AbortSignal.timeout(330000),
});
console.log(await resp.json());
```

## Response

Status `200`.

```json
{
  "success": true,
  "id": "01K0EXAMPLEJOB00000000000A",
  "url": "https://api.darkcrawl.dev/v2/crawl/01K0EXAMPLEJOB00000000000A"
}
```

## Errors

| Code                    | Status |
| ----------------------- | ------ |
| `BAD_REQUEST`           | 400    |
| `INVALID_ONION`         | 400    |
| `POLICY_FORBIDDEN`      | 400    |
| `BLOCKLISTED`           | 403    |
| `BLOCKLIST_UNAVAILABLE` | 503    |
| `SECRETS_UNAVAILABLE`   | 503    |
| `AI_UNAVAILABLE`        | 503    |
| `QUOTA_EXCEEDED`        | 402    |
| `RATE_LIMITED`          | 429    |

What each code means, and what to do about it: [Errors](https://darkcrawl.dev/docs/api-reference/errors/).

## Notes

- A `limit` above the plan's crawl maximum is lowered to it, and a `limit` above the pages you have left is lowered again. The job's `warning` says so. With no pages left, nothing starts.
- Poll `url` for the job. `expiresAt` in its status says when the job's listing expires.
- The call reserves the job's pages before it stores anything, and charges the pages the job read when it ends. [Rate limits](https://darkcrawl.dev/docs/api-reference/rate-limits/) has what can refuse it.
- A `webhook` sends the job's events to your receiver, which must be `https`. See [Webhooks](https://darkcrawl.dev/docs/api-reference/webhooks/).
