@hunt-labs/bytekit-mcp 0.3.22 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,32 @@ today, see [README.md](./README.md), which remains the authoritative usage guide
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.3.24] - 2026-11-12
14
+
15
+ ### Changed
16
+
17
+ - Refreshed the bundled documentation snapshot after `viewport` became bounded (#5628): the
18
+ screenshots guide and the Python SDK monitors page now document a width of 360 to 2544 px and a
19
+ height of 1 to 1297 px, and any other size as a 422 `validation_error`. This refresh itself changes
20
+ no tool, schema or transport.
21
+ - Refreshed the bundled documentation snapshot after the scrape `mobile` option was re-described
22
+ (#5628): the scraping guide, the SDK scrape pages and the CLI scrape page now say that a page
23
+ rendered in a browser renders in a phone-sized window with a desktop (Windows) browser identity.
24
+ This refresh itself changes no tool, schema or transport.
25
+
26
+ ## [0.3.23] - 2026-11-04
27
+
28
+ ### Changed
29
+
30
+ - Refreshed the bundled documentation snapshot after the new internal `GET /v1/bulk/concurrency`
31
+ operation (#3718): the bundled `api/bulk` index gains a `getbulkconcurrency` page and the
32
+ `guides/bulk` page gains a "Checking bulk concurrency" section. This refresh itself changes no tool,
33
+ schema or transport.
34
+ - Refreshed the bundled documentation snapshot after `device_scale_factor` narrowed to `1` (#5630):
35
+ the screenshot and bulk API pages and the screenshots guide now document only `1` (or `null`), and any
36
+ other value as a 422 `validation_error`. The server has no screenshot tool parameter for it, so no
37
+ tool, schema or transport changes.
38
+
13
39
  ## [0.3.22] - 2026-10-27
14
40
 
15
41
  ### Added
@@ -17,12 +17,12 @@
17
17
  "api/bulk": {
18
18
  "title": "Bulk",
19
19
  "section": "API Reference",
20
- "body": "# Bulk\n\nBulk API — endpoints, requests, and responses.\n\nThe **Bulk** API. 5 endpoints:\n\n- [List bulk jobs](https://bytekit.com/docs/api/bulk/listbulk) — GET /v1/bulk\n- [Create mixed bulk job](https://bytekit.com/docs/api/bulk/createbulk) — POST /v1/bulk\n- [Get bulk job status](https://bytekit.com/docs/api/bulk/getbulk) — GET /v1/bulk/:id\n- [Cancel a bulk job](https://bytekit.com/docs/api/bulk/deletebulk) — DELETE /v1/bulk/:id\n- [List bulk job items](https://bytekit.com/docs/api/bulk/listbulkscreenshots) — GET /v1/bulk/:id/screenshots"
20
+ "body": "# Bulk\n\nBulk API — endpoints, requests, and responses.\n\nThe **Bulk** API. 6 endpoints:\n\n- [List bulk jobs](https://bytekit.com/docs/api/bulk/listbulk) — GET /v1/bulk\n- [Create mixed bulk job](https://bytekit.com/docs/api/bulk/createbulk) — POST /v1/bulk\n- [Get bulk concurrency usage](https://bytekit.com/docs/api/bulk/getbulkconcurrency) — GET /v1/bulk/concurrency\n- [Get bulk job status](https://bytekit.com/docs/api/bulk/getbulk) — GET /v1/bulk/:id\n- [Cancel a bulk job](https://bytekit.com/docs/api/bulk/deletebulk) — DELETE /v1/bulk/:id\n- [List bulk job items](https://bytekit.com/docs/api/bulk/listbulkscreenshots) — GET /v1/bulk/:id/screenshots"
21
21
  },
22
22
  "api/bulk/createbulk": {
23
23
  "title": "Create mixed bulk job",
24
24
  "section": "API Reference",
25
- "body": "# Create mixed bulk job\n\nEnqueues screenshots or scrapes in a single batch.\nProvide `urls` (simple list) or `items` (per-item config), not both.\nWebhook deliveries include `X-ByteKit-Event: bulk.completed` so\nreceivers can dispatch on the header without parsing the body shape.\nThe body follows `BulkCompletedWebhook`: at most 500 complete items and\n1 MiB, followed by cursor recovery through the existing mixed-item route\nwhenever `recovery_required` is true.\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 4 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 32 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's richer per-item override\nbudget), which reaches 28.7 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 4 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n\n**POST** `/v1/bulk`\n\n## Request Body\n\n- `urls`\n- `items`\n- `items.url`\n- `items.type`\n- `items.device`\n- `items.format`\n- `items.quality`\n- `items.full_page`\n- `items.block_ads`\n- `items.block_cookie_banners`\n- `items.scroll`\n- `items.include_html`\n- `items.country`\n- `items.language`\n- `items.dark_mode`\n- `items.formats`\n- `items.formats.type`\n- `items.formats.schema`\n- `items.formats.model`\n- `items.formats.prompt`\n- `items.wait_until`\n- `items.wait_for_selector`\n- `items.delay_ms`\n- `items.viewport`\n- `items.viewport.width`\n- `items.viewport.height`\n- `items.duration`\n- `items.scenario`\n- `items.metadata`\n- `defaults`\n- `defaults.type`\n- `defaults.device`\n- `defaults.format`\n- `defaults.quality`\n- `defaults.full_page`\n- `defaults.block_ads`\n- `defaults.block_cookie_banners`\n- `defaults.scroll`\n- `defaults.include_html`\n- `defaults.country`\n- `defaults.language`\n- `defaults.dark_mode`\n- `defaults.formats`\n- `defaults.formats.type`\n- `defaults.formats.schema`\n- `defaults.formats.model`\n- `defaults.formats.prompt`\n- `defaults.wait_until`\n- `defaults.wait_for_selector`\n- `defaults.delay_ms`\n- `defaults.viewport`\n- `defaults.viewport.width`\n- `defaults.viewport.height`\n- `defaults.device_scale_factor`\n- `webhook_url` (required)\n- `webhook_secret`\n- `metadata`\n\n## Responses\n\n### 202 — Bulk job accepted.\n- `id`\n- `status`\n- `total`\n- `completed`\n- `failed`\n- `created_at`\n- `completed_at`\n- `total_credits_charged`\n- `total_billed_bytes`\n- `estimated_credits`\n- `webhook_url`\n\n### 400 — Bad request. When a `url` (or item URL) fails strict validation the\nerror code is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — One or more URLs in the request are on ByteKit's blocklist. The whole request is\nrejected before anything is queued or billed. This body is NOT the unified `Error`\nenvelope: it carries no `status`, `http_status` or `failed_at`. `blocked` lists every\noffending URL with the rule that matched (`domain`, `tld`, `port` or `path`) and the\ncode that rule maps to (`host_forbidden` for the first three, `path_forbidden` for\n`path`).\n- `error`\n- `error.code`\n- `error.message`\n- `blocked`\n- `blocked.url`\n- `blocked.rule_type`\n- `blocked.error_code`\n\n### 422 — Validation error. `bulk_too_large` is returned when the item count\nexceeds the account plan's `max_bulk_size` cap (also surfaced as\n`max_bulk_size` on `GET /v1/account`). `validation_error` is\nreturned when the request body contains an unrecognized key\nanywhere in the top-level object, an `items[]` entry, or\n`defaults` — all three reject unknown keys with a 422\n`validation_error` whose `details` message names the offending\nkey, instead of silently discarding it. The two nested objects\ndo not accept the same field set: `device_scale_factor` is\n`defaults`-only (rejected per item), and `duration`/`scenario`\nare `items[]`-only (rejected under `defaults`). `metadata` is\nvalid both at the top level of the body and per item, but is\nrejected with this same 422 if placed under `defaults`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
25
+ "body": "# Create mixed bulk job\n\nEnqueues screenshots or scrapes in a single batch.\nProvide `urls` (simple list) or `items` (per-item config), not both.\nWebhook deliveries include `X-ByteKit-Event: bulk.completed` so\nreceivers can dispatch on the header without parsing the body shape.\nThe body follows `BulkCompletedWebhook`: at most 500 complete items and\n1 MiB, followed by cursor recovery through the existing mixed-item route\nwhenever `recovery_required` is true.\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 4 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 32 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's richer per-item override\nbudget), which reaches 28.7 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 4 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n\n**POST** `/v1/bulk`\n\n## Request Body\n\n- `urls`\n- `items`\n- `items.url`\n- `items.type`\n- `items.device`\n- `items.format`\n- `items.quality`\n- `items.full_page`\n- `items.block_ads`\n- `items.block_cookie_banners`\n- `items.scroll`\n- `items.include_html`\n- `items.country`\n- `items.language`\n- `items.dark_mode`\n- `items.formats`\n- `items.formats.type`\n- `items.formats.schema`\n- `items.formats.model`\n- `items.formats.prompt`\n- `items.wait_until`\n- `items.wait_for_selector`\n- `items.delay_ms`\n- `items.viewport`\n- `items.viewport.width`\n- `items.viewport.height`\n- `items.duration`\n- `items.scenario`\n- `items.metadata`\n- `defaults`\n- `defaults.type`\n- `defaults.device`\n- `defaults.format`\n- `defaults.quality`\n- `defaults.full_page`\n- `defaults.block_ads`\n- `defaults.block_cookie_banners`\n- `defaults.scroll`\n- `defaults.include_html`\n- `defaults.country`\n- `defaults.language`\n- `defaults.dark_mode`\n- `defaults.formats`\n- `defaults.formats.type`\n- `defaults.formats.schema`\n- `defaults.formats.model`\n- `defaults.formats.prompt`\n- `defaults.wait_until`\n- `defaults.wait_for_selector`\n- `defaults.delay_ms`\n- `defaults.viewport`\n- `defaults.viewport.width`\n- `defaults.viewport.height`\n- `defaults.device_scale_factor`\n- `webhook_url` (required)\n- `webhook_secret`\n- `metadata`\n\n## Responses\n\n### 202 — Bulk job accepted.\n- `id`\n- `status`\n- `total`\n- `completed`\n- `failed`\n- `created_at`\n- `completed_at`\n- `total_credits_charged`\n- `total_billed_bytes`\n- `estimated_credits`\n- `webhook_url`\n\n### 400 — Bad request. When a `url` (or item URL) fails strict validation the\nerror code is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — One or more URLs in the request are on ByteKit's blocklist. The whole request is\nrejected before anything is queued or billed. This body is NOT the unified `Error`\nenvelope: it carries no `status`, `http_status` or `failed_at`. `blocked` lists every\noffending URL with the rule that matched (`domain`, `tld`, `port` or `path`) and the\ncode that rule maps to (`host_forbidden` for the first three, `path_forbidden` for\n`path`).\n- `error`\n- `error.code`\n- `error.message`\n- `blocked`\n- `blocked.url`\n- `blocked.rule_type`\n- `blocked.error_code`\n\n### 422 — Validation error. `bulk_too_large` is returned when the item count\nexceeds the account plan's `max_bulk_size` cap (also surfaced as\n`max_bulk_size` on `GET /v1/account`). `validation_error` is\nreturned when the request body contains an unrecognized key\nanywhere in the top-level object, an `items[]` entry, or\n`defaults` — all three reject unknown keys with a 422\n`validation_error` whose `details` message names the offending\nkey, instead of silently discarding it. The two nested objects\ndo not accept the same field set: `device_scale_factor` is\n`defaults`-only (rejected per item), and `duration`/`scenario`\nare `items[]`-only (rejected under `defaults`). `metadata` is\nvalid both at the top level of the body and per item, but is\nrejected with this same 422 if placed under `defaults`. A\n`viewport` outside width 360 to 2544 or height 1 to 1297, under\n`defaults` or on an item, is a 422 `validation_error` too.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
26
26
  },
27
27
  "api/bulk/deletebulk": {
28
28
  "title": "Cancel a bulk job",
@@ -34,6 +34,11 @@
34
34
  "section": "API Reference",
35
35
  "body": "# Get bulk job status\n\nReturns the job envelope. Items are listed by `GET /v1/bulk/{id}/screenshots`.\n\n**Cancelled by the platform.** When the account can no longer spend (its bandwidth\nbalance is exhausted, or the account is deleted) while items are still pending, ByteKit\ncancels the job itself. It then reads `status: cancelled` even though you never called\n`DELETE /v1/bulk/{id}`, and the cancellation sends no webhook.\n\n**Job ids from other create routes.** The job is looked up by account only, so the id\nof a job created by `POST /v1/scrape/bulk` or `POST /v1/fetch/bulk` is found here too, not\na `404`, with that job's envelope. An id from another account answers `404`.\n\n**GET** `/v1/bulk/{id}`\n\n## Parameters\n\n- `id` (path, string, required)\n\n## Responses\n\n### 200 — Successful response.\n- `id`\n- `status`\n- `total`\n- `completed`\n- `failed`\n- `created_at`\n- `completed_at`\n- `total_credits_charged`\n- `total_billed_bytes`\n- `estimated_credits`\n- `webhook_url`\n\n### 202 — Bulk job still processing. `routes/bulk.ts` ends the poll handler with\n`status: isTerminal ? 200 : 202` over an identical body, so this is the\nSAME envelope the 200 documents — only the status code and the reachable\n`status` values differ. Keep polling until you get a 200 (issue #3533).\n- `id`\n- `status`\n- `total`\n- `completed`\n- `failed`\n- `created_at`\n- `completed_at`\n- `total_credits_charged`\n- `total_billed_bytes`\n- `estimated_credits`\n- `webhook_url`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 404 — Resource not found.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
36
36
  },
37
+ "api/bulk/getbulkconcurrency": {
38
+ "title": "Get bulk concurrency usage",
39
+ "section": "API Reference",
40
+ "body": "# Get bulk concurrency usage\n\nReturns how many of the account's bulk concurrency slots are in use and\nthe plan cap they count against, so a dashboard can tell a bulk job that\nis waiting on the cap from one that is stalled. `active` is a live\napproximation of dispatched bulk children: a slot whose release never\narrived drops out of the count after 5 minutes. It is for display only\nand never decides a job's state or progress, which come from the job's\nown counters, nor enforcement or billing. Authenticates with an API key\nor a dashboard session, like the other `/v1/bulk` operations.\n\n**GET** `/v1/bulk/concurrency`\n\n## Responses\n\n### 200 — Successful response.\n- `active`\n- `limit`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
41
+ },
37
42
  "api/bulk/listbulk": {
38
43
  "title": "List bulk jobs",
39
44
  "section": "API Reference",
@@ -67,12 +72,12 @@
67
72
  "api/fetch/getfetch": {
68
73
  "title": "Fetch a URL (GET)",
69
74
  "section": "API Reference",
70
- "body": "# Fetch a URL (GET)\n\nDirect HTTP fetch. Metadata is returned in X-Fetch-* headers. What the body holds\ndepends on `X-Fetch-Fast-Path`. When it is `true`, a successful response returns the\nupstream response bytes verbatim. When it is `false` the request fell back to a browser\nrender, and the body is the rendered page rather than the bytes the target sent;\n`X-Fetch-Content-Length` is then the compressed size of that page. Non-2xx upstream\nresponses use the `upstream_error` JSON envelope with the upstream HTTP status.\n\n**GET** `/v1/fetch`\n\n## Parameters\n\n- `url` (query, string, required)\n- `country` (query, string) — Two-letter country code. Either case is accepted; the value is upper-cased.\n- `timeout_ms` (query, integer)\n- `cache_ttl` (query) — How long a freshly fetched URL may be served from cache. `0` skips the cache read; cache-eligible fresh results are still written with the default 7-day TTL so later non-zero-TTL callers can HIT. Safety-classified WAF husks remain live-only and are not written. Accepts `Nh` (hours, up to 168h), `Nd` (days, up to 7d), or the integer `0`. Examples: `0`, `48h`, `2d`. Invalid values receive a 422 validation_error with an actionable message.\n- `custom` (query, string) — A JSON-encoded object, URL-encoded in the query string. It is echoed back base64-encoded in\nthe `X-Fetch-Custom` response header so callers can correlate the response to caller-side\nstate. Capped at 4096 UTF-8 bytes after JSON serialization, and not part of the cache key.\nA value that is not valid JSON answers `422 validation_error` (\"custom must be a\nJSON-encoded object\"); valid JSON that is not an object is also rejected with `422`.\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. slow-path-only field), or a fetch that failed for a\ntarget-side reason.\n\nTwo distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
75
+ "body": "# Fetch a URL (GET)\n\nDirect HTTP fetch. Metadata is returned in X-Fetch-* headers. What the body holds\ndepends on `X-Fetch-Fast-Path`. When it is `true`, a successful response returns the\nupstream response bytes verbatim. When it is `false` the request fell back to a browser\nrender, and the body is the rendered page rather than the bytes the target sent;\n`X-Fetch-Content-Length` is then the compressed size of that page. Non-2xx upstream\nresponses use the `upstream_error` JSON envelope with the upstream HTTP status.\n\n**GET** `/v1/fetch`\n\n## Parameters\n\n- `url` (query, string, required)\n- `country` (query, string) — Two-letter country code. Either case is accepted; the value is upper-cased.\n- `timeout_ms` (query, integer)\n- `cache_ttl` (query) — How long a freshly fetched URL may be served from cache. `0` skips the cache read; cache-eligible fresh results are still written with the default 7-day TTL so later non-zero-TTL callers can HIT. Safety-classified WAF husks remain live-only and are not written. Accepts `Nh` (hours, up to 168h), `Nd` (days, up to 7d), or the integer `0`. Examples: `0`, `48h`, `2d`. Invalid values receive a 422 validation_error with an actionable message.\n- `custom` (query, string) — A JSON-encoded object, URL-encoded in the query string. It is echoed back base64-encoded in\nthe `X-Fetch-Custom` response header so callers can correlate the response to caller-side\nstate. Capped at 4096 UTF-8 bytes after JSON serialization, and not part of the cache key.\nA value that is not valid JSON answers `422 validation_error` (\"custom must be a\nJSON-encoded object\"); valid JSON that is not an object is also rejected with `422`.\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. slow-path-only field), or a fetch that failed for a\ntarget-side reason.\n\nThree distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- **`timeout`** — the fetch ran out of its time limit before the page could be\n fetched (message `The request hit its time limit before the page could be\n fetched.`). It takes precedence over `blocked` and `upstream_error`, and like\n them it is charged nothing and reports `error.http_status` `422`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
71
76
  },
72
77
  "api/fetch/postfetch": {
73
78
  "title": "Fetch a URL (POST)",
74
79
  "section": "API Reference",
75
- "body": "# Fetch a URL (POST)\n\nSame as GET /v1/fetch but with a JSON request body. The response is the same, including\nthe `X-Fetch-Fast-Path` rule for what the body holds: the upstream bytes verbatim when\nit is `true`, the rendered page when it is `false`.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/fetch`\n\n## Request Body\n\n- `url` (required)\n- `country`\n- `timeout_ms`\n- `cache_ttl`\n- `custom`\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request body.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. malformed JSON, unsupported fetch format, or slow-path-only\nfield), or a fetch that failed for a target-side reason.\n\nTwo distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
80
+ "body": "# Fetch a URL (POST)\n\nSame as GET /v1/fetch but with a JSON request body. The response is the same, including\nthe `X-Fetch-Fast-Path` rule for what the body holds: the upstream bytes verbatim when\nit is `true`, the rendered page when it is `false`.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/fetch`\n\n## Request Body\n\n- `url` (required)\n- `country`\n- `timeout_ms`\n- `cache_ttl`\n- `custom`\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request body.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. malformed JSON, unsupported fetch format, or slow-path-only\nfield), or a fetch that failed for a target-side reason.\n\nThree distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- **`timeout`** — the fetch ran out of its time limit before the page could be\n fetched (message `The request hit its time limit before the page could be\n fetched.`). It takes precedence over `blocked` and `upstream_error`, and like\n them it is charged nothing and reports `error.http_status` `422`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
76
81
  },
77
82
  "api/health": {
78
83
  "title": "Health",
@@ -92,7 +97,7 @@
92
97
  "api/monitors/createmonitor": {
93
98
  "title": "Create a change-detection monitor",
94
99
  "section": "API Reference",
95
- "body": "# Create a change-detection monitor\n\nCreates a recurring change-detection monitor for a URL, delivering results via webhook.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/monitors`\n\n## Request Body\n\n- `url` (required)\n- `type`\n- `interval_type` (required)\n- `cron_expression`\n- `change_threshold`\n- `notify_on`\n- `webhook_url` (required)\n- `webhook_secret`\n- `webhook_headers`\n- `options`\n- `scrape_options`\n- `metadata`\n\n## Responses\n\n### 201 — Monitor created.\n- `id`\n- `type`\n- `url`\n- `status`\n- `interval_type`\n- `cron_expression`\n- `next_capture_at`\n- `notify_on`\n- `webhook_url`\n- `webhook_headers`\n- `change_threshold`\n- `scrape_options`\n- `last_content_hash`\n- `captures_count`\n- `changes_count`\n- `skipped_captures`\n- `last_captured_at`\n- `last_changed_at`\n- `consecutive_failures`\n- `last_error_code`\n- `suspension_reason`\n- `metadata`\n- `created_at`\n- `updated_at`\n- `cancelled_at`\n- `webhook_secret`\n\n### 400 — Bad request. When the `url` (or `webhook_url`) field fails strict\nvalidation the error code is `invalid_url` and the `details` object\ncontains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 409 — Duplicate monitor for this URL.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
100
+ "body": "# Create a change-detection monitor\n\nCreates a recurring change-detection monitor for a URL, delivering results via webhook.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/monitors`\n\n## Request Body\n\n- `url` (required)\n- `type`\n- `interval_type` (required)\n- `cron_expression`\n- `change_threshold`\n- `notify_on`\n- `webhook_url` (required)\n- `webhook_secret`\n- `webhook_headers`\n- `options`\n- `scrape_options`\n- `metadata`\n\n## Responses\n\n### 201 — Monitor created.\n- `id`\n- `type`\n- `url`\n- `status`\n- `interval_type`\n- `cron_expression`\n- `next_capture_at`\n- `notify_on`\n- `webhook_url`\n- `webhook_headers`\n- `change_threshold`\n- `scrape_options`\n- `last_content_hash`\n- `captures_count`\n- `changes_count`\n- `skipped_captures`\n- `last_captured_at`\n- `last_changed_at`\n- `consecutive_failures`\n- `last_error_code`\n- `suspension_reason`\n- `metadata`\n- `created_at`\n- `updated_at`\n- `cancelled_at`\n- `webhook_secret`\n\n### 400 — Bad request. When the `url` (or `webhook_url`) field fails strict\nvalidation the error code is `invalid_url` and the `details` object\ncontains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 409 — Duplicate monitor for this URL.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 415 — `unsupported_content_type`: a `scrape` monitor whose `url` path ends in `.pdf` is refused\nbefore it is stored. The check is on the URL only: the path, lowercased, ends in `.pdf`;\nthe query string and fragment are not looked at. A PDF served from another path, or reached\nthrough a redirect, is not caught here — its polls fail as `unsupported_content_type` and\ncount toward auto-suspension. A `screenshot` monitor is not affected.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
96
101
  },
97
102
  "api/monitors/deletemonitor": {
98
103
  "title": "Cancel monitor",
@@ -117,7 +122,7 @@
117
122
  "api/monitors/updatemonitor": {
118
123
  "title": "Update monitor",
119
124
  "section": "API Reference",
120
- "body": "# Update monitor\n\n**PATCH** `/v1/monitors/{id}`\n\n## Parameters\n\n- `id` (path, string, required)\n\n## Request Body\n\n- `url`\n- `interval_type`\n- `cron_expression`\n- `change_threshold`\n- `notify_on`\n- `webhook_url`\n- `webhook_secret`\n- `webhook_headers`\n- `status`\n- `options`\n- `scrape_options`\n- `metadata`\n\n## Responses\n\n### 200 — Successful response.\n- `id`\n- `type`\n- `url`\n- `status`\n- `interval_type`\n- `cron_expression`\n- `next_capture_at`\n- `notify_on`\n- `webhook_url`\n- `webhook_headers`\n- `change_threshold`\n- `scrape_options`\n- `last_content_hash`\n- `captures_count`\n- `changes_count`\n- `skipped_captures`\n- `last_captured_at`\n- `last_changed_at`\n- `consecutive_failures`\n- `last_error_code`\n- `suspension_reason`\n- `metadata`\n- `created_at`\n- `updated_at`\n- `cancelled_at`\n\n### 400 — Bad request. When the `url` (or `webhook_url`) field fails strict\nvalidation the error code is `invalid_url` and the `details` object\ncontains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 404 — Resource not found.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 409 — Duplicate URL.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
125
+ "body": "# Update monitor\n\n**PATCH** `/v1/monitors/{id}`\n\n## Parameters\n\n- `id` (path, string, required)\n\n## Request Body\n\n- `url`\n- `interval_type`\n- `cron_expression`\n- `change_threshold`\n- `notify_on`\n- `webhook_url`\n- `webhook_secret`\n- `webhook_headers`\n- `status`\n- `options`\n- `scrape_options`\n- `metadata`\n\n## Responses\n\n### 200 — Successful response.\n- `id`\n- `type`\n- `url`\n- `status`\n- `interval_type`\n- `cron_expression`\n- `next_capture_at`\n- `notify_on`\n- `webhook_url`\n- `webhook_headers`\n- `change_threshold`\n- `scrape_options`\n- `last_content_hash`\n- `captures_count`\n- `changes_count`\n- `skipped_captures`\n- `last_captured_at`\n- `last_changed_at`\n- `consecutive_failures`\n- `last_error_code`\n- `suspension_reason`\n- `metadata`\n- `created_at`\n- `updated_at`\n- `cancelled_at`\n\n### 400 — Bad request. When the `url` (or `webhook_url`) field fails strict\nvalidation the error code is `invalid_url` and the `details` object\ncontains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 404 — Resource not found.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 409 — Duplicate URL.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 415 — `unsupported_content_type`: a `scrape` monitor whose `url` path ends in `.pdf` is refused\nbefore it is stored. The check is on the URL only: the path, lowercased, ends in `.pdf`;\nthe query string and fragment are not looked at. A PDF served from another path, or reached\nthrough a redirect, is not caught here — its polls fail as `unsupported_content_type` and\ncount toward auto-suspension. A `screenshot` monitor is not affected.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
121
126
  },
122
127
  "api/plans": {
123
128
  "title": "Plans",
@@ -152,7 +157,7 @@
152
157
  "api/scrape-bulk/createscrapebulk": {
153
158
  "title": "Bulk scrape URLs",
154
159
  "section": "API Reference",
155
- "body": "# Bulk scrape URLs\n\nEnqueues multiple URLs for scraping. Results delivered via webhook.\nCompletion deliveries use `X-ByteKit-Event: bulk.completed` and the\n`BulkCompletedWebhook` contract: at most 500 complete items and 1 MiB,\nfollowed by cursor recovery through `GET /v1/scrape/bulk/{id}` whenever\n`recovery_required` is true.\n\n**Unknown keys.** An unknown key on an `items[]` entry, or at the top level of\nthe body, is rejected with `422 validation_error`. An unknown key inside\n`defaults` is not: it is dropped without a warning and the request is accepted\nwith `202`. The exception is `cookies` and `headers`, on an item or in `defaults`: they\nanswer `400 validation_error`.\n\n**POST** `/v1/scrape/bulk`\n\n## Request Body\n\n- `urls`\n- `items`\n- `items.url`\n- `items.formats`\n- `items.formats.type`\n- `items.formats.schema`\n- `items.formats.model`\n- `items.formats.prompt`\n- `items.country`\n- `items.delay_ms`\n- `items.timeout_ms`\n- `items.metadata`\n- `items.clean_markdown`\n- `items.custom`\n- `defaults`\n- `defaults.formats`\n- `defaults.formats.type`\n- `defaults.formats.schema`\n- `defaults.formats.model`\n- `defaults.formats.prompt`\n- `defaults.country`\n- `defaults.delay_ms`\n- `defaults.timeout_ms`\n- `defaults.clean_markdown`\n- `webhook_url` (required)\n- `webhook_secret`\n- `metadata`\n- `custom`\n\n## Responses\n\n### 202 — Bulk scrape job accepted.\n- `id`\n- `status`\n- `total`\n- `completed`\n- `failed`\n- `created_at`\n- `completed_at`\n- `total_credits_charged`\n- `total_billed_bytes`\n- `estimated_credits`\n- `webhook_url`\n\n### 400 — Bad request. When a `url` (or item URL) fails strict validation the\nerror code is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — One or more URLs in the request are on ByteKit's blocklist. The whole request is\nrejected before anything is queued or billed. This body is NOT the unified `Error`\nenvelope: it carries no `status`, `http_status` or `failed_at`. `blocked` lists every\noffending URL with the rule that matched (`domain`, `tld`, `port` or `path`) and the\ncode that rule maps to (`host_forbidden` for the first three, `path_forbidden` for\n`path`).\n- `error`\n- `error.code`\n- `error.message`\n- `blocked`\n- `blocked.url`\n- `blocked.rule_type`\n- `blocked.error_code`\n\n### 422 — Validation error. `bulk_too_large` is returned when the item count\nexceeds the account plan's `max_bulk_size` cap (also surfaced as\n`max_bulk_size` on `GET /v1/account`).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
160
+ "body": "# Bulk scrape URLs\n\nEnqueues multiple URLs for scraping. Results delivered via webhook.\nCompletion deliveries use `X-ByteKit-Event: bulk.completed` and the\n`BulkCompletedWebhook` contract: at most 500 complete items and 1 MiB,\nfollowed by cursor recovery through `GET /v1/scrape/bulk/{id}` whenever\n`recovery_required` is true.\n\n**Unknown keys.** An unknown key on an `items[]` entry, or at the top level of\nthe body, is rejected with `422 validation_error`. An unknown key inside\n`defaults` is not: it is dropped without a warning and the request is accepted\nwith `202`. The exception is `cookies` and `headers`, on an item or in `defaults`: they\nanswer `400 validation_error`.\n\n**POST** `/v1/scrape/bulk`\n\n## Request Body\n\n- `urls`\n- `items`\n- `items.url`\n- `items.formats`\n- `items.formats.type`\n- `items.formats.schema`\n- `items.formats.model`\n- `items.formats.prompt`\n- `items.country`\n- `items.delay_ms`\n- `items.timeout_ms`\n- `items.metadata`\n- `items.clean_markdown`\n- `items.custom`\n- `defaults`\n- `defaults.formats`\n- `defaults.formats.type`\n- `defaults.formats.schema`\n- `defaults.formats.model`\n- `defaults.formats.prompt`\n- `defaults.country`\n- `defaults.delay_ms`\n- `defaults.timeout_ms`\n- `defaults.clean_markdown`\n- `webhook_url` (required)\n- `webhook_secret`\n- `metadata`\n- `custom`\n\n## Responses\n\n### 202 — Bulk scrape job accepted.\n- `id`\n- `status`\n- `total`\n- `completed`\n- `failed`\n- `created_at`\n- `completed_at`\n- `total_credits_charged`\n- `total_billed_bytes`\n- `estimated_credits`\n- `webhook_url`\n- `rejected`\n- `rejected.index`\n- `rejected.url`\n- `rejected.code`\n- `rejected.message`\n\n### 400 — Bad request. When a `url` (or item URL) fails strict validation the\nerror code is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — One or more URLs in the request are on ByteKit's blocklist. The whole request is\nrejected before anything is queued or billed. This body is NOT the unified `Error`\nenvelope: it carries no `status`, `http_status` or `failed_at`. `blocked` lists every\noffending URL with the rule that matched (`domain`, `tld`, `port` or `path`) and the\ncode that rule maps to (`host_forbidden` for the first three, `path_forbidden` for\n`path`).\n- `error`\n- `error.code`\n- `error.message`\n- `blocked`\n- `blocked.url`\n- `blocked.rule_type`\n- `blocked.error_code`\n\n### 415 — `unsupported_content_type`: every item in the batch was refused because its URL path ends in\n`.pdf` (the path, lowercased; the query string and fragment are not looked at). Nothing is\nqueued or billed. `details.rejected` lists each item as `{ index, url, code, message }`.\nWhen only some items are refused the batch is accepted with `202` and those items are\nlisted in `rejected` instead.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error. `bulk_too_large` is returned when the count of\naccepted items exceeds the account plan's `max_bulk_size` cap (also\nsurfaced as `max_bulk_size` on `GET /v1/account`). Items refused\nfor a `.pdf` path are listed in `rejected` and do not count.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
156
161
  },
157
162
  "api/scrape-bulk/getscrapebulk": {
158
163
  "title": "Get scrape bulk job status",
@@ -162,7 +167,7 @@
162
167
  "api/scrape/createscrape": {
163
168
  "title": "Scrape a URL",
164
169
  "section": "API Reference",
165
- "body": "# Scrape a URL\n\nFetches and processes a URL, returning content in one or more formats wrapped in a ScrapeEnvelope.\n\n**The response shape is decided by your request, not by how we route it.** In precedence order:\n\n1. `async: true` in the body, or `?async=true` in the query string (either one is enough; `false` in one never cancels `true` in the other) → **202** with a `ScrapeQueuedEnvelope` receipt, returned immediately. Poll `GET /v1/scrape/{id}` for the result.\n2. Otherwise, a request that needs a full page render — today that is any of `delay_ms > 0`, `solve_challenge: true`, or `outline` in `formats` — is **held open** until the render reaches a terminal state, then returns **200** with the content envelope (`success` or `failed`). If the render is still running when the hold window expires (28 seconds by default), the request returns the **202** receipt instead and the job continues in the background. A `solve_challenge` render can outlast the hold window, so expect the 202 receipt from such a request.\n3. Otherwise the request is served by the fast HTTP path and returns **200** with the content envelope, typically in under a second.\n\n**A failed fetch is a result, not a transport error.** An unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all come back on the same **200** as a `failed` envelope — never a 5xx. Narrow on the envelope's `status` before reading the body. A failure the fast path decides inline is recorded as a failed job, so its envelope normally carries that job's `id` and `GET /v1/scrape/{id}` returns the same envelope; if recording the failed job itself fails, the envelope still arrives on the same 200 with `id` set to `null` and there is nothing to poll. A failure a held render reaches carries that render's real `id`. Either way the request transfers no billable bytes and is charged nothing.\n\n**A target that rate-limits us is not ByteKit rate-limiting you.** The `failed` envelope's `error.code` is `target_rate_limited` when the target rate-limits the request. On the fast path that means our proxy attempts end on an HTTP 429 and no bot protection is identified on any attempt, even if the browser fallback then fails or reaches only an unidentified block page; the inline failure carries `error.retry_after_seconds` when the target sent a usable `Retry-After`. On a held render the browser's own answer decides: it observes a 429 on the page itself, or it fails outright after the proxy attempts ended on an HTTP 429. A bot-protection verdict on an earlier fetch attempt does not keep a held render `blocked` when the browser then observes the 429. A held render never carries `error.retry_after_seconds`. Retrying a `target_rate_limited` failure later is likely to work. A held render whose browser reaches an unidentified 403 or 503 page after a proxy 429 is `blocked`. A 429 that bot protection sends as a block stays `blocked` when it is the answer that decides the code: the fast path's proxy attempts, or the browser render on a held render. Your own per-key limit is a separate case: it answers HTTP 429 `rate_limited` with a `Retry-After` header (see the `429` response).\n\nSo a 202 means one of exactly two things: you asked for one with `async: true` or `?async=true`, or the hold window expired. `wait_for_selector` and `wait_until` are `ScreenshotRequest` options, not `ScrapeRequest` options — sending either to this endpoint returns `422 validation_error`, so neither can produce a 202 here.\n\n**POST** `/v1/scrape`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 receipt immediately; any other value is ignored. Either spelling turns async on, and `false` in one never cancels `true` in the other.\n\n## Request Body\n\n- `url` (required)\n- `formats`\n- `formats.type`\n- `formats.schema`\n- `formats.model`\n- `formats.prompt`\n- `country`\n- `delay_ms`\n- `timeout_ms`\n- `async`\n- `webhook_url`\n- `events`\n- `markdown_mode`\n- `markdown_query`\n- `markdown_links`\n- `markdown_images`\n- `with_links_summary`\n- `with_images_summary`\n- `markdown_compact`\n- `markdown_filter_images`\n- `markdown_include_media`\n- `markdown_include_warnings`\n- `markdown_include_stats`\n- `token_budget`\n- `token_encoding`\n- `mobile`\n- `solve_challenge`\n- `remove_base64_images`\n- `include_tags`\n- `exclude_tags`\n- `cache_ttl`\n- `custom`\n- `clean_markdown`\n\n## Responses\n\n### 200 — Scrape reached a terminal state and the body is that terminal envelope: `success` carrying content, or `failed` carrying the error envelope. Returned by the fast HTTP path in one round trip, and by a browser-path request without `async: true` or `?async=true` once its render reaches a terminal state inside the hold window. A held render that ends in failure answers 200 with the same `failed` envelope `GET /v1/scrape/{id}` returns — narrow on `status` before reading the body. A definitive upstream outcome is a result, not a transport error: an unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all answer 200 with the `failed` envelope, never a 5xx. An inline failure is recorded as a failed job, so its envelope normally carries that job's `id` and polling it returns the same envelope; `id` is `null` only when recording the failed job itself failed. `error.http_status` is present only when a real upstream HTTP status is known.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `final_url`\n- `content_type`\n- `content_length`\n- `status_code`\n- `retrieved_at`\n- `formats`\n- `formats.raw`\n- `formats.markdown`\n- `formats.links`\n- `formats.links.url`\n- `formats.links.text`\n- `formats.links.isInternal`\n- `formats.links.rel`\n- `formats.images`\n- `formats.images.url`\n- `formats.images.alt`\n- `formats.images.width`\n- `formats.images.height`\n- `formats.images.format`\n- `formats.images.score`\n- `formats.json`\n- `formats.json.data`\n- `formats.json.validated`\n- `formats.json.model`\n- `formats.outline`\n- `metadata`\n- `metadata.title`\n- `metadata.description`\n- `metadata.language`\n- `metadata.canonicalUrl`\n- `metadata.ogTitle`\n- `metadata.ogDescription`\n- `metadata.ogImage`\n- `metadata.ogUrl`\n- `metadata.ogSiteName`\n- `metadata.robots`\n- `metadata.byline`\n- `metadata.publishedAt`\n- `tables`\n- `tables.kind`\n- `tables.gfm`\n- `tables.rows`\n- `tables.cols`\n- `warnings`\n- `warnings.code`\n- `warnings.message`\n- `warnings.element`\n- `stats`\n- `stats.chars`\n- `stats.tokens`\n- `stats.blocks`\n- `markdown_tokens`\n- `markdown_tokens.kept`\n- `markdown_tokens.total`\n- `markdown_tokens.truncated`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `custom`\n- `cache`\n- `cache_age_s`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.retry_after_seconds`\n- `error.failed_at`\n\n### 202 — Scrape accepted for background processing; the body is a receipt, not content. Returned when `async: true` or `?async=true` was requested, or when a browser-path request's hold window expired before the render finished. Poll `GET /v1/scrape/{id}` for the result.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `status_url`\n- `queued_at`\n- `events`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error. A `json` format entry whose `schema` the extractor cannot take is\nrefused with `schema_incompatible`, before anything is drawn.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 500 — Internal server error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — The request carried a `json` format entry and JSON extraction is unavailable on this\ndeployment (`provider_unavailable`). It is refused before anything is drawn. A\nterminal upstream failure is never a `503`: it is a `200` result, described above.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
170
+ "body": "# Scrape a URL\n\nFetches and processes a URL, returning content in one or more formats wrapped in a ScrapeEnvelope.\n\n**The response shape is decided by your request, not by how we route it.** In precedence order:\n\n1. `async: true` in the body, or `?async=true` in the query string (either one is enough; `false` in one never cancels `true` in the other) → **202** with a `ScrapeQueuedEnvelope` receipt, returned immediately. Poll `GET /v1/scrape/{id}` for the result.\n2. Otherwise, a request that needs a full page render — today that is any of `delay_ms > 0`, `solve_challenge: true`, or `outline` in `formats` — is **held open** until the render reaches a terminal state, then returns **200** with the content envelope (`success` or `failed`). If the render is still running when the hold window expires (28 seconds by default), the request returns the **202** receipt instead and the job continues in the background. A `solve_challenge` render can outlast the hold window, so expect the 202 receipt from such a request.\n3. Otherwise the request is served by the fast HTTP path and returns **200** with the content envelope, typically in under a second.\n\n**A failed fetch is a result, not a transport error.** An unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all come back on the same **200** as a `failed` envelope — never a 5xx. Narrow on the envelope's `status` before reading the body. A failure the fast path decides inline is recorded as a failed job, so its envelope normally carries that job's `id` and `GET /v1/scrape/{id}` returns the same envelope; if recording the failed job itself fails, the envelope still arrives on the same 200 with `id` set to `null` and there is nothing to poll. A failure a held render reaches carries that render's real `id`. Either way the request transfers no billable bytes and is charged nothing.\n\n**A target that rate-limits us is not ByteKit rate-limiting you.** The `failed` envelope's `error.code` is `target_rate_limited` when the target rate-limits the request. On the fast path that means our proxy attempts end on an HTTP 429 and no bot protection is identified on any attempt, even if the browser fallback then fails or reaches only an unidentified block page; the inline failure carries `error.retry_after_seconds` when the target sent a usable `Retry-After`. On a held render the browser's own answer decides: it observes a 429 on the page itself, or it fails outright after the proxy attempts ended on an HTTP 429. A bot-protection verdict on an earlier fetch attempt does not keep a held render `blocked` when the browser then observes the 429. A held render never carries `error.retry_after_seconds`. Retrying a `target_rate_limited` failure later is likely to work. A held render whose browser reaches an unidentified 403 or 503 page after a proxy 429 is `blocked`. A 429 that bot protection sends as a block stays `blocked` when it is the answer that decides the code: the fast path's proxy attempts, or the browser render on a held render. Your own per-key limit is a separate case: it answers HTTP 429 `rate_limited` with a `Retry-After` header (see the `429` response).\n\nSo a 202 means one of exactly two things: you asked for one with `async: true` or `?async=true`, or the hold window expired. `wait_for_selector` and `wait_until` are `ScreenshotRequest` options, not `ScrapeRequest` options — sending either to this endpoint returns `422 validation_error`, so neither can produce a 202 here.\n\n**POST** `/v1/scrape`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 receipt immediately; any other value is ignored. Either spelling turns async on, and `false` in one never cancels `true` in the other.\n\n## Request Body\n\n- `url` (required)\n- `formats`\n- `formats.type`\n- `formats.schema`\n- `formats.model`\n- `formats.prompt`\n- `country`\n- `delay_ms`\n- `timeout_ms`\n- `async`\n- `webhook_url`\n- `events`\n- `markdown_mode`\n- `markdown_query`\n- `markdown_links`\n- `markdown_images`\n- `with_links_summary`\n- `with_images_summary`\n- `markdown_compact`\n- `markdown_filter_images`\n- `markdown_include_media`\n- `markdown_include_warnings`\n- `markdown_include_stats`\n- `token_budget`\n- `token_encoding`\n- `mobile`\n- `solve_challenge`\n- `remove_base64_images`\n- `include_tags`\n- `exclude_tags`\n- `cache_ttl`\n- `custom`\n- `clean_markdown`\n\n## Responses\n\n### 200 — Scrape reached a terminal state and the body is that terminal envelope: `success` carrying content, or `failed` carrying the error envelope. Returned by the fast HTTP path in one round trip, and by a browser-path request without `async: true` or `?async=true` once its render reaches a terminal state inside the hold window. A held render that ends in failure answers 200 with the same `failed` envelope `GET /v1/scrape/{id}` returns — narrow on `status` before reading the body. A definitive upstream outcome is a result, not a transport error: an unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all answer 200 with the `failed` envelope, never a 5xx. An inline failure is recorded as a failed job, so its envelope normally carries that job's `id` and polling it returns the same envelope; `id` is `null` only when recording the failed job itself failed. `error.http_status` is present only when a real upstream HTTP status is known.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `final_url`\n- `content_type`\n- `content_length`\n- `status_code`\n- `retrieved_at`\n- `formats`\n- `formats.raw`\n- `formats.markdown`\n- `formats.links`\n- `formats.links.url`\n- `formats.links.text`\n- `formats.links.isInternal`\n- `formats.links.rel`\n- `formats.images`\n- `formats.images.url`\n- `formats.images.alt`\n- `formats.images.width`\n- `formats.images.height`\n- `formats.images.format`\n- `formats.images.score`\n- `formats.json`\n- `formats.json.data`\n- `formats.json.validated`\n- `formats.json.model`\n- `formats.outline`\n- `metadata`\n- `metadata.title`\n- `metadata.description`\n- `metadata.language`\n- `metadata.canonicalUrl`\n- `metadata.ogTitle`\n- `metadata.ogDescription`\n- `metadata.ogImage`\n- `metadata.ogUrl`\n- `metadata.ogSiteName`\n- `metadata.robots`\n- `metadata.byline`\n- `metadata.publishedAt`\n- `tables`\n- `tables.kind`\n- `tables.gfm`\n- `tables.rows`\n- `tables.cols`\n- `warnings`\n- `warnings.code`\n- `warnings.message`\n- `warnings.element`\n- `stats`\n- `stats.chars`\n- `stats.tokens`\n- `stats.blocks`\n- `markdown_tokens`\n- `markdown_tokens.kept`\n- `markdown_tokens.total`\n- `markdown_tokens.truncated`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `custom`\n- `cache`\n- `cache_age_s`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.retry_after_seconds`\n- `error.failed_at`\n\n### 202 — Scrape accepted for background processing; the body is a receipt, not content. Returned when `async: true` or `?async=true` was requested, or when a browser-path request's hold window expired before the render finished. Poll `GET /v1/scrape/{id}` for the result.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `status_url`\n- `queued_at`\n- `events`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 415 — `unsupported_content_type`, in two cases:\n- The `url` path ends in `.pdf`: the path, lowercased, ends in `.pdf`; the query string and\n fragment are not looked at. It is refused before anything is drawn. A PDF served from\n another path, or reached through a redirect, is not caught by this check.\n- The page was fetched (or served from cache) and its content type cannot produce the\n requested formats. The charge is refunded.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error. A `json` format entry whose `schema` the extractor cannot take is\nrefused with `schema_incompatible`, before anything is drawn.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 500 — Internal server error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — The request carried a `json` format entry and JSON extraction is unavailable on this\ndeployment (`provider_unavailable`). It is refused before anything is drawn. A\nterminal upstream failure is never a `503`: it is a `200` result, described above.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
166
171
  },
167
172
  "api/scrape/getscrape": {
168
173
  "title": "Get scrape result",
@@ -177,7 +182,7 @@
177
182
  "api/screenshots/createscreenshot": {
178
183
  "title": "Capture a screenshot",
179
184
  "section": "API Reference",
180
- "body": "# Capture a screenshot\n\nSync by default (holds up to 28s). Pass `async: true` in the body or `?async=true` in the\nquery string to return 202 immediately; either one is enough, and `false` in one never\ncancels `true` in the other.\nPoll via GET /v1/screenshots/{id}.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/screenshots`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 immediately; any other value is ignored.\n\n## Request Body\n\n- `url` (required)\n- `device`\n- `viewport`\n- `viewport.width`\n- `viewport.height`\n- `async`\n- `full_page`\n- `format`\n- `quality`\n- `block_ads`\n- `block_cookie_banners`\n- `wait_until`\n- `wait_for_selector`\n- `delay_ms`\n- `scroll`\n- `clip`\n- `clip.x`\n- `clip.y`\n- `clip.width`\n- `clip.height`\n- `dark_mode`\n- `device_scale_factor`\n- `include_html`\n- `country`\n- `language`\n- `metadata`\n\n## Responses\n\n### 200 — Screenshot completed (sync mode).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 202 — Screenshot accepted (async mode or sync timeout).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target is on ByteKit's blocklist. Nothing is captured and nothing is billed.\nThe unified `Error` envelope carries one of two codes:\n\n- `host_forbidden` — a blocked domain, any `.gov` host, or a blocked port.\n `details` is `{ host }`.\n- `path_forbidden` — an authentication-style path such as a login page.\n `details` is `{ path }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error, or a screenshot that failed inside the sync hold.\nThe two carry DIFFERENT bodies (issue #2679):\n\n- A request-validation failure returns the unified `Error` envelope\n with code `validation_error`.\n- A capture that reached a terminal `failed` state inside the sync\n hold returns the full `ScreenshotResponse` resource, whose\n `error_code`/`error_message` carry the real failure (`blocked`,\n `timeout`, …). This is the canonical shape for that case: the\n resource body is what carries the `ss_` handle, `poll_url` and\n `expires_at` a client needs to redeem the failed capture, none of\n which fit the `Error` envelope.\n\nDiscriminate on the shape of the top-level `error` key. The envelope\nform carries `error` as an OBJECT (`{ code, message, http_status,\nfailed_at }`); the resource form has no `error` key at all, and\ncarries the flat `error_code`/`error_message` pair plus `id` instead.\n\nDo NOT discriminate on `status`. Both forms carry\n`\"status\": \"failed\"` on this response — `Error.status` is a required\nproperty with `enum: [failed]` — so it separates nothing here.\n\n`X-Screenshot-ID` accompanies the resource form only: a\nrequest-validation failure is raised before a screenshot row exists,\nso no screenshot headers travel with it.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n- `id`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
185
+ "body": "# Capture a screenshot\n\nSync by default (holds up to 28s). Pass `async: true` in the body or `?async=true` in the\nquery string to return 202 immediately; either one is enough, and `false` in one never\ncancels `true` in the other.\nPoll via GET /v1/screenshots/{id}.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/screenshots`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 immediately; any other value is ignored.\n\n## Request Body\n\n- `url` (required)\n- `device`\n- `viewport`\n- `viewport.width`\n- `viewport.height`\n- `async`\n- `full_page`\n- `format`\n- `quality`\n- `block_ads`\n- `block_cookie_banners`\n- `wait_until`\n- `wait_for_selector`\n- `delay_ms`\n- `scroll`\n- `clip`\n- `clip.x`\n- `clip.y`\n- `clip.width`\n- `clip.height`\n- `dark_mode`\n- `device_scale_factor`\n- `include_html`\n- `country`\n- `language`\n- `metadata`\n\n## Responses\n\n### 200 — Screenshot completed (sync mode).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 202 — Screenshot accepted (async mode or sync timeout).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target is on ByteKit's blocklist. Nothing is captured and nothing is billed.\nThe unified `Error` envelope carries one of two codes:\n\n- `host_forbidden` — a blocked domain, any `.gov` host, or a blocked port.\n `details` is `{ host }`.\n- `path_forbidden` — an authentication-style path such as a login page.\n `details` is `{ path }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error, or a screenshot that failed inside the sync hold.\nThe two carry DIFFERENT bodies (issue #2679):\n\n- A request-validation failure returns the unified `Error` envelope\n with code `validation_error`. A `viewport` outside the `Viewport`\n bounds (width 360 to 2544, height 1 to 1297) is one.\n- A capture that reached a terminal `failed` state inside the sync\n hold returns the full `ScreenshotResponse` resource, whose\n `error_code`/`error_message` carry the real failure (`blocked`,\n `timeout`, …). This is the canonical shape for that case: the\n resource body is what carries the `ss_` handle, `poll_url` and\n `expires_at` a client needs to redeem the failed capture, none of\n which fit the `Error` envelope.\n\nDiscriminate on the shape of the top-level `error` key. The envelope\nform carries `error` as an OBJECT (`{ code, message, http_status,\nfailed_at }`); the resource form has no `error` key at all, and\ncarries the flat `error_code`/`error_message` pair plus `id` instead.\n\nDo NOT discriminate on `status`. Both forms carry\n`\"status\": \"failed\"` on this response — `Error.status` is a required\nproperty with `enum: [failed]` — so it separates nothing here.\n\n`X-Screenshot-ID` accompanies the resource form only: a\nrequest-validation failure is raised before a screenshot row exists,\nso no screenshot headers travel with it.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n- `id`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
181
186
  },
182
187
  "api/screenshots/getscreenshot": {
183
188
  "title": "Get screenshot status",
@@ -302,12 +307,12 @@
302
307
  "cli/scrape": {
303
308
  "title": "Scrape",
304
309
  "section": "CLI Reference",
305
- "body": "# Scrape\n\nScrape URL content\n\nScrape URL content\n\n### scrape › bulk\n\nBulk scrape operations\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n#### scrape › bulk › create\n\nCreate a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `--file <path>` | Path to a newline-delimited file. Each line is a plain URL, or a JSON object carrying \"url\" plus per-item config. A line whose only key is \"url\" behaves exactly as before (sent as a bare URL string); any line with additional keys switches the payload to the per-item shape. |\n| `--webhook-url <url>` | HTTPS webhook URL notified when the job completes |\n| `--webhook-secret <secret>` | HMAC secret used to sign the completion webhook (omitted → unsigned) |\n| `--defaults <json>` | Defaults applied to every entry, as a JSON object (omitted → none). Unknown keys are rejected by /v1/bulk (422) and ignored by scrape bulk / fetch bulk; fetch bulk additionally rejects browser-only keys (wait_until, wait_for_selector, delay_ms) with a 400. `cookies` and `headers` are no longer accepted by any capture endpoint and 400 (#3242). |\n| `--metadata <json>` | Arbitrary metadata echoed on the job envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--custom <json>` | User payload echoed on every scrape entry, as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none; a per-entry value in --file wins) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk create --file <path> --webhook-url <url> --webhook-secret <secret> --defaults <json> --metadata <json> --custom <json>\n```\n\n#### scrape › bulk › get\n\nGet a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `--cursor <cursor>` | Continue from a cursor returned by the preceding page |\n| `--limit <n>` | Maximum items to return (1-500) |\n| `--status <status>` | Filter items by status: pending, processing, completed, failed, cancelled |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk get <id> --cursor <cursor> --limit <n> --status <status>\n```\n\n### scrape › create\n\nCreate a scrape job\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to scrape |\n| `--format <format>` | Output format; repeat or comma-separate for multiple (e.g. --format raw --format markdown, or --format raw,markdown). Sent as the formats array; omitted → server default. |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--markdown-mode <mode>` | Markdown extraction mode: article, raw, llm |\n| `--markdown-query <q>` | BM25 query string for relevance-ranked markdown filtering (omitted → disabled) |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--events <csv>` | Webhook events (comma-separated): queued, completed, failed (omitted → server default) |\n| `--token-encoding <enc>` | Tokenizer for --token-budget: cl100k_base, o200k_base (omitted → server default) |\n| `--custom <json>` | User payload echoed on the envelope as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none) |\n| `--remove-base64-images` | Strip base64 data: images before conversion (server default) |\n| `--no-remove-base64-images` | Preserve base64 data: images in the pipeline output |\n| `--markdown-links <mode>` | Link rendering: inline, references, none, text |\n| `--markdown-images <mode>` | Image retention: inline, references, none, text |\n| `--with-links-summary` | Append a Links footer to the markdown output |\n| `--with-images-summary` | Append an Images footer to the markdown output |\n| `--markdown-compact` | Collapse excessive whitespace in the markdown output |\n| `--markdown-filter-images` | Filter low-signal images from the markdown output |\n| `--markdown-include-media` | Return rich link/image objects and a tables array |\n| `--markdown-include-warnings` | Include markdown-pipeline and tag-filter warnings |\n| `--markdown-include-stats` | Include a top-level stats object (chars, tokens, blocks) |\n| `--async` | Queue the scrape and return a job envelope immediately (no wait) |\n| `--webhook-url <url>` | HTTPS webhook URL notified when an async scrape completes |\n| `--token-budget <n>` | Maximum tokens of markdown to return |\n| `--clean-markdown` | Post-process markdown with the LLM cleaner (billed 3x) |\n| `--include-tags <csv>` | Comma-separated HTML tags to keep (e.g. article,main) |\n| `--exclude-tags <csv>` | Comma-separated HTML tags to drop (e.g. nav,footer) |\n| `--mobile` | Render with a mobile viewport/user-agent |\n| `--solve-challenge` | Attempt to clear a Cloudflare challenge; success is not guaranteed. Billed as a normal browser render. |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape create --url <url> --format <format> --country <cc> --timeout-ms <n> --markdown-mode <mode> --markdown-query <q> --cache-ttl <ttl> --delay-ms <n> --events <csv> --token-encoding <enc> --custom <json> --remove-base64-images --no-remove-base64-images --markdown-links <mode> --markdown-images <mode> --with-links-summary --with-images-summary --markdown-compact --markdown-filter-images --markdown-include-media --markdown-include-warnings --markdown-include-stats --async --webhook-url <url> --token-budget <n> --clean-markdown --include-tags <csv> --exclude-tags <csv> --mobile --solve-challenge --raw\n```\n\n### scrape › get\n\nGet a scrape job by ID (use --raw/-o/--format to retrieve a completed body)\n\n| Option | Description |\n| --- | --- |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `--format <format>` | Which persisted format to emit — only takes effect with --raw/-o; ignored otherwise |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape get <id> --raw --format <format>\n```"
310
+ "body": "# Scrape\n\nScrape URL content\n\nScrape URL content\n\n### scrape › bulk\n\nBulk scrape operations\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n#### scrape › bulk › create\n\nCreate a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `--file <path>` | Path to a newline-delimited file. Each line is a plain URL, or a JSON object carrying \"url\" plus per-item config. A line whose only key is \"url\" behaves exactly as before (sent as a bare URL string); any line with additional keys switches the payload to the per-item shape. |\n| `--webhook-url <url>` | HTTPS webhook URL notified when the job completes |\n| `--webhook-secret <secret>` | HMAC secret used to sign the completion webhook (omitted → unsigned) |\n| `--defaults <json>` | Defaults applied to every entry, as a JSON object (omitted → none). Unknown keys are rejected by /v1/bulk (422) and ignored by scrape bulk / fetch bulk; fetch bulk additionally rejects browser-only keys (wait_until, wait_for_selector, delay_ms) with a 400. `cookies` and `headers` are no longer accepted by any capture endpoint and 400 (#3242). |\n| `--metadata <json>` | Arbitrary metadata echoed on the job envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--custom <json>` | User payload echoed on every scrape entry, as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none; a per-entry value in --file wins) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk create --file <path> --webhook-url <url> --webhook-secret <secret> --defaults <json> --metadata <json> --custom <json>\n```\n\n#### scrape › bulk › get\n\nGet a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `--cursor <cursor>` | Continue from a cursor returned by the preceding page |\n| `--limit <n>` | Maximum items to return (1-500) |\n| `--status <status>` | Filter items by status: pending, processing, completed, failed, cancelled |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk get <id> --cursor <cursor> --limit <n> --status <status>\n```\n\n### scrape › create\n\nCreate a scrape job\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to scrape |\n| `--format <format>` | Output format; repeat or comma-separate for multiple (e.g. --format raw --format markdown, or --format raw,markdown). Sent as the formats array; omitted → server default. |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--markdown-mode <mode>` | Markdown extraction mode: article, raw, llm |\n| `--markdown-query <q>` | BM25 query string for relevance-ranked markdown filtering (omitted → disabled) |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--events <csv>` | Webhook events (comma-separated): queued, completed, failed (omitted → server default) |\n| `--token-encoding <enc>` | Tokenizer for --token-budget: cl100k_base, o200k_base (omitted → server default) |\n| `--custom <json>` | User payload echoed on the envelope as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none) |\n| `--remove-base64-images` | Strip base64 data: images before conversion (server default) |\n| `--no-remove-base64-images` | Preserve base64 data: images in the pipeline output |\n| `--markdown-links <mode>` | Link rendering: inline, references, none, text |\n| `--markdown-images <mode>` | Image retention: inline, references, none, text |\n| `--with-links-summary` | Append a Links footer to the markdown output |\n| `--with-images-summary` | Append an Images footer to the markdown output |\n| `--markdown-compact` | Collapse excessive whitespace in the markdown output |\n| `--markdown-filter-images` | Filter low-signal images from the markdown output |\n| `--markdown-include-media` | Return rich link/image objects and a tables array |\n| `--markdown-include-warnings` | Include markdown-pipeline and tag-filter warnings |\n| `--markdown-include-stats` | Include a top-level stats object (chars, tokens, blocks) |\n| `--async` | Queue the scrape and return a job envelope immediately (no wait) |\n| `--webhook-url <url>` | HTTPS webhook URL notified when an async scrape completes |\n| `--token-budget <n>` | Maximum tokens of markdown to return |\n| `--clean-markdown` | Post-process markdown with the LLM cleaner (billed 3x) |\n| `--include-tags <csv>` | Comma-separated HTML tags to keep (e.g. article,main) |\n| `--exclude-tags <csv>` | Comma-separated HTML tags to drop (e.g. nav,footer) |\n| `--mobile` | Ask for the mobile page (a browser render uses a phone-sized window with a desktop Windows identity) |\n| `--solve-challenge` | Attempt to clear a Cloudflare challenge; success is not guaranteed. Billed as a normal browser render. |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape create --url <url> --format <format> --country <cc> --timeout-ms <n> --markdown-mode <mode> --markdown-query <q> --cache-ttl <ttl> --delay-ms <n> --events <csv> --token-encoding <enc> --custom <json> --remove-base64-images --no-remove-base64-images --markdown-links <mode> --markdown-images <mode> --with-links-summary --with-images-summary --markdown-compact --markdown-filter-images --markdown-include-media --markdown-include-warnings --markdown-include-stats --async --webhook-url <url> --token-budget <n> --clean-markdown --include-tags <csv> --exclude-tags <csv> --mobile --solve-challenge --raw\n```\n\n### scrape › get\n\nGet a scrape job by ID (use --raw/-o/--format to retrieve a completed body)\n\n| Option | Description |\n| --- | --- |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `--format <format>` | Which persisted format to emit — only takes effect with --raw/-o; ignored otherwise |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape get <id> --raw --format <format>\n```"
306
311
  },
307
312
  "cli/screenshots": {
308
313
  "title": "Screenshots",
309
314
  "section": "CLI Reference",
310
- "body": "# Screenshots\n\nScreenshot operations\n\nScreenshot operations\n\n### screenshots › create\n\nCapture a screenshot\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to screenshot |\n| `--full-page` | Capture the full page (default: viewport only) |\n| `--device <device>` | Device profile: desktop, mobile |\n| `--viewport <WxH>` | Viewport size WIDTHxHEIGHT (e.g. 1280x720) |\n| `--format <format>` | Image format: jpeg, png |\n| `--quality <n>` | JPEG quality (1-100) |\n| `--wait-until <event>` | Wait condition: load, domcontentloaded, networkidle |\n| `--clip <x,y,w,h>` | Clip region X,Y,WIDTH,HEIGHT (e.g. 0,0,800,600) |\n| `--block-ads` | Block ads before capture (server default) |\n| `--no-block-ads` | Do not block ads |\n| `--block-cookie-banners` | Block cookie-consent banners before capture (server default) |\n| `--no-block-cookie-banners` | Do not block cookie-consent banners |\n| `--scroll` | Scroll the page before capture to trigger lazy content (server default) |\n| `--no-scroll` | Do not scroll the page before capture |\n| `--wait-for-selector <sel>` | Wait until this CSS selector is present before capture |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--dark-mode` | Emulate prefers-color-scheme: dark |\n| `--device-scale-factor <n>` | Device pixel ratio: 1, 2 |\n| `--include-html` | Include the rendered HTML alongside the screenshot |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--language <lang>` | Accept-Language override (e.g. en-US) |\n| `--metadata <json>` | Arbitrary metadata echoed on the screenshot envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--async` | Queue the screenshot and return a job envelope immediately (no wait) |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots create --url <url> --full-page --device <device> --viewport <WxH> --format <format> --quality <n> --wait-until <event> --clip <x,y,w,h> --block-ads --no-block-ads --block-cookie-banners --no-block-cookie-banners --scroll --no-scroll --wait-for-selector <sel> --delay-ms <n> --dark-mode --device-scale-factor <n> --include-html --country <cc> --language <lang> --metadata <json> --async\n```\n\n### screenshots › get\n\nGet a screenshot by ID\n\n| Option | Description |\n| --- | --- |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots get <id>\n```"
315
+ "body": "# Screenshots\n\nScreenshot operations\n\nScreenshot operations\n\n### screenshots › create\n\nCapture a screenshot\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to screenshot |\n| `--full-page` | Capture the full page (default: viewport only) |\n| `--device <device>` | Device profile: desktop, mobile |\n| `--viewport <WxH>` | Viewport size WIDTHxHEIGHT (e.g. 1280x720) |\n| `--format <format>` | Image format: jpeg, png |\n| `--quality <n>` | JPEG quality (1-100) |\n| `--wait-until <event>` | Wait condition: load, domcontentloaded, networkidle |\n| `--clip <x,y,w,h>` | Clip region X,Y,WIDTH,HEIGHT (e.g. 0,0,800,600) |\n| `--block-ads` | Block ads before capture (server default) |\n| `--no-block-ads` | Do not block ads |\n| `--block-cookie-banners` | Block cookie-consent banners before capture (server default) |\n| `--no-block-cookie-banners` | Do not block cookie-consent banners |\n| `--scroll` | Scroll the page before capture to trigger lazy content (server default) |\n| `--no-scroll` | Do not scroll the page before capture |\n| `--wait-for-selector <sel>` | Wait until this CSS selector is present before capture |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--dark-mode` | Emulate prefers-color-scheme: dark |\n| `--device-scale-factor <n>` | Device pixel ratio: 1 |\n| `--include-html` | Include the rendered HTML alongside the screenshot |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--language <lang>` | Accept-Language override (e.g. en-US) |\n| `--metadata <json>` | Arbitrary metadata echoed on the screenshot envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--async` | Queue the screenshot and return a job envelope immediately (no wait) |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots create --url <url> --full-page --device <device> --viewport <WxH> --format <format> --quality <n> --wait-until <event> --clip <x,y,w,h> --block-ads --no-block-ads --block-cookie-banners --no-block-cookie-banners --scroll --no-scroll --wait-for-selector <sel> --delay-ms <n> --dark-mode --device-scale-factor <n> --include-html --country <cc> --language <lang> --metadata <json> --async\n```\n\n### screenshots › get\n\nGet a screenshot by ID\n\n| Option | Description |\n| --- | --- |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots get <id>\n```"
311
316
  },
312
317
  "cli/search": {
313
318
  "title": "Search",
@@ -342,7 +347,7 @@
342
347
  "guides/bulk": {
343
348
  "title": "Bulk",
344
349
  "section": "Guides",
345
- "body": "# Bulk\n\nSubmit many URLs in one request — which of the three bulk APIs to use, how results arrive, how to cancel a job, what it costs, and the limits.\n\nByteKit has three bulk APIs. Each takes a list of URLs in one request, answers `202` with a job id, and does the work in the background.\nYou get the results by webhook when the job completes, and you can also read them by polling. A job that is cancelled or failed sends no webhook, so poll it.\n\n## Which bulk API to use\n\n| You want | Use | Entries are |\n| ------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ |\n| Screenshots, or screenshots and scrapes in one job | `POST /v1/bulk` | `urls`, or `items` that each choose `screenshot` or `scrape` |\n| Scrapes only, as `raw`, `markdown`, `links` or `images` | `POST /v1/scrape/bulk` | `urls`, or `items` with per-URL options |\n| The raw response from each URL | `POST /v1/fetch/bulk` | `urls`, as strings or small objects |\n\nThe three do not share one field set. For example, `clean_markdown` is accepted on `/v1/scrape/bulk` and\nrejected on `/v1/bulk` with a `422`, and `wait_until` is accepted on `/v1/bulk` and rejected on a\n`/v1/scrape/bulk` item with a `422`. The API Reference lists the fields of each:\n[Bulk](https://bytekit.com/docs/api/bulk/createbulk), [Scrape bulk](https://bytekit.com/docs/api/scrape-bulk/createscrapebulk) and\n[Fetch bulk](https://bytekit.com/docs/api/fetch-bulk/createfetchbulk).\n\n`/v1/fetch/bulk` does not render pages. A `cookies` or `headers` field in its body, in `defaults`, or in a `urls` object returns\n`400 validation_error` with the message `cookies is no longer accepted: caller-supplied cookies and headers were removed from the capture API. Every capture presents ByteKit's own identity to the target site.` (the message for `headers` is the same with `headers` in place of the leading `cookies`; for a `urls` object it starts with `Item 0: `, using the object's position). No bulk route accepts `cookies` or `headers`, so there is no other route to send them to. A `wait_for_selector`, `delay_ms` or `wait_until` field in the same three places returns `400 validation_error` with the message `Use /v1/bulk for browser-backed options.`, with the same `Item 0: ` prefix, because `/v1/bulk` accepts all three. Naming a scrape format such as `markdown` as `format` is also a `400`. For\nMarkdown, links or images from a batch, use `/v1/scrape/bulk`.\n\n## Submit a job\n\nAll three create routes require `webhook_url`, an `https://` URL. An `http://` URL is rejected with\n`400 invalid_url` and the reason `scheme_unsupported`. Set `webhook_secret` to have the deliveries signed;\nsee the [Webhooks guide](https://bytekit.com/docs/guides/webhooks) for verification.\n\n### Mixed screenshots and scrapes\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/bulk \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"items\": [\n {\"url\": \"https://example.com/?page=bulk-guide-1\", \"type\": \"screenshot\"},\n {\"url\": \"https://example.com/?page=bulk-guide-1\", \"type\": \"scrape\", \"formats\": [\"markdown\"]}\n ],\n \"webhook_url\": \"https://hooks.example.com/bytekit\"\n }'\n```\n\n```json\n{\n \"id\": \"bulk_01a125a61d9777909cff22879e7d0165\",\n \"status\": \"processing\",\n \"total\": 2,\n \"completed\": 0,\n \"failed\": 0,\n \"total_credits_charged\": 0,\n \"total_billed_bytes\": null,\n \"estimated_credits\": 2.5,\n \"webhook_url\": \"https://hooks.example.com/bytekit\",\n \"created_at\": \"2026-10-10T11:50:05.984Z\",\n \"completed_at\": null\n}\n```\n\n> This request was run for real and returned `202`.\n\nKeep the `id`: it is how you read and cancel the job. `total_billed_bytes` is `null` here because nothing has completed yet.\n\n### Scrapes only\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/scrape/bulk \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"urls\": [\"https://example.com/?page=bulk-guide-2\"],\n \"defaults\": {\"formats\": [\"markdown\"]},\n \"webhook_url\": \"https://hooks.example.com/bytekit\"\n }'\n```\n\n> This request was run for real and returned `202`, with the same job envelope as above.\n\n### Raw fetches\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/fetch/bulk \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"urls\": [\"https://example.com/?page=bulk-guide-3\"],\n \"webhook_url\": \"https://hooks.example.com/bytekit\"\n }'\n```\n\n> This request was run for real and returned `202`, with the same job envelope as above.\n\n### `urls` or `items`\n\nOn `/v1/bulk` and `/v1/scrape/bulk`, send `urls` or `items`, not both. A request with both returns\n`422 validation_error` (`Provide either urls or items, not both.`), and a request with neither returns\n`422 validation_error` (`Either urls or items must be provided.`).\n\n- `urls` is a plain list of URLs. Each one takes the values in `defaults`.\n- `items` is a list of objects, each with a `url` and its own options. An option on an item wins over the\n same option in `defaults`.\n- On `/v1/bulk`, an entry that names no `type` is a screenshot unless `defaults.type` says `scrape`. A bare\n `urls` list on `/v1/bulk` therefore produces screenshots, and with `\"defaults\": {\"type\": \"scrape\"}` it\n produces scrapes. Both were run for real.\n- `/v1/fetch/bulk` has no `items`. It takes `urls`, as strings or as objects with `url`, `country` and\n `cache_ttl`, and a body with `items` and no `urls` returns `422 validation_error`.\n\n## Get the results\n\n### By webhook\n\nWhen the job reaches `completed`, ByteKit sends a `POST` to your `webhook_url` with the header `X-ByteKit-Event: bulk.completed`, so you can dispatch on the header without reading the body. A job that ends `cancelled` or `failed` gets no webhook, so poll it. The\n[Scraping guide](https://bytekit.com/docs/guides/scraping#webhook-event-header) lists the other event types.\n\nThe body is bounded: it carries at most 500 complete items and 1 MiB of JSON. These are its fields, from\nthe API Reference (this page shows no captured delivery):\n\n| Field | Meaning |\n| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `bulk_id` | The job id |\n| `status` | `completed` |\n| `total`, `completed`, `failed` | Counts for the whole job |\n| `total_billed_bytes` | Bandwidth billed for the job, in bytes, or `null` when it cannot be reported in full |\n| `total_credits_charged` | Deprecated: read `total_billed_bytes` instead |\n| `webhook_url` | The `webhook_url` the job was created with |\n| `items` | Complete item records, up to 500. Each has an `id`, a `type` and a `status` (`success`, `completed`, `failed` or `cancelled`), and may carry `error_code` and `error_message` |\n| `recovery_api` | `fetch`, `scrape` or `mixed`: which API created the job |\n| `recovery_url` | The path to read the rest of the results from |\n| `manifest_item_count` | How many items this body carries |\n| `manifest_items_complete` | `true` when every item that reached a final status is in `items` |\n| `manifest_artifacts_complete` | `true` when every included completed item has a usable result reference |\n| `manifest_complete` | `true` when both of the above are `true` |\n| `recovery_required` | The inverse of `manifest_complete` |\n\nWhen `recovery_required` is `true`, the body does not hold the whole job. Read the rest from\n`recovery_url` with cursors: request it, then repeat the request with `?cursor=` set to the `next_cursor`\nyou were given, until `has_more` is `false`. `recovery_url` depends on the API that created the job:\n\n| Created with | `recovery_url` |\n| ---------------------- | --------------------------- |\n| `POST /v1/bulk` | `/v1/bulk/{id}/screenshots` |\n| `POST /v1/scrape/bulk` | `/v1/scrape/bulk/{id}` |\n| `POST /v1/fetch/bulk` | `/v1/fetch/bulk/{id}` |\n\nA delivery can arrive more than once or late. Use `bulk_id` together with each item `id` to process an item\nonce.\n\n### By polling\n\nEach API has `GET` routes for its own jobs. The job routes (`GET /v1/bulk/{id}`,\n`GET /v1/scrape/bulk/{id}` and `GET /v1/fetch/bulk/{id}`) answer `202` while the job is `processing` and `200` once it is `completed`, `failed` or `cancelled`. `GET /v1/bulk/{id}/screenshots` answers `200` whatever the job's status; an item that\nhas not completed shows `null` in `billing`.\n\n| Created with | Job status | Items |\n| ---------------------- | -------------------------- | --------------------------------------------------------- |\n| `POST /v1/bulk` | `GET /v1/bulk/{id}` | `GET /v1/bulk/{id}/screenshots`, whatever the item `type` |\n| `POST /v1/scrape/bulk` | `GET /v1/scrape/bulk/{id}` | the same response, in `items` |\n| `POST /v1/fetch/bulk` | `GET /v1/fetch/bulk/{id}` | the same response, in `items` |\n\n`GET /v1/bulk/{id}/screenshots` lists the items of a mixed job and is not limited to screenshots; each item\nhas a `type` of `screenshot` or `scrape`. Unless the job is cancelled, its `status` is `processing` until every item has completed or failed, and `completed` after. A `completed` job can have a non-zero `failed`; read `failed` to tell. The other values are `failed` and `cancelled`.\n\n```bash\ncurl -i https://api.bytekit.com/v1/bulk/bulk_01a125a61d9777909cff22879e7d0165 \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n```json\n{\n \"id\": \"bulk_01a125a61d9777909cff22879e7d0165\",\n \"status\": \"completed\",\n \"total\": 2,\n \"completed\": 2,\n \"failed\": 0,\n \"total_credits_charged\": 0,\n \"total_billed_bytes\": 1002,\n \"estimated_credits\": null,\n \"webhook_url\": \"https://hooks.example.com/bytekit\",\n \"created_at\": \"2026-10-10T11:50:05.951Z\",\n \"completed_at\": \"2026-10-10T11:50:16.313Z\"\n}\n```\n\n> This request was run for real and returned `200`. Called while the job was still running, it returned `202`.\n\nThe items of that job:\n\n```bash\ncurl -i https://api.bytekit.com/v1/bulk/bulk_01a125a61d9777909cff22879e7d0165/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n```json\n{\n \"bulk_id\": \"bulk_01a125a61d9777909cff22879e7d0165\",\n \"items\": [\n {\n \"type\": \"screenshot\",\n \"id\": \"ss_01a125a61d9d744299721fb4b915b626\",\n \"status\": \"completed\",\n \"url\": \"https://example.com/?page=bulk-guide-1\",\n \"image_url\": \"https://…\",\n \"billing\": { \"raw_bytes\": 334, \"multiplier\": 1.5, \"billed_bytes\": 501 },\n \"error_code\": null\n },\n {\n \"type\": \"scrape\",\n \"id\": \"sc_01a125a61d9973569644148e9697b8ba\",\n \"status\": \"completed\",\n \"url\": \"https://example.com/?page=bulk-guide-1\",\n \"content_url\": \"https://…\",\n \"markdown_url\": \"https://…\",\n \"billing\": { \"raw_bytes\": 334, \"multiplier\": 1.5, \"billed_bytes\": 501 },\n \"error_code\": null\n }\n ],\n \"total\": 2,\n \"next_cursor\": null,\n \"has_more\": false,\n \"job_counters\": { \"total\": 2, \"completed\": 2, \"failed\": 0 }\n}\n```\n\n> This request was run for real and returned `200`. Links are shortened, and other fields, such as\n> `page_title`, `artifacts` and `created_at`, are left out.\n\nThe item routes take `limit`, `cursor` and `status` (`pending`, `processing`, `completed`, `failed` or\n`cancelled`). `limit` runs from 1 to 500; its default is 100 on `/v1/bulk/{id}/screenshots` and 500 on the\nother two. Pass the `next_cursor` of one page as `cursor` of the next while `has_more` is `true`, and reuse\nthe same `status` filter for the whole walk.\n\nDownload links in the item lists are signed and expire. `content_url`, `markdown_url` and `image_url` on\n`/v1/bulk/{id}/screenshots` and `content_url` on `/v1/fetch/bulk/{id}` are valid for 600 seconds; read the\njob again for a fresh link. On `/v1/scrape/bulk/{id}`, a `raw` or `markdown` result up to 10 MiB is returned\ninline, and a larger one is replaced by a signed link valid for 24 hours.\n\nRead a job through the routes of the API that created it. Another API's routes can answer `200` with\nsomething else: in a run for real, `GET /v1/fetch/bulk/{id}` on a `POST /v1/bulk` job returned `200` with an\nempty `items` list.\n\n### Listing jobs\n\n`GET /v1/bulk` lists your bulk jobs, most recent first, whichever API created them. It takes `status`\n(`processing`, `completed`, `failed` or `cancelled`), `limit` (1 to 100, default 25) and `cursor`. Follow\n`next_cursor` while `has_more` is `true`. Each entry is the job envelope without `items`.\n\n```bash\ncurl -i \"https://api.bytekit.com/v1/bulk?limit=2\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n> This request was run for real and returned `200` with `data`, `next_cursor` and `has_more`.\n\n## Cancel a job\n\n`DELETE /v1/bulk/{id}` cancels a job that is still running. It takes the id from any of the three create\nroutes. `/v1/scrape/bulk/{id}` and `/v1/fetch/bulk/{id}` have no `DELETE`; they answer `404`.\n\nCancelling drains the items that are still waiting to start and refunds the quota held for exactly those.\nItems that already completed or are in progress are not refunded by the cancel. A failed item adds nothing to `total_billed_bytes`, and on `GET /v1/bulk/{id}/screenshots` it shows `null` in `billing`. Repeating a `DELETE` is safe: on a job that is already `completed`, `failed` or `cancelled` it returns `200` with the job's current status. An id that does not exist, or that belongs to another account, returns `404 not_found`.\n\nByteKit can also cancel a job without a `DELETE`. When your balance has run out as the next waiting item is about to start, the waiting items are cancelled, their quota is refunded, and the job's `status` becomes `cancelled`. No webhook is sent for it, so poll the job.\n\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 22315 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/bulk]"
350
+ "body": "# Bulk\n\nSubmit many URLs in one request — which of the three bulk APIs to use, how results arrive, how to cancel a job, what it costs, and the limits.\n\nByteKit has three bulk APIs. Each takes a list of URLs in one request, answers `202` with a job id, and does the work in the background.\nYou get the results by webhook when the job completes, and you can also read them by polling. A job that is cancelled or failed sends no webhook, so poll it.\n\n## Which bulk API to use\n\n| You want | Use | Entries are |\n| ------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ |\n| Screenshots, or screenshots and scrapes in one job | `POST /v1/bulk` | `urls`, or `items` that each choose `screenshot` or `scrape` |\n| Scrapes only, as `raw`, `markdown`, `links` or `images` | `POST /v1/scrape/bulk` | `urls`, or `items` with per-URL options |\n| The raw response from each URL | `POST /v1/fetch/bulk` | `urls`, as strings or small objects |\n\nThe three do not share one field set. For example, `clean_markdown` is accepted on `/v1/scrape/bulk` and\nrejected on `/v1/bulk` with a `422`, and `wait_until` is accepted on `/v1/bulk` and rejected on a\n`/v1/scrape/bulk` item with a `422`. The API Reference lists the fields of each:\n[Bulk](https://bytekit.com/docs/api/bulk/createbulk), [Scrape bulk](https://bytekit.com/docs/api/scrape-bulk/createscrapebulk) and\n[Fetch bulk](https://bytekit.com/docs/api/fetch-bulk/createfetchbulk).\n\n`/v1/fetch/bulk` does not render pages. A `cookies` or `headers` field in its body, in `defaults`, or in a `urls` object returns\n`400 validation_error` with the message `cookies is no longer accepted: caller-supplied cookies and headers were removed from the capture API. Every capture presents ByteKit's own identity to the target site.` (the message for `headers` is the same with `headers` in place of the leading `cookies`; for a `urls` object it starts with `Item 0: `, using the object's position). No bulk route accepts `cookies` or `headers`, so there is no other route to send them to. A `wait_for_selector`, `delay_ms` or `wait_until` field in the same three places returns `400 validation_error` with the message `Use /v1/bulk for browser-backed options.`, with the same `Item 0: ` prefix, because `/v1/bulk` accepts all three. Naming a scrape format such as `markdown` as `format` is also a `400`. For\nMarkdown, links or images from a batch, use `/v1/scrape/bulk`.\n\n## Submit a job\n\nAll three create routes require `webhook_url`, an `https://` URL. An `http://` URL is rejected with\n`400 invalid_url` and the reason `scheme_unsupported`. Set `webhook_secret` to have the deliveries signed;\nsee the [Webhooks guide](https://bytekit.com/docs/guides/webhooks) for verification.\n\n### Mixed screenshots and scrapes\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/bulk \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"items\": [\n {\"url\": \"https://example.com/?page=bulk-guide-1\", \"type\": \"screenshot\"},\n {\"url\": \"https://example.com/?page=bulk-guide-1\", \"type\": \"scrape\", \"formats\": [\"markdown\"]}\n ],\n \"webhook_url\": \"https://hooks.example.com/bytekit\"\n }'\n```\n\n```json\n{\n \"id\": \"bulk_01a125a61d9777909cff22879e7d0165\",\n \"status\": \"processing\",\n \"total\": 2,\n \"completed\": 0,\n \"failed\": 0,\n \"total_credits_charged\": 0,\n \"total_billed_bytes\": null,\n \"estimated_credits\": 2.5,\n \"webhook_url\": \"https://hooks.example.com/bytekit\",\n \"created_at\": \"2026-10-10T11:50:05.984Z\",\n \"completed_at\": null\n}\n```\n\n> This request was run for real and returned `202`.\n\nKeep the `id`: it is how you read and cancel the job. `total_billed_bytes` is `null` here because nothing has completed yet.\n\n### Scrapes only\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/scrape/bulk \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"urls\": [\"https://example.com/?page=bulk-guide-2\"],\n \"defaults\": {\"formats\": [\"markdown\"]},\n \"webhook_url\": \"https://hooks.example.com/bytekit\"\n }'\n```\n\n> This request was run for real and returned `202`, with the same job envelope as above.\n\n### Raw fetches\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/fetch/bulk \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"urls\": [\"https://example.com/?page=bulk-guide-3\"],\n \"webhook_url\": \"https://hooks.example.com/bytekit\"\n }'\n```\n\n> This request was run for real and returned `202`, with the same job envelope as above.\n\n### `urls` or `items`\n\nOn `/v1/bulk` and `/v1/scrape/bulk`, send `urls` or `items`, not both. A request with both returns\n`422 validation_error` (`Provide either urls or items, not both.`), and a request with neither returns\n`422 validation_error` (`Either urls or items must be provided.`).\n\n- `urls` is a plain list of URLs. Each one takes the values in `defaults`.\n- `items` is a list of objects, each with a `url` and its own options. An option on an item wins over the\n same option in `defaults`.\n- On `/v1/bulk`, an entry that names no `type` is a screenshot unless `defaults.type` says `scrape`. A bare\n `urls` list on `/v1/bulk` therefore produces screenshots, and with `\"defaults\": {\"type\": \"scrape\"}` it\n produces scrapes. Both were run for real.\n- `/v1/fetch/bulk` has no `items`. It takes `urls`, as strings or as objects with `url`, `country` and\n `cache_ttl`, and a body with `items` and no `urls` returns `422 validation_error`.\n\n## Get the results\n\n### By webhook\n\nWhen the job reaches `completed`, ByteKit sends a `POST` to your `webhook_url` with the header `X-ByteKit-Event: bulk.completed`, so you can dispatch on the header without reading the body. A job that ends `cancelled` or `failed` gets no webhook, so poll it. The\n[Scraping guide](https://bytekit.com/docs/guides/scraping#webhook-event-header) lists the other event types.\n\nThe body is bounded: it carries at most 500 complete items and 1 MiB of JSON. These are its fields, from\nthe API Reference (this page shows no captured delivery):\n\n| Field | Meaning |\n| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `bulk_id` | The job id |\n| `status` | `completed` |\n| `total`, `completed`, `failed` | Counts for the whole job |\n| `total_billed_bytes` | Bandwidth billed for the job, in bytes, or `null` when it cannot be reported in full |\n| `total_credits_charged` | Deprecated: read `total_billed_bytes` instead |\n| `webhook_url` | The `webhook_url` the job was created with |\n| `items` | Complete item records, up to 500. Each has an `id`, a `type` and a `status` (`success`, `completed`, `failed` or `cancelled`), and may carry `error_code` and `error_message` |\n| `recovery_api` | `fetch`, `scrape` or `mixed`: which API created the job |\n| `recovery_url` | The path to read the rest of the results from |\n| `manifest_item_count` | How many items this body carries |\n| `manifest_items_complete` | `true` when every item that reached a final status is in `items` |\n| `manifest_artifacts_complete` | `true` when every included completed item has a usable result reference |\n| `manifest_complete` | `true` when both of the above are `true` |\n| `recovery_required` | The inverse of `manifest_complete` |\n\nWhen `recovery_required` is `true`, the body does not hold the whole job. Read the rest from\n`recovery_url` with cursors: request it, then repeat the request with `?cursor=` set to the `next_cursor`\nyou were given, until `has_more` is `false`. `recovery_url` depends on the API that created the job:\n\n| Created with | `recovery_url` |\n| ---------------------- | --------------------------- |\n| `POST /v1/bulk` | `/v1/bulk/{id}/screenshots` |\n| `POST /v1/scrape/bulk` | `/v1/scrape/bulk/{id}` |\n| `POST /v1/fetch/bulk` | `/v1/fetch/bulk/{id}` |\n\nA delivery can arrive more than once or late. Use `bulk_id` together with each item `id` to process an item\nonce.\n\n### By polling\n\nEach API has `GET` routes for its own jobs. The job routes (`GET /v1/bulk/{id}`,\n`GET /v1/scrape/bulk/{id}` and `GET /v1/fetch/bulk/{id}`) answer `202` while the job is `processing` and `200` once it is `completed`, `failed` or `cancelled`. `GET /v1/bulk/{id}/screenshots` answers `200` whatever the job's status; an item that\nhas not completed shows `null` in `billing`.\n\n| Created with | Job status | Items |\n| ---------------------- | -------------------------- | --------------------------------------------------------- |\n| `POST /v1/bulk` | `GET /v1/bulk/{id}` | `GET /v1/bulk/{id}/screenshots`, whatever the item `type` |\n| `POST /v1/scrape/bulk` | `GET /v1/scrape/bulk/{id}` | the same response, in `items` |\n| `POST /v1/fetch/bulk` | `GET /v1/fetch/bulk/{id}` | the same response, in `items` |\n\n`GET /v1/bulk/{id}/screenshots` lists the items of a mixed job and is not limited to screenshots; each item\nhas a `type` of `screenshot` or `scrape`. Unless the job is cancelled, its `status` is `processing` until every item has completed or failed, and `completed` after. A `completed` job can have a non-zero `failed`; read `failed` to tell. The other values are `failed` and `cancelled`.\n\n```bash\ncurl -i https://api.bytekit.com/v1/bulk/bulk_01a125a61d9777909cff22879e7d0165 \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n```json\n{\n \"id\": \"bulk_01a125a61d9777909cff22879e7d0165\",\n \"status\": \"completed\",\n \"total\": 2,\n \"completed\": 2,\n \"failed\": 0,\n \"total_credits_charged\": 0,\n \"total_billed_bytes\": 1002,\n \"estimated_credits\": null,\n \"webhook_url\": \"https://hooks.example.com/bytekit\",\n \"created_at\": \"2026-10-10T11:50:05.951Z\",\n \"completed_at\": \"2026-10-10T11:50:16.313Z\"\n}\n```\n\n> This request was run for real and returned `200`. Called while the job was still running, it returned `202`.\n\nThe items of that job:\n\n```bash\ncurl -i https://api.bytekit.com/v1/bulk/bulk_01a125a61d9777909cff22879e7d0165/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n```json\n{\n \"bulk_id\": \"bulk_01a125a61d9777909cff22879e7d0165\",\n \"items\": [\n {\n \"type\": \"screenshot\",\n \"id\": \"ss_01a125a61d9d744299721fb4b915b626\",\n \"status\": \"completed\",\n \"url\": \"https://example.com/?page=bulk-guide-1\",\n \"image_url\": \"https://…\",\n \"billing\": { \"raw_bytes\": 334, \"multiplier\": 1.5, \"billed_bytes\": 501 },\n \"error_code\": null\n },\n {\n \"type\": \"scrape\",\n \"id\": \"sc_01a125a61d9973569644148e9697b8ba\",\n \"status\": \"completed\",\n \"url\": \"https://example.com/?page=bulk-guide-1\",\n \"content_url\": \"https://…\",\n \"markdown_url\": \"https://…\",\n \"billing\": { \"raw_bytes\": 334, \"multiplier\": 1.5, \"billed_bytes\": 501 },\n \"error_code\": null\n }\n ],\n \"total\": 2,\n \"next_cursor\": null,\n \"has_more\": false,\n \"job_counters\": { \"total\": 2, \"completed\": 2, \"failed\": 0 }\n}\n```\n\n> This request was run for real and returned `200`. Links are shortened, and other fields, such as\n> `page_title`, `artifacts` and `created_at`, are left out.\n\nThe item routes take `limit`, `cursor` and `status` (`pending`, `processing`, `completed`, `failed` or\n`cancelled`). `limit` runs from 1 to 500; its default is 100 on `/v1/bulk/{id}/screenshots` and 500 on the\nother two. Pass the `next_cursor` of one page as `cursor` of the next while `has_more` is `true`, and reuse\nthe same `status` filter for the whole walk.\n\nDownload links in the item lists are signed and expire. `content_url`, `markdown_url` and `image_url` on\n`/v1/bulk/{id}/screenshots` and `content_url` on `/v1/fetch/bulk/{id}` are valid for 600 seconds; read the\njob again for a fresh link. On `/v1/scrape/bulk/{id}`, a `raw` or `markdown` result up to 10 MiB is returned\ninline, and a larger one is replaced by a signed link valid for 24 hours.\n\nRead a job through the routes of the API that created it. Another API's routes can answer `200` with\nsomething else: in a run for real, `GET /v1/fetch/bulk/{id}` on a `POST /v1/bulk` job returned `200` with an\nempty `items` list.\n\n### Listing jobs\n\n`GET /v1/bulk` lists your bulk jobs, most recent first, whichever API created them. It takes `status`\n(`processing`, `completed`, `failed` or `cancelled`), `limit` (1 to 100, default 25) and `cursor`. Follow\n`next_cursor` while `has_more` is `true`. Each entry is the job envelope without `items`.\n\n```bash\ncurl -i \"https://api.bytekit.com/v1/bulk?limit=2\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n> This request was run for real and returned `200` with `data`, `next_cursor` and `has_more`.\n\n### Checking bulk concurrency\n\n`GET /v1/bulk/concurrency` returns `{ active, limit }`: how many of your account's bulk concurrency slots\nare in use, and your plan's maximum concurrency. Compare the two to see whether your jobs are held at the\ncap. `active` is `null` when the count cannot be read right now; it is not zero. A slot whose release never\narrived drops out of the count after 5 minutes.\n\n## Cancel a job\n\n`DELETE /v1/bulk/{id}` cancels a job that is still running. It takes the id from any of the three create\nroutes. `/v1/scrape/bulk/{id}` and `/v1/fetch/bulk/{id}` have no `DELETE`; they answer `404`.\n\nCancelling drains the items that are still waiting to start and refunds the quota held for exactly those.\nItems that already completed or are in progress are not refunded by the cancel. A failed item adds nothing to `total_billed_bytes`, and on `GET /v1/bulk/{id}/screenshots` it shows `null` in `billing`. Repeating a `DELETE` is safe: on a job that is already `completed`, `failed` or `cancelled` it retu\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 22715 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/bulk]"
346
351
  },
347
352
  "guides/choosing-an-endpoint": {
348
353
  "title": "Choosing an endpoint",
@@ -352,7 +357,7 @@
352
357
  "guides/errors": {
353
358
  "title": "Errors",
354
359
  "section": "Guides",
355
- "body": "# Errors\n\nByteKit error response shape, common error codes, and retry guidance.\n\nAll errors from the ByteKit API follow a consistent envelope shape so you can handle them\nprogrammatically.\n\n## Error response shape\n\nEvery `4xx`/`5xx` response across the API uses one unified envelope. `status` is\nalways the literal string `\"failed\"`, so you can branch on the response body alone.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"rate_limited\",\n \"message\": \"Rate limit exceeded. Allowed 5 requests per second.\",\n \"http_status\": 429,\n \"failed_at\": \"2026-08-27T12:17:46.234Z\"\n }\n}\n```\n\nThe number in a `rate_limited` message is your own plan's per-second limit — the same value the `X-RateLimit-Limit` response header carries.\n\n| Field | Description |\n| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |\n| `status` | Always `\"failed\"` on an error response — the top-level discriminator |\n| `error.code` | Machine-readable string identifier |\n| `error.message` | Human-readable explanation |\n| `error.http_status` | Mirrors the HTTP response status (useful for logged or replayed bodies) |\n| `error.failed_at` | ISO-8601 UTC timestamp of when the error was produced |\n| `error.details` | Optional object with additional context (e.g. which field failed validation). Absent — not `{}` — when the error carries no context |\n\n## Common error codes\n\n| HTTP status | Code | Meaning |\n| ----------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `400` | `invalid_url` | A supplied URL (including `webhook_url`) is malformed or uses an unsupported scheme |\n| `400` | `validation_error` | Field errors on `/v1/search`, `POST /v1/billing/checkout` and `PUT`/`DELETE /v1/billing/payment-methods/{id}`, plus rejections that run before schema validation on any endpoint: a removed field such as `cookies` or `headers` on a capture endpoint, or a `/v1/fetch` or `/v1/fetch/bulk` request asking for an option only `/v1/scrape` or `/v1/bulk` serves |\n| `401` | `unauthorized` | Missing or malformed `Authorization` header |\n| `401` | `invalid_api_key` | API key is present but not valid |\n| `402` | `quota_exceeded` | The [balance](https://bytekit.com/docs/billing#terms) cannot fund this request. Capture endpoints reject when it cannot fund the request's byte reservation, and `error.details.required_bytes` and `error.details.available_bytes` give the bytes the request reserves and the bytes available; `/v1/search` meters credits and rejects when its credit balance is used up |\n| `402` | `spending_cap_reached` | A credit-metered request would push overage spend past the account's cap. Only reachable on a custom plan with an overage agreement — standard plans have no automatic overage and stop at `quota_exceeded` |\n| `402` | `billing_entitlement_impaired` | The paid subscription is in a payment impairment (e.g. `past_due`); `error.message` names the reason |\n| `402` | `billing_entitlement_expired` | The paid subscription's entitlement period has ended, or its dunning grace period has run out |\n| `403` | `forbidden` | Key is valid but lacks permission for this action |\n| `422` | `validation_error` | Malformed JSON, or a request field failed validation, everywhere the `400` row above does not name |\n| `422` | `blocked`, `upstream_error` | `/v1/fetch` only: the fetch ran and the target could not be read (bot protection refused every attempt, or another exhausted-retries failure such as an unresolvable host). This is a result about the URL, not an outage of this API, and it is charged nothing. `upstream_error` can also come from a relay fault on our side, so the code alone does not prove the target is at fault. The `X-Fetch-ID` response header, when present, names the failed request's row in Logs |\n| `429` | `rate_limited` | Too many requests per second; back off and retry |\n| `429` | `concurrency_limit` | Too many simultaneous in-flight requests; back off and retry |\n| `500` | `internal_error` | A ByteKit-side failure (for example, failing to enqueue a job or to persist a result, or an unexpected server error), not a problem with the target site. A target-site failure is a result instead: a `200` response with a `failed` scrape envelope on `/v1/scrape` (its `error.code` can itself be `internal_error`), or the `422` `blocked` / `upstream_error` row above on `/v1/fetch` |\n\n## Webhook URLs Must Use HTTPS\n\nAll webhook URLs submitted to the ByteKit API must use HTTPS. Plain HTTP URLs (e.g. `http://example.com/webhook`) are rejected with a `400` `invalid_url` error.\n\n**Why HTTPS only?** Webhook payloads may contain sensitive data (API keys, session tokens, scrape results). HTTPS encryption protects this data in transit.\n\n**Request with an invalid webhook URL:**\n\n```json\n{\n \"webhook_url\": \"http://example.com/webhook\"\n}\n```\n\n**Response (HTTP 400)** — the same unified envelope as every other error; `error.details` names the offending field and reason:\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"invalid_url\",\n \"message\": \"url is not a valid HTTP(S) URL: scheme_unsupported\",\n \"http_status\": 400,\n \"failed_at\": \"2026-08-27T12:16:29.033Z\",\n \"details\": {\n \"url\": \"http://example.com/webhook\",\n \"field\": \"webhook_url\",\n \"reason\": \"scheme_unsupported\"\n }\n }\n}\n```\n\n**Working example:**\n\n```json\n{\n \"webhook_url\": \"https://example.com/webhook\"\n}\n```\n\nThis applies to all endpoints that accept a `webhook_url` parameter: `/v1/scrape` (async), `/v1/scrape/bulk`, `/v1/fetch/bulk`, `/v1/bulk`, `/v1/monitors`, and `/v1/sitemap`.\n\n## Retry guidance\n\nNot all errors are retryable. Use this table to decide:\n\n| Code | Retry? | Guidance |\n| ---------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `invalid_url` | No | Fix the URL before retrying |\n| `validation_error` | No | Fix the request body before retrying |\n| `unauthorized` / `invalid_api_key` | No | Check your API key |\n| `quota_exceeded` | No | Retrying the same request cannot succeed while the balance is short. Compare `error.details.required_bytes` with `error.details.available_bytes`: add balance (upgrade your plan or top up), or send a smaller request. On `/v1/search`, upgrade your plan or wait for the credit reset |\n| `spending_cap_reached` | No | The overage cap is account-level and has no self-service control — [contact support](https://bytekit.com/docs/billing/spending) to raise it, or upgrade the plan |\n| `billing_entitlement_impaired` | No | Settle the outstanding invoice — retrying cannot succeed while the subscription is impaired |\n| `billing_entitlement_expired` | No | Restore or renew the subscription; the entitlement period has ended |\n| `forbidden` | No | You do not have access to this resource |\n| `rate_limited` | Yes | Exponential backoff; honour the `Retry-After` header |\n| `concurrency_limit` | Yes | Honour the `Retry-After` header (a short fixed back-off — a slot frees on job completion, not a fixed window) |\n| `internal_error` | Yes | Exponential backoff; most resolve on retry |\n\nFor retriable errors, start with a 1-second delay and double on each subsequent failure, up to\na maximum of 60 seconds. Respect the `Retry-After` header value when it is present on `429`\nresponses.\n\n## Example: handling error\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 16983 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/errors]"
360
+ "body": "# Errors\n\nByteKit error response shape, common error codes, and retry guidance.\n\nAll errors from the ByteKit API follow a consistent envelope shape so you can handle them\nprogrammatically.\n\n## Error response shape\n\nEvery `4xx`/`5xx` response across the API uses one unified envelope. `status` is\nalways the literal string `\"failed\"`, so you can branch on the response body alone.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"rate_limited\",\n \"message\": \"Rate limit exceeded. Allowed 5 requests per second.\",\n \"http_status\": 429,\n \"failed_at\": \"2026-08-27T12:17:46.234Z\"\n }\n}\n```\n\nThe number in a `rate_limited` message is your own plan's per-second limit — the same value the `X-RateLimit-Limit` response header carries.\n\n| Field | Description |\n| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |\n| `status` | Always `\"failed\"` on an error response — the top-level discriminator |\n| `error.code` | Machine-readable string identifier |\n| `error.message` | Human-readable explanation |\n| `error.http_status` | Mirrors the HTTP response status (useful for logged or replayed bodies) |\n| `error.failed_at` | ISO-8601 UTC timestamp of when the error was produced |\n| `error.details` | Optional object with additional context (e.g. which field failed validation). Absent — not `{}` — when the error carries no context |\n\n## Common error codes\n\n| HTTP status | Code | Meaning |\n| ----------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `400` | `invalid_url` | A supplied URL (including `webhook_url`) is malformed or uses an unsupported scheme |\n| `400` | `validation_error` | Field errors on `/v1/search`, `POST /v1/billing/checkout` and `PUT`/`DELETE /v1/billing/payment-methods/{id}`, plus rejections that run before schema validation on any endpoint: a removed field such as `cookies` or `headers` on a capture endpoint, or a `/v1/fetch` or `/v1/fetch/bulk` request asking for an option only `/v1/scrape` or `/v1/bulk` serves |\n| `401` | `unauthorized` | Missing or malformed `Authorization` header |\n| `401` | `invalid_api_key` | API key is present but not valid |\n| `402` | `quota_exceeded` | The [balance](https://bytekit.com/docs/billing#terms) cannot fund this request. Capture endpoints reject when it cannot fund the request's byte reservation, and `error.details.required_bytes` and `error.details.available_bytes` give the bytes the request reserves and the bytes available; `/v1/search` meters credits and rejects when its credit balance is used up |\n| `402` | `spending_cap_reached` | A credit-metered request would push overage spend past the account's cap. Only reachable on a custom plan with an overage agreement — standard plans have no automatic overage and stop at `quota_exceeded` |\n| `402` | `billing_entitlement_impaired` | The paid subscription is in a payment impairment (e.g. `past_due`); `error.message` names the reason |\n| `402` | `billing_entitlement_expired` | The paid subscription's entitlement period has ended, or its dunning grace period has run out |\n| `403` | `forbidden` | Key is valid but lacks permission for this action |\n| `422` | `validation_error` | Malformed JSON, or a request field failed validation, everywhere the `400` row above does not name |\n| `422` | `blocked`, `upstream_error`, `timeout` | `/v1/fetch` only: the fetch ran and the target could not be read (bot protection refused every attempt, or another exhausted-retries failure such as an unresolvable host), or it ran out of its time limit before the page could be fetched (`timeout`). This is a result about the URL, not an outage of this API, and it is charged nothing. `upstream_error` can also come from a relay fault on our side, so the code alone does not prove the target is at fault. The `X-Fetch-ID` response header, when present, names the failed request's row in Logs |\n| `429` | `rate_limited` | Too many requests per second; back off and retry |\n| `429` | `concurrency_limit` | Too many simultaneous in-flight requests; back off and retry |\n| `500` | `internal_error` | A ByteKit-side failure (for example, failing to enqueue a job or to persist a result, or an unexpected server error), not a problem with the target site. A target-site failure is a result instead: a `200` response with a `failed` scrape envelope on `/v1/scrape` (its `error.code` can itself be `internal_error`), or the `422` `blocked` / `upstream_error` row above on `/v1/fetch` |\n\n## Webhook URLs Must Use HTTPS\n\nAll webhook URLs submitted to the ByteKit API must use HTTPS. Plain HTTP URLs (e.g. `http://example.com/webhook`) are rejected with a `400` `invalid_url` error.\n\n**Why HTTPS only?** Webhook payloads may contain sensitive data (API keys, session tokens, scrape results). HTTPS encryption protects this data in transit.\n\n**Request with an invalid webhook URL:**\n\n```json\n{\n \"webhook_url\": \"http://example.com/webhook\"\n}\n```\n\n**Response (HTTP 400)** — the same unified envelope as every other error; `error.details` names the offending field and reason:\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"invalid_url\",\n \"message\": \"url is not a valid HTTP(S) URL: scheme_unsupported\",\n \"http_status\": 400,\n \"failed_at\": \"2026-08-27T12:16:29.033Z\",\n \"details\": {\n \"url\": \"http://example.com/webhook\",\n \"field\": \"webhook_url\",\n \"reason\": \"scheme_unsupported\"\n }\n }\n}\n```\n\n**Working example:**\n\n```json\n{\n \"webhook_url\": \"https://example.com/webhook\"\n}\n```\n\nThis applies to all endpoints that accept a `webhook_url` parameter: `/v1/scrape` (async), `/v1/scrape/bulk`, `/v1/fetch/bulk`, `/v1/bulk`, `/v1/monitors`, and `/v1/sitemap`.\n\n## Retry guidance\n\nNot all errors are retryable. Use this table to decide:\n\n| Code | Retry? | Guidance |\n| ---------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `invalid_url` | No | Fix the URL before retrying |\n| `validation_error` | No | Fix the request body before retrying |\n| `unauthorized` / `invalid_api_key` | No | Check your API key |\n| `quota_exceeded` | No | Retrying the same request cannot succeed while the balance is short. Compare `error.details.required_bytes` with `error.details.available_bytes`: add balance (upgrade your plan or top up), or send a smaller request. On `/v1/search`, upgrade your plan or wait for the credit reset |\n| `spending_cap_reached` | No | The overage cap is account-level and has no self-service control — [contact support](https://bytekit.com/docs/billing/spending) to raise it, or upgrade the plan |\n| `billing_entitlement_impaired` | No | Settle the outstanding invoice — retrying cannot succeed while the subscription is impaired |\n| `billing_entitlement_expired` | No | Restore or renew the subscription; the entitlement period has ended |\n| `forbidden` | No | You do not have access to this resource \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 18359 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/errors]"
356
361
  },
357
362
  "guides/fetch": {
358
363
  "title": "Fetch",
@@ -377,12 +382,12 @@
377
382
  "guides/scraping": {
378
383
  "title": "Scraping",
379
384
  "section": "Guides",
380
- "body": "# Scraping\n\nScrape any URL as HTML, markdown, or structured content — formats, options, latency, and async polling.\n\n`POST /v1/scrape` fetches a URL and returns its content in the format you ask for. The same\nrequest shape works for every site; the options you pass determine the output and how long the\ncall takes.\n\n## Rendering & latency\n\nMost scrapes return in well under a second. Some options require ByteKit to fully render the page\nbefore it can return content, which takes longer — typically a few seconds. Pass these only when\nyou need them:\n\n| Option | When it adds latency |\n| ----------------- | -------------------------------------------------------------- |\n| `delay_ms` | Greater than `0` |\n| `solve_challenge` | `true` (can outlast the 28 s hold, so expect a `202` receipt) |\n| `formats` | Includes `outline` |\n| `async` | `true` (the request is queued and processed in the background) |\n\nThe `country` option routes the request through a geo-located proxy. On its own it does not add\nrendering latency; it only does so when combined with one of the options above.\n\nLooking for `wait_for_selector` or `wait_until`? Those are not `ScrapeRequest` options — they\nbelong to the [Screenshot](https://bytekit.com/docs/api/screenshots/createscreenshot) endpoint. Sending them to\n`/v1/scrape` returns `422`.\n\n`cookies` and `headers` are no longer request options on any capture endpoint. Sending either\nreturns `400 validation_error`.\n\n```bash\n# A simple, low-latency scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\n```bash\n# Slower: delay_ms forces a full render and waits before returning\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"delay_ms\": 2000\n }'\n```\n\n## Options\n\nEvery `POST /v1/scrape` option is listed here by the job it does. Only `url` is required. The\n[API reference](https://bytekit.com/docs/api/scrape/createscrape) carries the full request schema.\n\n### Output shaping\n\n- `url` — the page to scrape.\n- `formats` — what to return: any of `raw` (the default), `markdown`, `links`, `images` and `outline`. The\n `formats` object in the response is keyed by what you asked for. `outline` is experimental: an\n indented text accessibility tree of the browser-rendered page. It forces the browser path, adds\n no credits, and is not accepted on monitors.\n- `markdown_mode` — how the page becomes markdown: `article` (the default) extracts the article\n content, `raw` applies minimal cleanup, and `llm` produces compact, LLM-optimised output.\n- `markdown_query` — a BM25 query string (up to 200 characters) that filters the markdown by\n relevance to it. Omit it or leave it empty to disable.\n- `include_tags` and `exclude_tags` — HTML element names (not CSS selectors). `include_tags` keeps\n only the content inside those elements in the `markdown` output; `exclude_tags` strips them from\n it. `include_tags` is applied first, then `exclude_tags`. Neither affects `raw`, which always\n returns the full page.\n- `clean_markdown` — when `true` and `markdown` is in `formats`, the converted markdown is sent to\n an LLM (Groq) to remove boilerplate and ads and improve formatting before it is returned. If that\n step fails for any reason (key unset, 4xx/5xx, timeout, empty response), you get the raw markdown\n unchanged plus a warning in the `warnings` array. Billing is 3× credits and bytes, applied only\n when cleaning succeeds.\n- `markdown_links` — how links are written in the markdown: `inline` (the default) keeps\n `[text](url)`, `text` keeps only the anchor text, `none` strips URLs and removes reference\n definitions, and `references` converts to numbered `[text][N]` references with a Links footer.\n- `markdown_images` — how images are written in the markdown: `inline` (the default) keeps\n `![alt](url)`, `text` keeps only the alt text, `none` removes images entirely, and `references`\n converts to numbered `![alt][N]` references with an Images footer. This is distinct from\n `markdown_filter_images`, which drops low-signal images before conversion.\n- `with_links_summary` and `with_images_summary` — append a `Links:` or `Images:` footer, a\n numbered list of the extracted URLs, to the markdown. `with_links_summary` is enabled\n automatically when `markdown_links` is `references`.\n- `markdown_compact` — collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — filter low-signal images out of the markdown output.\n- `markdown_include_media` — return `formats.links` and `formats.images` as rich scored objects\n instead of string arrays, and include a top-level `tables` array. Only effective when `markdown`\n is in `formats`.\n- `markdown_include_warnings` — enable markdown-pipeline and tag-filter warnings for requests that\n include the `markdown` format. Artifact availability warnings such as `artifact_unavailable` may\n appear independently of this flag.\n- `remove_base64_images` — base64-encoded `data:` image sources are stripped from the HTML before\n markdown conversion (the default, `true`). Set it to `false` to keep them. It does not affect\n `raw`, which always returns the original source unchanged.\n\n### Token control\n\n- `token_budget` — the maximum token count for the markdown output. When set and `markdown` is in\n `formats`, the output is truncated at the last paragraph, then sentence, then token boundary that\n keeps the estimated count under the limit. Leave it out for no truncation. Setting it adds a\n `markdown_tokens` field to the response.\n- `token_encoding` — the tokenizer hint for `token_budget`: `cl100k_base` (the default) matches\n GPT-4/4o and `o200k_base` matches GPT-4o-mini and the o-series. Both use the same 4-characters-\n per-token heuristic internally.\n- `markdown_include_stats` — include a top-level `stats` object (characters, tokens, blocks) in the\n response. Only effective when `markdown` is in `formats`.\n\n### Rendering and access\n\n- `delay_ms` — milliseconds to wait after page load before capturing, for content that renders\n late. See [Rendering & latency](#rendering--latency) above.\n- `country` — a two-letter uppercase country code (default `US`) that routes the request through a\n geo-located proxy.\n- `mobile` — emulate a mobile device: the request uses a mobile (Android) user agent and viewport\n so the upstream serves its mobile page. The default is `false` (desktop). The value is part of\n the cache key, so mobile and desktop responses are cached independently.\n- `solve_challenge` — attempts to clear a Cloudflare challenge. Success is not guaranteed, and it\n is billed as a normal browser render. A synchronous scrape with `solve_challenge: true` takes\n the held browser render; a solve can outlast the hold window (28 seconds by default), and the\n request then returns the `202` receipt while the job continues in the background. Poll\n `GET /v1/scrape/{id}` for the result.\n- `timeout_ms` — the request timeout in milliseconds, from `1000` to `90000` (default `60000`).\n\n### Caching and delivery\n\n- `cache_ttl` — how long a freshly fetched URL may be served from cache. `0` (string or integer)\n skips the cache read, though cache-eligible results are still written. `Nh` or `Nd` sets a TTL,\n capped at 168 h / 7 d. The default is `48h`. Safety-classified WAF husks are returned live but\n never stored in the shared cache. It is honoured on both the synchronous and asynchronous paths.\n- `async` — queue the scrape and get a `202` receipt immediately; see\n [Async scrapes](#async-scrapes) below.\n- `webhook_url` — an HTTPS endpoint to notify. An `http://` URL is rejected with `400 invalid_url`\n (reason `scheme_unsupported`).\n- `events` — which webhook events to deliver when `webhook_url` is set: any of `queued`,\n `completed` and `failed`. All three are delivered by default; send a subset to receive fewer.\n- `custom` — a JSON object of your own, echoed back on the success envelope (sync, async and\n webhook). It is capped at 4096 UTF-8 bytes and does not affect the cache key, so two requests\n that differ only in `custom` resolve to the same cache entry.\n\n### Examples\n\nA markdown scrape trimmed to a token budget, with the response's token statistics:\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"formats\": [\"markdown\"],\n \"markdown_mode\": \"llm\",\n \"token_budget\": 4000,\n \"token_encoding\": \"o200k_base\",\n \"markdown_include_stats\": true\n }'\n```\n\nA content-only scrape: keep the `article` and `main` elements, then strip navigation and footers\nfrom what is left.\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"formats\": [\"markdown\"],\n \"include_tags\": [\"article\", \"main\"],\n \"exclude_tags\": [\"nav\", \"footer\", \"aside\"]\n }'\n```\n\n## Response fields\n\nThe default format is `raw` — pass `formats` to request others (`markdown`, `links`,\n`images`, `outline`). The `formats` object in the response is keyed by the format you requested.\n\nThe `scrape_url` tool in the [MCP server](https://bytekit.com/docs/mcp) differs: it returns markdown when `formats` is\nomitted. A request that includes `markdown` bills the 1.5× `scrape_md` endpoint factor; one that\ndoes not bills 1× (`scrape`). The API default stays `raw` so that omitting `formats` does not\nsilently raise a request's cost.\n\nEnvelope fields are `snake_case`; the keys inside `metadata` are the page's own metadata and\nstay `camelCase`.\n\n| Field | Description |\n| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `schema_version` | Response envelope version (currently `1`) |\n| `formats.raw` | Page content in the requested format (`raw` is the default when `formats` is omitted) |\n| `final_url` | URL the fetch landed on after redirects |\n| `content_type` | `Content-Type` reported by the origin |\n| `content_length` | Compressed wire bytes — the _basis_ for bandwidth billing, before the endpoint factor (see `billing`). A page served by a hosted browser reports the browser's full measured transfer |\n| `status_code` | HTTP status code of the origin page |\n| `retrieved_at` | ISO-8601 UTC timestamp of the fetch |\n| `cache` | `\"hit\"` or `\"miss\"` |\n| `cache_age_s` | Age of the cached entry in seconds — present only on a hit |\n| `billing` | What the request cost: `raw_bytes`, the `factors` applied, the resulting `multiplier`, and `billed_bytes` |\n| `metadata.title` | Page `<title>` element |\n\nThe `X-Scrape-*` response headers describe how each request was handled (cache status, timing,\nand the final URL) — useful for debugging.\n\n## Async scrapes\n\nFor long-running pages, pass `\"async\": true` to get a `202 Accepted` response with a scrape\n`id` prefixed `sc_`. Poll the result with `GET /v1/scrape/{id}`.\n\n```bash\n# Start async scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"async\": true}'\n\n# Poll for result\ncurl https://api.bytekit.com/v1/scrape/sc_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n## Webhook event header\n\nEvery outbound webhook POST includes an `X-ByteKit-Event` header with the event type:\n\n| Event type | Trigger |\n| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |\n| `bulk.completed` | A bulk job finishes (all items processed) |\n| `scrape.completed` | An async scrape succeeds, or a scrape monitor delivers a capture (`has_change` tells a change from a no-change capture) |\n| `scrape.failed` | An async scrape fails terminally |\n| `monitor.change_detected` | A screenshot monitor fires and detects a change |\n| `monitor.captured` | A screenshot monitor fires with no change detected (notify_on: every) |\n| `monitor.suspended` | A monitor is suspended because the account ran out of balance (reason `insufficient_balance`) |\n| `sitemap.completed` | A sitemap job finishes |\n| `sitemap.failed` | A sitemap job fails terminally |\n\nUse this header to dispatch events without inspecting the body shape:\n\n```python\nfrom flask import Flask, request\n\napp = Flask(__name__)\n\n@app.route(\"/webhooks/bytekit\", methods=[\"POST\"])\ndef handle():\n event = request.headers.get(\"X-ByteKit-Event\")\n if event == \"bulk.completed\":\n handle_bulk(request.json)\n elif event == \"scrape.completed\":\n handle_scrape(request.json)\n return \"\", 200\n```\n\n`X-ByteKit-Event` is a reserved header — you cannot supply it via `webhook_headers` in\nmonitor or bulk configuration. Attempts to do so will be rejected with a `422` at request\ntime.\n\n## Next steps\n\n- [Rate Limits](https://bytekit.com/docs/guides/rate-limits) — usage counting and concurrency slots\n- [Errors](https://bytekit.com/docs/guides/errors) — how to interpret and retry error responses\n- [API Reference: Scrape](https://bytekit.com/docs/api/scrape/createscrape) — full request/response schema"
385
+ "body": "# Scraping\n\nScrape any URL as HTML, markdown, or structured content — formats, options, latency, and async polling.\n\n`POST /v1/scrape` fetches a URL and returns its content in the format you ask for. The same\nrequest shape works for every site; the options you pass determine the output and how long the\ncall takes.\n\n## Rendering & latency\n\nMost scrapes return in well under a second. Some options require ByteKit to fully render the page\nbefore it can return content, which takes longer — typically a few seconds. Pass these only when\nyou need them:\n\n| Option | When it adds latency |\n| ----------------- | -------------------------------------------------------------- |\n| `delay_ms` | Greater than `0` |\n| `solve_challenge` | `true` (can outlast the 28 s hold, so expect a `202` receipt) |\n| `formats` | Includes `outline` |\n| `async` | `true` (the request is queued and processed in the background) |\n\nThe `country` option routes the request through a geo-located proxy. On its own it does not add\nrendering latency; it only does so when combined with one of the options above.\n\nLooking for `wait_for_selector` or `wait_until`? Those are not `ScrapeRequest` options — they\nbelong to the [Screenshot](https://bytekit.com/docs/api/screenshots/createscreenshot) endpoint. Sending them to\n`/v1/scrape` returns `422`.\n\n`cookies` and `headers` are no longer request options on any capture endpoint. Sending either\nreturns `400 validation_error`.\n\n```bash\n# A simple, low-latency scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\n```bash\n# Slower: delay_ms forces a full render and waits before returning\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"delay_ms\": 2000\n }'\n```\n\n## Options\n\nEvery `POST /v1/scrape` option is listed here by the job it does. Only `url` is required. The\n[API reference](https://bytekit.com/docs/api/scrape/createscrape) carries the full request schema.\n\n### Output shaping\n\n- `url` — the page to scrape.\n- `formats` — what to return: any of `raw` (the default), `markdown`, `links`, `images` and `outline`. The\n `formats` object in the response is keyed by what you asked for. `outline` is experimental: an\n indented text accessibility tree of the browser-rendered page. It forces the browser path, adds\n no credits, and is not accepted on monitors.\n- `markdown_mode` — how the page becomes markdown: `article` (the default) extracts the article\n content, `raw` applies minimal cleanup, and `llm` produces compact, LLM-optimised output.\n- `markdown_query` — a BM25 query string (up to 200 characters) that filters the markdown by\n relevance to it. Omit it or leave it empty to disable.\n- `include_tags` and `exclude_tags` — HTML element names (not CSS selectors). `include_tags` keeps\n only the content inside those elements in the `markdown` output; `exclude_tags` strips them from\n it. `include_tags` is applied first, then `exclude_tags`. Neither affects `raw`, which always\n returns the full page.\n- `clean_markdown` — when `true` and `markdown` is in `formats`, the converted markdown is sent to\n an LLM (Groq) to remove boilerplate and ads and improve formatting before it is returned. If that\n step fails for any reason (key unset, 4xx/5xx, timeout, empty response), you get the raw markdown\n unchanged plus a warning in the `warnings` array. Billing is 3× credits and bytes, applied only\n when cleaning succeeds.\n- `markdown_links` — how links are written in the markdown: `inline` (the default) keeps\n `[text](url)`, `text` keeps only the anchor text, `none` strips URLs and removes reference\n definitions, and `references` converts to numbered `[text][N]` references with a Links footer.\n- `markdown_images` — how images are written in the markdown: `inline` (the default) keeps\n `![alt](url)`, `text` keeps only the alt text, `none` removes images entirely, and `references`\n converts to numbered `![alt][N]` references with an Images footer. This is distinct from\n `markdown_filter_images`, which drops low-signal images before conversion.\n- `with_links_summary` and `with_images_summary` — append a `Links:` or `Images:` footer, a\n numbered list of the extracted URLs, to the markdown. `with_links_summary` is enabled\n automatically when `markdown_links` is `references`.\n- `markdown_compact` — collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — filter low-signal images out of the markdown output.\n- `markdown_include_media` — return `formats.links` and `formats.images` as rich scored objects\n instead of string arrays, and include a top-level `tables` array. Only effective when `markdown`\n is in `formats`.\n- `markdown_include_warnings` — enable markdown-pipeline and tag-filter warnings for requests that\n include the `markdown` format. Artifact availability warnings such as `artifact_unavailable` may\n appear independently of this flag.\n- `remove_base64_images` — base64-encoded `data:` image sources are stripped from the HTML before\n markdown conversion (the default, `true`). Set it to `false` to keep them. It does not affect\n `raw`, which always returns the original source unchanged.\n\n### Token control\n\n- `token_budget` — the maximum token count for the markdown output. When set and `markdown` is in\n `formats`, the output is truncated at the last paragraph, then sentence, then token boundary that\n keeps the estimated count under the limit. Leave it out for no truncation. Setting it adds a\n `markdown_tokens` field to the response.\n- `token_encoding` — the tokenizer hint for `token_budget`: `cl100k_base` (the default) matches\n GPT-4/4o and `o200k_base` matches GPT-4o-mini and the o-series. Both use the same 4-characters-\n per-token heuristic internally.\n- `markdown_include_stats` — include a top-level `stats` object (characters, tokens, blocks) in the\n response. Only effective when `markdown` is in `formats`.\n\n### Rendering and access\n\n- `delay_ms` — milliseconds to wait after page load before capturing, for content that renders\n late. See [Rendering & latency](#rendering--latency) above.\n- `country` — a two-letter uppercase country code (default `US`) that routes the request through a\n geo-located proxy.\n- `mobile` — ask for the mobile version of the page. A page fetched over plain HTTP is requested\n with a mobile (Android) user agent. A page rendered in a browser renders in a phone-sized window\n but presents a desktop (Windows) browser identity, so a site that checks for a real phone may\n serve its desktop page. The default is `false` (desktop). The value is part of\n the cache key, so mobile and desktop responses are cached independently.\n- `solve_challenge` — attempts to clear a Cloudflare challenge. Success is not guaranteed, and it\n is billed as a normal browser render. A synchronous scrape with `solve_challenge: true` takes\n the held browser render; a solve can outlast the hold window (28 seconds by default), and the\n request then returns the `202` receipt while the job continues in the background. Poll\n `GET /v1/scrape/{id}` for the result.\n- `timeout_ms` — the request timeout in milliseconds, from `1000` to `90000` (default `60000`).\n\n### Caching and delivery\n\n- `cache_ttl` — how long a freshly fetched URL may be served from cache. `0` (string or integer)\n skips the cache read, though cache-eligible results are still written. `Nh` or `Nd` sets a TTL,\n capped at 168 h / 7 d. The default is `48h`. Safety-classified WAF husks are returned live but\n never stored in the shared cache. It is honoured on both the synchronous and asynchronous paths.\n- `async` — queue the scrape and get a `202` receipt immediately; see\n [Async scrapes](#async-scrapes) below.\n- `webhook_url` — an HTTPS endpoint to notify. An `http://` URL is rejected with `400 invalid_url`\n (reason `scheme_unsupported`).\n- `events` — which webhook events to deliver when `webhook_url` is set: any of `queued`,\n `completed` and `failed`. All three are delivered by default; send a subset to receive fewer.\n- `custom` — a JSON object of your own, echoed back on the success envelope (sync, async and\n webhook). It is capped at 4096 UTF-8 bytes and does not affect the cache key, so two requests\n that differ only in `custom` resolve to the same cache entry.\n\n### Examples\n\nA markdown scrape trimmed to a token budget, with the response's token statistics:\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"formats\": [\"markdown\"],\n \"markdown_mode\": \"llm\",\n \"token_budget\": 4000,\n \"token_encoding\": \"o200k_base\",\n \"markdown_include_stats\": true\n }'\n```\n\nA content-only scrape: keep the `article` and `main` elements, then strip navigation and footers\nfrom what is left.\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"formats\": [\"markdown\"],\n \"include_tags\": [\"article\", \"main\"],\n \"exclude_tags\": [\"nav\", \"footer\", \"aside\"]\n }'\n```\n\n## Response fields\n\nThe default format is `raw` — pass `formats` to request others (`markdown`, `links`,\n`images`, `outline`). The `formats` object in the response is keyed by the format you requested.\n\nThe `scrape_url` tool in the [MCP server](https://bytekit.com/docs/mcp) differs: it returns markdown when `formats` is\nomitted. A request that includes `markdown` bills the 1.5× `scrape_md` endpoint factor; one that\ndoes not bills 1× (`scrape`). The API default stays `raw` so that omitting `formats` does not\nsilently raise a request's cost.\n\nEnvelope fields are `snake_case`; the keys inside `metadata` are the page's own metadata and\nstay `camelCase`.\n\n| Field | Description |\n| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `schema_version` | Response envelope version (currently `1`) |\n| `formats.raw` | Page content in the requested format (`raw` is the default when `formats` is omitted) |\n| `final_url` | URL the fetch landed on after redirects |\n| `content_type` | `Content-Type` reported by the origin |\n| `content_length` | Compressed wire bytes — the _basis_ for bandwidth billing, before the endpoint factor (see `billing`). A page served by a hosted browser reports the browser's full measured transfer |\n| `status_code` | HTTP status code of the origin page |\n| `retrieved_at` | ISO-8601 UTC timestamp of the fetch |\n| `cache` | `\"hit\"` or `\"miss\"` |\n| `cache_age_s` | Age of the cached entry in seconds — present only on a hit |\n| `billing` | What the request cost: `raw_bytes`, the `factors` applied, the resulting `multiplier`, and `billed_bytes` |\n| `metadata.title` | Page `<title>` element |\n\nThe `X-Scrape-*` response headers describe how each request was handled (cache status, timing,\nand the final URL) — useful for debugging.\n\n## Async scrapes\n\nFor long-running pages, pass `\"async\": true` to get a `202 Accepted` response with a scrape\n`id` prefixed `sc_`. Poll the result with `GET /v1/scrape/{id}`.\n\n```bash\n# Start async scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"async\": true}'\n\n# Poll for result\ncurl https://api.bytekit.com/v1/scrape/sc_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n## Webhook event header\n\nEvery outbound webhook POST includes an `X-ByteKit-Event` header with the event type:\n\n| Event type | Trigger |\n| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |\n| `bulk.completed` | A bulk job finishes (all items processed) |\n| `scrape.completed` | An async scrape succeeds, or a scrape monitor delivers a capture (`has_change` tells a change from a no-change capture) |\n| `scrape.failed` | An async scrape fails terminally |\n| `monitor.change_detected` | A screenshot monitor fires and detects a change |\n| `monitor.captured` | A screenshot monitor fires with no change detected (notify_on: every) |\n| `monitor.suspended` | A monitor is suspended because the account ran out of balance (reason `insufficient_balance`) |\n| `sitemap.completed` | A sitemap job finishes |\n| `sitemap.failed` | A sitemap job fails terminally |\n\nUse this header to dispatch events without inspecting the body shape:\n\n```python\nfrom flask import Flask, request\n\napp = Flask(__name__)\n\n@app.route(\"/webhooks/bytekit\", methods=[\"POST\"])\ndef handle():\n event = request.headers.get(\"X-ByteKit-Event\")\n if event == \"bulk.completed\":\n handle_bulk(request.json)\n elif event == \"scrape.completed\":\n handle_scrape(request.json)\n return \"\", 200\n```\n\n`X-ByteKit-Event` is a reserved header — you cannot supply it via `webhook_headers` in\nmonitor or bulk configuration. Attempts to do so will be rejected with a `422` at request\ntime.\n\n## Next steps\n\n- [Rate Limits](https://bytekit.com/docs/guides/rate-limits) — usage counting and concurrency slots\n- [Errors](https://bytekit.com/docs/guides/errors) — how to interpret and retry error responses\n- [API Reference: Scrape](https://bytekit.com/docs/api/scrape/createscrape) — full request/response schema"
381
386
  },
382
387
  "guides/screenshots": {
383
388
  "title": "Screenshots",
384
389
  "section": "Guides",
385
- "body": "# Screenshots\n\nCapture a screenshot of any URL — a working request, the options that matter, the response, what it costs, and the errors to handle.\n\n`POST /v1/screenshots` loads a URL in a real browser and returns an image of the page. Send a\nURL and you get back a `jpeg` (the default) or `png`, plus the page title and the image\ndimensions. Everything else — device, viewport, how long to wait, what to hide — is optional.\n\n## Capture a screenshot\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\nBy default the call is **synchronous**: the request is held open for up to 28 seconds and\nreturns `200` with the finished screenshot. The response is JSON — `image_url` is a link to the\nimage, not the image bytes:\n\n```json\n{\n \"id\": \"ss_01a1210c210477f6838a6256629087e6\",\n \"status\": \"completed\",\n \"url\": \"https://example.com\",\n \"image_url\": \"https://<storage-host>/.../screenshot.jpeg?X-Amz-Signature=...\",\n \"page_title\": \"Example Domain\",\n \"image_width\": 1440,\n \"image_height\": 900,\n \"file_size_bytes\": 62635,\n \"credits_charged\": 1,\n \"billing\": {\n \"raw_bytes\": 334,\n \"factors\": [\n {\n \"name\": \"phase1_render\",\n \"value\": 1.5,\n \"reason\": \"phase 1 proxy fetch + render overhead\"\n }\n ],\n \"multiplier\": 1.5,\n \"billed_bytes\": 501\n },\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:23:25.417Z\",\n \"completed_at\": \"2026-10-09T14:23:33.047Z\",\n \"expires_at\": \"2027-10-09T14:23:25.407Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210c210477f6838a6256629087e6\"\n}\n```\n\n> This response was returned by a real request. Two values are edited for the page: the signed `image_url` is shortened, and `poll_url` shows the production\n> host.\n\n| Field | Description |\n| ----------------------------- | ----------------------------------------------------------------------------------------------------------------- |\n| `id` | Screenshot id, prefixed `ss_`. Use it with `GET /v1/screenshots/{id}` |\n| `status` | `pending`, `processing`, `completed`, or `failed` |\n| `image_url` | Signed link to the image. It stays valid for 10 minutes — fetch a fresh one by polling `GET /v1/screenshots/{id}` |\n| `page_title` | The page's `<title>` |\n| `image_width`, `image_height` | Image dimensions in pixels |\n| `file_size_bytes` | Size of the image file. Informational only — it is not what you are billed on (see [Cost](#cost)) |\n| `billing` | What the capture was billed: `raw_bytes`, the `factors` applied, the resulting `multiplier`, and `billed_bytes` |\n| `error_code`, `error_message` | Why a capture failed. `null` on success |\n| `expires_at` | When the stored image expires |\n| `poll_url` | Where to poll this screenshot |\n\nThe `200` response also carries `X-Screenshot-*` headers (the same id, status and timestamps as\nthe JSON) and `X-Quota-*` headers reporting your quota.\n\nIf the capture is still running when the 28 seconds are up, the call returns `202` with\n`status: \"processing\"` and the same `id`. The capture keeps running in the background — poll it\nas described in [Async captures](#async-captures).\n\n## Options\n\nSend any of these alongside `url`. All are optional and the defaults suit most pages. Unknown\nfields are rejected with `422 validation_error`.\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"format\": \"png\",\n \"viewport\": {\"width\": 1280, \"height\": 720},\n \"dark_mode\": true,\n \"wait_until\": \"networkidle\"\n }'\n```\n\n> This request was run for real and returned `200` with\n> `\"image_width\": 1280` and `\"image_height\": 720`.\n\n**Output**\n\n| Option | Default | Description |\n| --------------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |\n| `format` | `jpeg` | Image format: `jpeg` or `png` |\n| `quality` | `80` | Image quality, an integer from `1` to `100` |\n| `full_page` | `false` | Capture the whole scrollable page instead of only the viewport |\n| `clip` | `null` | Capture only a region: `{\"x\": 0, \"y\": 0, \"width\": 800, \"height\": 600}` in pixels (`width` and `height` at least `1`) |\n| `device_scale_factor` | `null` | Pixel density: `1` or `2` (`2` for a retina-sharp image) |\n\n**Device**\n\n| Option | Default | Description |\n| ----------- | --------- | --------------------------------------------------------------------------------------------- |\n| `device` | `desktop` | `desktop` or `mobile` |\n| `viewport` | `null` | Browser window size, `{\"width\": 1280, \"height\": 720}` in pixels. Overrides the device default |\n| `dark_mode` | `false` | Render the page with a dark colour scheme preference |\n\n**Page readiness**\n\n| Option | Default | Description |\n| ------------------- | ------- | ------------------------------------------------------------------------------ |\n| `wait_until` | `load` | Navigation event to wait for: `load`, `domcontentloaded`, or `networkidle` |\n| `wait_for_selector` | `null` | CSS selector that must be visible before the capture is taken |\n| `delay_ms` | `0` | Extra wait after the page is ready, in milliseconds (`0` to `10000`) |\n| `scroll` | `true` | Scroll the page to the bottom before capturing, so lazy-loaded content appears |\n\n`wait_until` and `wait_for_selector` are Screenshot options. They are not `POST /v1/scrape`\noptions — sending either there returns `422`. See the [Scraping guide](https://bytekit.com/docs/guides/scraping).\n\n**Clean-up**\n\n| Option | Default | Description |\n| ---------------------- | ------- | --------------------------- |\n| `block_ads` | `true` | Block ads on the page |\n| `block_cookie_banners` | `true` | Hide cookie-consent banners |\n\n**Geo and language**\n\n| Option | Default | Description |\n| ---------- | ------- | ---------------------------------------------------------------------------------- |\n| `country` | `US` | Two-letter, upper-case country code the page is requested from |\n| `language` | `null` | Browser language, for example `de-DE`. When `null`, the language follows `country` |\n\n**Other**\n\n| Option | Default | Description |\n| -------------- | ------- | ----------------------------------------------------------------------------------------------------------- |\n| `include_html` | `false` | Also capture the page's rendered HTML alongside the image. The HTML is not returned in the response |\n| `metadata` | `{}` | Your own key-value pairs to attach to the capture. At most 4096 bytes as JSON; keys must not start with `_` |\n\n`cookies` and `headers` are not request options on any capture endpoint. Sending either returns\n`400 validation_error`.\n\n## Async captures\n\nFor pages that take a while, add `?async=true` to the URL, or send `\"async\": true` in the request\nbody. Either one is enough, and `false` in one never cancels `true` in the other. The call returns\n`202` immediately with an `ss_` id and `status: \"pending\"`, and the capture runs in the background.\n`POST /v1/scrape` accepts the same two spellings.\n\n```bash\n# Start an async capture\ncurl -X POST \"https://api.bytekit.com/v1/screenshots?async=true\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n\n# Poll for the result\ncurl https://api.bytekit.com/v1/screenshots/ss_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\nThe first call returns:\n\n```json\n{\n \"id\": \"ss_01a1210d0e3a719589e9c3d70c4791d2\",\n \"status\": \"pending\",\n \"url\": \"https://example.com\",\n \"image_url\": null,\n \"page_title\": null,\n \"image_width\": null,\n \"image_height\": null,\n \"file_size_bytes\": null,\n \"credits_charged\": 1,\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:24:26.172Z\",\n \"completed_at\": null,\n \"expires_at\": \"2027-10-09T14:24:26.149Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210d0e3a719589e9c3d70c4791d2\"\n}\n```\n\n> This response was returned by a real request; `poll_url` shows the production host.\n\n`GET /v1/screenshots/{id}` answers by state:\n\n| State | Status | Body |\n| ------------------------------- | ------ | ---------------------------------------------------------------------- |\n| Still `pending` or `processing` | `202` | The screenshot resource; poll again |\n| `completed` | `200` | The full screenshot resource, with a fresh signed `image_url` |\n| `failed` | `200` | The [error envelope](https://bytekit.com/docs/guides/errors), with the failure in `error.code` |\n\nA failed capture is a successfully retrieved terminal state, so check `status` before reading\n`image_url`.\n\n## Cost\n\nScreenshots are billed on bandwidth, not credits. A capture is billed on the bytes of the\ninitial page fetch, multiplied by 1.5 — the extra 0.5 covers rendering the page. The size of the\nimage file is not the basis. If that initial fetch is skipped or fails, the capture bills nothing.\n\nIn the example above, the page fetch transferred 334 bytes (`raw_bytes`), so the capture was\nbilled 501 bytes (`billed_bytes`). The `billing` object is the authoritative breakdown; its\n`factors[].reason` text is descriptive and may change, so read `value` and `multiplier` rather\nthan parsing it. The same figures arrive in the `X-Raw-Bytes`, `X-Billing-Multiplier`, and\n`X-Billable-Bytes` response headers.\n\nThe `credits_charged` field and the `X-Screenshot-Credits-Charged` header carry a legacy weight\n(`1`, `2` or `4`, doubling for `full_page` and again for retina or mobile). It is recorded for\nreporting only and is not what you are billed. For how capture bandwidth is billed,\nsee [Bandwidth billing](https://bytekit.com/docs/billing/bandwidth).\n\n## Errors\n\nErrors use the unified envelope described in the [Errors guide](https://bytekit.com/docs/guides/errors). These are the\nones you are most likely to meet on this endpoint:\n\n| Status | Code | When | Retry? |\n| ------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ |\n| `400` | `invalid_url` | `url` is not a valid HTTP(S) URL. `error.details.reason` says why, for example `scheme_unsupported` | No — fix the URL |\n| `400` | `request_too_large` | The request body is over 512 KB | No — send a smaller body |\n| `401` | `unauthorized`, `invalid_api_key` | The API key is missing, malformed, or not valid | No — check your key |\n| `400` | `validation_error` | The request carries a removed field such as `cookies` or `headers` | No — remove the field |\n| `402` | `quota_exceeded` | The balance cannot fund the capture. `error.details.required_bytes` and `available_bytes` give the numbers | No — add balance or upgrade |\n| `402` | `spending_cap_reached`, `billing_entitlement_impaired`, `billing_entitlement_expired` | The spending cap or the subscription state blocks the request — see the [Errors guide](https://bytekit.com/docs/guides/errors) | No — resolve the billing state first |\n| `403` | `host_forbidden`, `path_forbidden` | The URL's host or path is not allowed as a capture target | No — use a different URL |\n| `422` | `validation_error` | A field failed validation (`error.details` names the field), an unknown field was sent, or the body is not valid JSON (no `details`) | No — fix the request |\n| `422` | `blocked`, `timeout`, … | The capture ran and failed inside the 28-second hold. The body is the screenshot resource, with `error_code` and `error_message` set | Possibly — a retry is a new capture |\n| `429` | `rate_limited` | Too many requests per second | Yes — wait for the `Retry-After` header, then back off |\n| `429` | `concurrency_limit` | Too many captures in flight at once | Yes — wait for the `Retry-After` header |\n| `404` | `not_found` | `GET /v1/screenshots/{id}` for an id that does not exist on your account \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 17580 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/screenshots]"
390
+ "body": "# Screenshots\n\nCapture a screenshot of any URL — a working request, the options that matter, the response, what it costs, and the errors to handle.\n\n`POST /v1/screenshots` loads a URL in a real browser and returns an image of the page. Send a\nURL and you get back a `jpeg` (the default) or `png`, plus the page title and the image\ndimensions. Everything else — device, viewport, how long to wait, what to hide — is optional.\n\n## Capture a screenshot\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\nBy default the call is **synchronous**: the request is held open for up to 28 seconds and\nreturns `200` with the finished screenshot. The response is JSON — `image_url` is a link to the\nimage, not the image bytes:\n\n```json\n{\n \"id\": \"ss_01a1210c210477f6838a6256629087e6\",\n \"status\": \"completed\",\n \"url\": \"https://example.com\",\n \"image_url\": \"https://<storage-host>/.../screenshot.jpeg?X-Amz-Signature=...\",\n \"page_title\": \"Example Domain\",\n \"image_width\": 1440,\n \"image_height\": 900,\n \"file_size_bytes\": 62635,\n \"credits_charged\": 1,\n \"billing\": {\n \"raw_bytes\": 334,\n \"factors\": [\n {\n \"name\": \"phase1_render\",\n \"value\": 1.5,\n \"reason\": \"phase 1 proxy fetch + render overhead\"\n }\n ],\n \"multiplier\": 1.5,\n \"billed_bytes\": 501\n },\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:23:25.417Z\",\n \"completed_at\": \"2026-10-09T14:23:33.047Z\",\n \"expires_at\": \"2027-10-09T14:23:25.407Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210c210477f6838a6256629087e6\"\n}\n```\n\n> This response was returned by a real request. Two values are edited for the page: the signed `image_url` is shortened, and `poll_url` shows the production\n> host.\n\n| Field | Description |\n| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `id` | Screenshot id, prefixed `ss_`. Use it with `GET /v1/screenshots/{id}` |\n| `status` | `pending`, `processing`, `completed`, or `failed` |\n| `image_url` | Signed link to the image. It stays valid for 10 minutes — fetch a fresh one by polling `GET /v1/screenshots/{id}` |\n| `page_title` | The page's `<title>` |\n| `image_width`, `image_height` | Image dimensions in pixels |\n| `file_size_bytes` | Size of the image file. Informational only — it is not what you are billed on (see [Cost](#cost)) |\n| `billing` | What the capture was billed: `raw_bytes`, the `factors` applied, the resulting `multiplier`, and `billed_bytes` |\n| `error_code`, `error_message` | Why a capture failed. `null` on success. On `pending` or `processing`, a set value is the last failed attempt's error while the capture is retried; on `failed`, it is the final cause |\n| `expires_at` | When the stored image expires |\n| `poll_url` | Where to poll this screenshot |\n\nThe `200` response also carries `X-Screenshot-*` headers (the same id, status and timestamps as\nthe JSON) and `X-Quota-*` headers reporting your quota.\n\nIf the capture is still running when the 28 seconds are up, the call returns `202` with\n`status: \"processing\"` and the same `id`. The capture keeps running in the background — poll it\nas described in [Async captures](#async-captures).\n\n## Options\n\nSend any of these alongside `url`. All are optional and the defaults suit most pages. Unknown\nfields are rejected with `422 validation_error`.\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"format\": \"png\",\n \"viewport\": {\"width\": 1280, \"height\": 720},\n \"dark_mode\": true,\n \"wait_until\": \"networkidle\"\n }'\n```\n\n> This request was run for real and returned `200` with\n> `\"image_width\": 1280` and `\"image_height\": 720`.\n\n**Output**\n\n| Option | Default | Description |\n| --------------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |\n| `format` | `jpeg` | Image format: `jpeg` or `png` |\n| `quality` | `80` | Image quality, an integer from `1` to `100` |\n| `full_page` | `false` | Capture the whole scrollable page instead of only the viewport |\n| `clip` | `null` | Capture only a region: `{\"x\": 0, \"y\": 0, \"width\": 800, \"height\": 600}` in pixels (`width` and `height` at least `1`) |\n| `device_scale_factor` | `null` | Pixel density: `1` or `null`; any other value is a 422 `validation_error` |\n\n**Device**\n\n| Option | Default | Description |\n| ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `device` | `desktop` | `desktop` or `mobile` |\n| `viewport` | `null` | Browser window size, `{\"width\": 1280, \"height\": 720}` in pixels. Overrides the device default. Width 360 to 2544, height 1 to 1297; any other size is a 422 `validation_error` |\n| `dark_mode` | `false` | Render the page with a dark colour scheme preference |\n\n**Page readiness**\n\n| Option | Default | Description |\n| ------------------- | ------- | ------------------------------------------------------------------------------ |\n| `wait_until` | `load` | Navigation event to wait for: `load`, `domcontentloaded`, or `networkidle` |\n| `wait_for_selector` | `null` | CSS selector that must be visible before the capture is taken |\n| `delay_ms` | `0` | Extra wait after the page is ready, in milliseconds (`0` to `10000`) |\n| `scroll` | `true` | Scroll the page to the bottom before capturing, so lazy-loaded content appears |\n\n`wait_until` and `wait_for_selector` are Screenshot options. They are not `POST /v1/scrape`\noptions — sending either there returns `422`. See the [Scraping guide](https://bytekit.com/docs/guides/scraping).\n\n**Clean-up**\n\n| Option | Default | Description |\n| ---------------------- | ------- | --------------------------- |\n| `block_ads` | `true` | Block ads on the page |\n| `block_cookie_banners` | `true` | Hide cookie-consent banners |\n\n**Geo and language**\n\n| Option | Default | Description |\n| ---------- | ------- | ---------------------------------------------------------------------------------- |\n| `country` | `US` | Two-letter, upper-case country code the page is requested from |\n| `language` | `null` | Browser language, for example `de-DE`. When `null`, the language follows `country` |\n\n**Other**\n\n| Option | Default | Description |\n| -------------- | ------- | ----------------------------------------------------------------------------------------------------------- |\n| `include_html` | `false` | Also capture the page's rendered HTML alongside the image. The HTML is not returned in the response |\n| `metadata` | `{}` | Your own key-value pairs to attach to the capture. At most 4096 bytes as JSON; keys must not start with `_` |\n\n`cookies` and `headers` are not request options on any capture endpoint. Sending either returns\n`400 validation_error`.\n\n## Async captures\n\nFor pages that take a while, add `?async=true` to the URL, or send `\"async\": true` in the request\nbody. Either one is enough, and `false` in one never cancels `true` in the other. The call returns\n`202` immediately with an `ss_` id and `status: \"pending\"`, and the capture runs in the background.\n`POST /v1/scrape` accepts the same two spellings.\n\n```bash\n# Start an async capture\ncurl -X POST \"https://api.bytekit.com/v1/screenshots?async=true\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n\n# Poll for the result\ncurl https://api.bytekit.com/v1/screenshots/ss_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\nThe first call returns:\n\n```json\n{\n \"id\": \"ss_01a1210d0e3a719589e9c3d70c4791d2\",\n \"status\": \"pending\",\n \"url\": \"https://example.com\",\n \"image_url\": null,\n \"page_title\": null,\n \"image_width\": null,\n \"image_height\": null,\n \"file_size_bytes\": null,\n \"credits_charged\": 1,\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:24:26.172Z\",\n \"completed_at\": null,\n \"expires_at\": \"2027-10-09T14:24:26.149Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210d0e3a719589e9c3d70c4791d2\"\n}\n```\n\n> This response was returned by a real request; `poll_url` shows the production host.\n\n`GET /v1/screenshots/{id}` answers by state:\n\n| State | Status | Body |\n| ------------------------------- | ------ | ---------------------------------------------------------------------- |\n| Still `pending` or `processing` | `202` | The screenshot resource; poll again |\n| `completed` | `200` | The full screenshot resource, with a fresh signed `image_url` |\n| `failed` | `200` | The [error envelope](https://bytekit.com/docs/guides/errors), with the failure in `error.code` |\n\nA failed capture is a successfully retrieved terminal state, so check `status` before reading\n`image_url`.\n\n## Pages that are not HTML\n\nA URL that serves text-like content — plain text, JSON, XML — is captured as the browser displays\nit and billed as usual. A URL that serves anything else, such as an image, a PDF or binary data,\nfails with `unsupported_content_type` on its first attempt, is not retried, and bills nothing.\n\n## Cost\n\nScreenshots are billed on bandwidth, not credits. A capture is billed on the bytes of the\ninitial page fetch, multiplied by 1.5 — the extra 0.5 covers rendering the page. The size of the\nimage file is not the basis. If that initial fetch is skipped or fails, the capture bills nothing.\n\nIn the example above, the page fetch transferred 334 bytes (`raw_bytes`), so the capture was\nbilled 501 bytes (`billed_bytes`). The `billing` object is the authoritative breakdown; its\n`factors[].reason` text is descriptive and may change, so read `value` and `multiplier` rather\nthan parsing it. The same figures arrive in the `X-Raw-Bytes`, `X-Billing-Multiplier`, and\n`X-Billable-Bytes` response headers.\n\nThe `credits_charged` field and the `X-Screenshot-Credits-Charged` header carry a legacy weight\n(`1`, `2` or `4`, doubling for `full_page` and again for mobile). It is recorded for\nreporting only and is not what you are billed. For how capture bandwidth is billed,\nsee [Bandwidth billing](https://bytekit.com/docs/billing/bandwidth).\n\n## Errors\n\nErrors use the unified envelope described in the [Errors guide](https://bytekit.com/docs/guides/errors). These are the\nones you are most likely to meet on this endpoint:\n\n| Status | Code | When | Retry? |\n| ------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ |\n| `400` | `invalid_url` | `url` is not a valid HTTP(S) URL. `error.details.reason` says why, for example `scheme_unsupported` | No — fix the URL |\n| `400` | `request_too_large` | The request body is over 512 KB | No — send a smaller body |\n| `401` | `unauthorized`, `invalid_api_key` | The API key is missing, malformed, or not valid | No — check your key |\n| `400` | `validation_error` | The request carries a removed field such as `cookies` or `headers` | No — remove the field |\n| `402` | `quota_exceeded` | The balance cannot fund the capture. `error.details.required_bytes` and `available_bytes` give the numbers | No — add balance or upgrade |\n| `402` | `spending_cap_reached`, `billing_entitlement_impaired`, `billing_entitlement_expired` | The spending cap or the subscription state blocks the request — see the [Errors guide](https://bytekit.com/docs/guides/errors) | No — resolve the billing state first |\n| `403` | `host_forbidden`, `path_forbidden` | The URL's host \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 19126 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/screenshots]"
386
391
  },
387
392
  "guides/search": {
388
393
  "title": "Search",
@@ -472,12 +477,12 @@
472
477
  "sdk/python/monitors": {
473
478
  "title": "Monitors",
474
479
  "section": "SDK Reference",
475
- "body": "# Monitors\n\nFunctions for interacting with the `monitors` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\nFirst-capture behavior is the same for both monitor types: the first capture is a silent baseline (`has_change=False`, `change_pct=None`) with no `change_detected` webhook, whether the monitor is `scrape` or `screenshot`. From the second capture onward both types diff against the previous capture.\n\n## Create Monitor\n\nCreate a change-detection monitor\n\nCreates a recurring change-detection monitor for a URL, delivering results via webhook.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (MonitorCreateRequest)`\n- `url` — `str`\n- `interval_type` — `MonitorCreateRequestIntervalType`\n- `webhook_url` — `str` — Webhook endpoint URL (HTTPS only; http:// rejected with 400 invalid_url, reason scheme_unsupported)\n- `type_` — `MonitorCreateRequestType | Unset`\n- `cron_expression` — `str | Unset` — 5-field cron expression. Required when interval_type is \"cron\".\n- `change_threshold` — `float | Unset`\n- `notify_on` — `MonitorCreateRequestNotifyOn | Unset`\n- `webhook_secret` — `str | Unset` — HMAC secret used to sign webhook deliveries. Each delivery carries `X-Webhook- Timestamp` and `X-Webhook-Signature` (`sha256=` + the hex HMAC-SHA256 of `timestamp.body`). See https://bytekit.com/docs/guides/webhooks for verification code.\n- `webhook_headers` — `MonitorCreateRequestWebhookHeaders | Unset` — Max 20 headers. Keys must match /^[A-Za-z0-9-]+$/ and not be reserved.\n- `options` — `MonitorCreateRequestOptions | Unset` — Screenshot monitor options (device, viewport, format, etc.).\n- `scrape_options` — `MonitorCreateRequestScrapeOptions | Unset` — Scrape monitor options (formats, country, wait_for_selector, wait_until, delay_ms). Only for type=scrape.\n- `metadata` — `Metadata | Unset` — Arbitrary key-value metadata. Max 4096 bytes when JSON-serialized.\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Error | MonitorCreateResponse]\nsync(client=client, body=body) -> Error | MonitorCreateResponse | None\nawait asyncio_detailed(client=client, body=body) -> Response[Error | MonitorCreateResponse]\nawait asyncio(client=client, body=body) -> Error | MonitorCreateResponse | None\n```\n\n## Delete Monitor\n\nCancel monitor\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Any | Error]\nsync(id=id, client=client) -> Any | Error | None\nawait asyncio_detailed(id=id, client=client) -> Response[Any | Error]\nawait asyncio(id=id, client=client) -> Any | Error | None\n```\n\n## Get Monitor\n\nGet monitor\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Error | MonitorResponse]\nsync(id=id, client=client) -> Error | MonitorResponse | None\nawait asyncio_detailed(id=id, client=client) -> Response[Error | MonitorResponse]\nawait asyncio(id=id, client=client) -> Error | MonitorResponse | None\n```\n\n## List Monitor Captures\n\nList monitor captures\n\n**Parameters**\n\n- `id (str)`\n- `limit (int | Unset)`\n- `cursor (str | Unset)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client, limit=limit, cursor=cursor) -> Response[Error | ListMonitorCapturesResponse200]\nsync(id=id, client=client, limit=limit, cursor=cursor) -> Error | ListMonitorCapturesResponse200 | None\nawait asyncio_detailed(id=id, client=client, limit=limit, cursor=cursor) -> Response[Error | ListMonitorCapturesResponse200]\nawait asyncio(id=id, client=client, limit=limit, cursor=cursor) -> Error | ListMonitorCapturesResponse200 | None\n```\n\n## List Monitors\n\nList monitors\n\n**Parameters**\n\n- `limit (int | Unset)`\n- `cursor (str | Unset)`\n- `status (ListMonitorsStatus | Unset)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, limit=limit, cursor=cursor, status=status) -> Response[Error | ListMonitorsResponse200]\nsync(client=client, limit=limit, cursor=cursor, status=status) -> Error | ListMonitorsResponse200 | None\nawait asyncio_detailed(client=client, limit=limit, cursor=cursor, status=status) -> Response[Error | ListMonitorsResponse200]\nawait asyncio(client=client, limit=limit, cursor=cursor, status=status) -> Error | ListMonitorsResponse200 | None\n```\n\n## Update Monitor\n\nUpdate monitor\n\n**Parameters**\n\n- `id (str)`\n- `body (MonitorUpdateRequest)`\n- `url` — `str | Unset`\n- `interval_type` — `MonitorUpdateRequestIntervalType | Unset`\n- `cron_expression` — `str | Unset`\n- `change_threshold` — `float | Unset`\n- `notify_on` — `MonitorUpdateRequestNotifyOn | Unset`\n- `webhook_url` — `str | Unset` — Webhook endpoint URL (HTTPS only; http:// rejected with 400 invalid_url, reason scheme_unsupported)\n- `webhook_secret` — `str | Unset` — HMAC secret used to sign webhook deliveries. Each delivery carries `X-Webhook- Timestamp` and `X-Webhook-Signature` (`sha256=` + the hex HMAC-SHA256 of `timestamp.body`). See https://bytekit.com/docs/guides/webhooks for verification code.\n- `webhook_headers` — `MonitorUpdateRequestWebhookHeaders | Unset`\n- `status` — `MonitorUpdateRequestStatus | Unset`\n- `options` — `MonitorUpdateRequestOptions | Unset`\n- `scrape_options` — `MonitorUpdateRequestScrapeOptions | Unset`\n- `metadata` — `Metadata | Unset` — Arbitrary key-value metadata. Max 4096 bytes when JSON-serialized.\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client, body=body) -> Response[Error | MonitorResponse]\nsync(id=id, client=client, body=body) -> Error | MonitorResponse | None\nawait asyncio_detailed(id=id, client=client, body=body) -> Response[Error | MonitorResponse]\nawait asyncio(id=id, client=client, body=body) -> Error | MonitorResponse | None\n```"
480
+ "body": "# Monitors\n\nFunctions for interacting with the `monitors` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\nFirst-capture behavior is the same for both monitor types: the first capture is a silent baseline (`has_change=False`, `change_pct=None`) with no `change_detected` webhook, whether the monitor is `scrape` or `screenshot`. From the second capture onward both types diff against the previous capture.\n\n## Create Monitor\n\nCreate a change-detection monitor\n\nCreates a recurring change-detection monitor for a URL, delivering results via webhook.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (MonitorCreateRequest)`\n- `url` — `str`\n- `interval_type` — `MonitorCreateRequestIntervalType`\n- `webhook_url` — `str` — Webhook endpoint URL (HTTPS only; http:// rejected with 400 invalid_url, reason scheme_unsupported)\n- `type_` — `MonitorCreateRequestType | Unset`\n- `cron_expression` — `str | Unset` — 5-field cron expression. Required when interval_type is \"cron\".\n- `change_threshold` — `float | Unset`\n- `notify_on` — `MonitorCreateRequestNotifyOn | Unset`\n- `webhook_secret` — `str | Unset` — HMAC secret used to sign webhook deliveries. Each delivery carries `X-Webhook- Timestamp` and `X-Webhook-Signature` (`sha256=` + the hex HMAC-SHA256 of `timestamp.body`). See https://bytekit.com/docs/guides/webhooks for verification code.\n- `webhook_headers` — `MonitorCreateRequestWebhookHeaders | Unset` — Max 20 headers. Keys must match /^[A-Za-z0-9-]+$/ and not be reserved.\n- `options` — `MonitorCreateRequestOptions | Unset` — Screenshot monitor options (device, viewport, format, etc.). `viewport` width is 360 to 2544 and height 1 to 1297; a size outside them is a 422 `validation_error`.\n- `scrape_options` — `MonitorCreateRequestScrapeOptions | Unset` — Scrape monitor options (formats, country, wait_for_selector, wait_until, delay_ms). Only for type=scrape.\n- `metadata` — `Metadata | Unset` — Arbitrary key-value metadata. Max 4096 bytes when JSON-serialized.\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Error | MonitorCreateResponse]\nsync(client=client, body=body) -> Error | MonitorCreateResponse | None\nawait asyncio_detailed(client=client, body=body) -> Response[Error | MonitorCreateResponse]\nawait asyncio(client=client, body=body) -> Error | MonitorCreateResponse | None\n```\n\n## Delete Monitor\n\nCancel monitor\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Any | Error]\nsync(id=id, client=client) -> Any | Error | None\nawait asyncio_detailed(id=id, client=client) -> Response[Any | Error]\nawait asyncio(id=id, client=client) -> Any | Error | None\n```\n\n## Get Monitor\n\nGet monitor\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Error | MonitorResponse]\nsync(id=id, client=client) -> Error | MonitorResponse | None\nawait asyncio_detailed(id=id, client=client) -> Response[Error | MonitorResponse]\nawait asyncio(id=id, client=client) -> Error | MonitorResponse | None\n```\n\n## List Monitor Captures\n\nList monitor captures\n\n**Parameters**\n\n- `id (str)`\n- `limit (int | Unset)`\n- `cursor (str | Unset)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client, limit=limit, cursor=cursor) -> Response[Error | ListMonitorCapturesResponse200]\nsync(id=id, client=client, limit=limit, cursor=cursor) -> Error | ListMonitorCapturesResponse200 | None\nawait asyncio_detailed(id=id, client=client, limit=limit, cursor=cursor) -> Response[Error | ListMonitorCapturesResponse200]\nawait asyncio(id=id, client=client, limit=limit, cursor=cursor) -> Error | ListMonitorCapturesResponse200 | None\n```\n\n## List Monitors\n\nList monitors\n\n**Parameters**\n\n- `limit (int | Unset)`\n- `cursor (str | Unset)`\n- `status (ListMonitorsStatus | Unset)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, limit=limit, cursor=cursor, status=status) -> Response[Error | ListMonitorsResponse200]\nsync(client=client, limit=limit, cursor=cursor, status=status) -> Error | ListMonitorsResponse200 | None\nawait asyncio_detailed(client=client, limit=limit, cursor=cursor, status=status) -> Response[Error | ListMonitorsResponse200]\nawait asyncio(client=client, limit=limit, cursor=cursor, status=status) -> Error | ListMonitorsResponse200 | None\n```\n\n## Update Monitor\n\nUpdate monitor\n\n**Parameters**\n\n- `id (str)`\n- `body (MonitorUpdateRequest)`\n- `url` — `str | Unset`\n- `interval_type` — `MonitorUpdateRequestIntervalType | Unset`\n- `cron_expression` — `str | Unset`\n- `change_threshold` — `float | Unset`\n- `notify_on` — `MonitorUpdateRequestNotifyOn | Unset`\n- `webhook_url` — `str | Unset` — Webhook endpoint URL (HTTPS only; http:// rejected with 400 invalid_url, reason scheme_unsupported)\n- `webhook_secret` — `str | Unset` — HMAC secret used to sign webhook deliveries. Each delivery carries `X-Webhook- Timestamp` and `X-Webhook-Signature` (`sha256=` + the hex HMAC-SHA256 of `timestamp.body`). See https://bytekit.com/docs/guides/webhooks for verification code.\n- `webhook_headers` — `MonitorUpdateRequestWebhookHeaders | Unset`\n- `status` — `MonitorUpdateRequestStatus | Unset`\n- `options` — `MonitorUpdateRequestOptions | Unset` — Screenshot monitor options. `viewport` width is 360 to 2544 and height 1 to 1297; a size outside them is a 422 `validation_error`.\n- `scrape_options` — `MonitorUpdateRequestScrapeOptions | Unset`\n- `metadata` — `Metadata | Unset` — Arbitrary key-value metadata. Max 4096 bytes when JSON-serialized.\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client, body=body) -> Response[Error | MonitorResponse]\nsync(id=id, client=client, body=body) -> Error | MonitorResponse | None\nawait asyncio_detailed(id=id, client=client, body=body) -> Response[Error | MonitorResponse]\nawait asyncio(id=id, client=client, body=body) -> Error | MonitorResponse | None\n```"
476
481
  },
477
482
  "sdk/python/scrape": {
478
483
  "title": "Scrape",
479
484
  "section": "SDK Reference",
480
- "body": "# Scrape\n\nFunctions for interacting with the `scrape` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Scrape\n\nScrape a URL\n\nFetches and processes a URL, returning content in one or more formats wrapped in a ScrapeEnvelope.\n\n**The response shape is decided by your request, not by how we route it.** In precedence order:\n\n1. `async: true` in the body, or `?async=true` in the query string (either one is enough; `false` in\none never cancels `true` in the other) → **202** with a `ScrapeQueuedEnvelope` receipt, returned\nimmediately. Poll `GET /v1/scrape/\\{id\\}` for the result.\n2. Otherwise, a request that needs a full page render — today that is any of `delay_ms > 0`,\n`solve_challenge: true`, or `outline` in `formats` — is **held open** until the render reaches a\nterminal state, then returns **200** with the content envelope (`success` or `failed`). If the\nrender is still running when the hold window expires (28 seconds by default), the request returns\nthe **202** receipt instead and the job continues in the background. A `solve_challenge` render can\noutlast the hold window, so expect the 202 receipt from such a request.\n3. Otherwise the request is served by the fast HTTP path and returns **200** with the content\nenvelope, typically in under a second.\n\n**A failed fetch is a result, not a transport error.** An unreachable host, a refused connection, or\na target whose bot protection defeats every proxy tier all come back on the same **200** as a\n`failed` envelope — never a 5xx. Narrow on the envelope's `status` before reading the body. A\nfailure the fast path decides inline is recorded as a failed job, so its envelope normally carries\nthat job's `id` and `GET /v1/scrape/\\{id\\}` returns the same envelope; if recording the failed job\nitself fails, the envelope still arrives on the same 200 with `id` set to `null` and there is\nnothing to poll. A failure a held render reaches carries that render's real `id`. Either way the\nrequest transfers no billable bytes and is charged nothing.\n\n**A target that rate-limits us is not ByteKit rate-limiting you.** The `failed` envelope's\n`error.code` is `target_rate_limited` when the target rate-limits the request. On the fast path that\nmeans our proxy attempts end on an HTTP 429 and no bot protection is identified on any attempt, even\nif the browser fallback then fails or reaches only an unidentified block page; the inline failure\ncarries `error.retry_after_seconds` when the target sent a usable `Retry-After`. On a held render\nthe browser's own answer decides: it observes a 429 on the page itself, or it fails outright after\nthe proxy attempts ended on an HTTP 429. A bot-protection verdict on an earlier fetch attempt does\nnot keep a held render `blocked` when the browser then observes the 429. A held render never carries\n`error.retry_after_seconds`. Retrying a `target_rate_limited` failure later is likely to work. A\nheld render whose browser reaches an unidentified 403 or 503 page after a proxy 429 is `blocked`. A\n429 that bot protection sends as a block stays `blocked` when it is the answer that decides the\ncode: the fast path's proxy attempts, or the browser render on a held render. Your own per-key limit\nis a separate case: it answers HTTP 429 `rate_limited` with a `Retry-After` header (see the `429`\nresponse).\n\nSo a 202 means one of exactly two things: you asked for one with `async: true` or `?async=true`, or\nthe hold window expired. `wait_for_selector` and `wait_until` are `ScreenshotRequest` options, not\n`ScrapeRequest` options — sending either to this endpoint returns `422 validation_error`, so neither\ncan produce a 202 here.\n\n**Parameters**\n\n- `async_ (bool | Unset)`\n- `body (ScrapeRequest)`\n- `url` — `str`\n- `formats` — `list[ScrapeRequestFormatsItem | ScrapeRequestJsonFormat] | Unset` — What to return. Each entry is either a string format (`raw`, `markdown`, `links` or `images`) or a `json` object entry that extracts structured data from the page. The string `\"json\"` is not a format value; the `json` entry is an object, described by `ScrapeRequestJsonFormat`. A list may hold at most one `json` entry, and a list holding only the `json` entry still captures `raw`. The `json` entry is accepted on `POST /v1/scrape`, `POST /v1/scrape/bulk` and `POST /v1/bulk` (scrape entries); monitor `formats` accept the string formats alone. Its result is `formats.json` on the response, and its charge is described on `ScrapeRequestJsonFormat`.\n- `country` — `str | Unset`\n- `delay_ms` — `int | Unset` — Milliseconds to wait after page load before capturing, for content that renders late. Any value above 0 puts the request on the full browser render path. Unless `async: true` is also set, the request is then HELD until the render finishes and returns 200 with the content envelope, or returns the 202 receipt if the hold window expires first. `0` (the default) keeps the request on the fast HTTP path, which returns 200 in one round trip.\n- `timeout_ms` — `int | Unset`\n- `async_` — `bool | Unset` — When true, the request returns 202 with a `ScrapeQueuedEnvelope` receipt immediately and the scrape runs in the background; poll `GET /v1/scrape/\\{id\\}` for the result. The `?async=true` query parameter is a second spelling of this field: the request is async when either one says true, and `false` in one never cancels `true` in the other. Asking for a receipt this way outranks every routing consequence: when neither is set (the default) a browser-path request is held to completion instead of being receipted. A 202 can still arrive without either, but only when the hold window expires.\n- `webhook_url` — `str | Unset` — Webhook endpoint URL (HTTPS only; http:// rejected with 400 invalid_url, reason scheme_unsupported)\n- `events` — `list[ScrapeRequestEventsItem] | Unset` — Webhook event types to deliver when webhook_url is set. Defaults to all three (queued, completed, failed); send an explicit subset to receive fewer.\n- `markdown_mode` — `ScrapeRequestMarkdownMode | Unset` — Markdown processing mode. article=article extraction (default), raw=minimal cleanup, llm=compact LLM-optimised output.\n- `markdown_query` — `str | Unset` — BM25 query string for relevance-ranked content filtering. Omit or leave empty to disable.\n- `markdown_links` — `ScrapeRequestMarkdownLinks | Unset` — Link rendering style in the markdown output. 'inline' (default) keeps `[text](url)` as-is. 'text' strips URLs, keeping only anchor text. 'none' strips URLs and removes reference definitions. 'references' converts to numbered `[text][N]` refs with a Links footer.\n- `markdown_images` — `ScrapeRequestMarkdownImages | Unset` — Image retention mode in the markdown output. 'inline' (default) keeps `![alt](url)` as-is. 'text' strips the URL, keeping only alt text. 'none' removes images entirely. 'references' converts to numbered `![alt][N]` refs with an Images footer. Distinct from markdown_filter_images (which drops low-signal images before conversion).\n- `with_links_summary` — `bool | Unset` — When true, appends a 'Links:\\n[1]: url\\n...' footer to the markdown output, built from the extracted link list. Automatically enabled when markdown_links is 'references'.\n- `with_images_summary` — `bool | Unset` — When true, appends an 'Images:\\n[1]: url\\n...' footer to the markdown output, built from the extracted image list.\n- `markdown_compact` — `bool | Unset` — Collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — `bool | Unset` — Filter low-signal images from the markdown output.\n- `markdown_include_media` — `bool | Unset` — When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`.\n- `markdown_include_warnings` — `bool | Unset` — When true, enables markdown-pipeline and tag-filter warnings for requests that include the `markdown` format. Artifact availability warnings such as `artifact_unavailable` may appear independently of this flag.\n- `markdown_include_stats` — `bool | Unset` — When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`.\n- `token_budget` — `int | Unset` — Maximum token count for the markdown output. When set and `markdown` is in `formats`, the output is truncated at the last paragraph → sentence → token boundary that keeps the estimated count under this limit. Absent → no truncation. Triggers a `markdown_tokens` field in the response.\n- `token_encoding` — `ScrapeRequestTokenEncoding | Unset` — Tokenizer encoding hint for `token_budget`. `cl100k_base` (default) matches GPT-4/4o; `o200k_base` matches GPT-4o-mini / o-series. Both use the same 4-char/token heuristic internally.\n- `mobile` — `bool | Unset` — When true, emulate a mobile device — the request uses a mobile (Android) user agent and a mobile viewport, so the upstream serves the mobile version of the page. Default false (desktop). The value is part of the cache key, so mobile and desktop responses are cached independently.\n- `solve_challenge` — `bool | Unset` — Attempts to clear a Cloudflare challenge; success is not guaranteed. Billed as a normal browser render. On a synchronous `POST /v1/scrape` this routes the request to the held browser render; a solve can outlast the hold window (28 seconds by default), and the request then returns the 202 receipt while the job continues in the background. With `async: true` the 202 receipt is returned immediately.\n- `remove_base64_images` — `bool | Unset` — When true (default), base64-encoded `data:` image sources are stripped from the HTML before markdown conversion. Set to false to preserve base64 images in the pipeline output. Does not affect `raw`, which always returns the original source unchanged.\n- `include_tags` — `list[str] | Unset` — HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in the `markdown` output. Applied before `exclude_tags`. Does not affect `raw`, which always returns the full page.\n- `exclude_tags` — `list[str] | Unset` — HTML element names (not CSS selectors) to strip from the `markdown` output. Applied after `include_tags` when both are present. Does not affect `raw`, which always returns the full page.\n- `cache_ttl` — `ScrapeRequestCacheTtlType1 | str | Unset` — How long a freshly fetched URL may be served from cache. `0` (string or integer) skips the cache read; cache-eligible results are still written. `Nh`/`Nd` set a TTL (capped at 168 h / 7 d). Safety-classified WAF husks are returned live but never stored in the shared cache. Honoured on both the synchronous and asynchronous paths; the async success envelope reports the lookup outcome via the `cache` field.\n- `custom` — `ScrapeRequestCustom | Unset` — User-supplied JSON payload, echoed back on the success envelope (sync, async, webhook). Capped at 4096 UTF-8 bytes (`Buffer.byteLength`). Distinct from the system-owned `metadata` column. Does NOT affect cache-key inputs — two requests differing only in `custom` resolve to the same cache entry.\n- `clean_markdown` — `bool | Unset` — When `true` and `markdown` is in `formats`, the converted markdown is sent to Groq LLM for cleaning (boilerplate removal, ad stripping, formatting improvement) before being returned. Graceful degradation: any Groq failure (key unset, 4xx/5xx, timeout, empty response) returns the raw markdown unchanged plus a warning in the `warnings` array. Billing: 3× credits and bytes applied only when cleaning succeeds.\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body, async_=async_) -> Response[Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope]\nsync(client=client, body=body, async_=async_) -> Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope | None\nawait asyncio_detailed(client=client, body=body, async_=async_) -> Response[Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope]\nawait asyncio(client=client, body=body, async_=async_) -> Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope | None\n```\n\n## Get Scrape\n\nGet scrape result\n\nAlways returns 200. Check the `status` discriminator for the scrape state.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope]\nsync(id=id, client=client) -> Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope | None\nawait asyncio_detailed(id=id, client=client) -> Response[Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope]\nawait asyncio(id=id, client=client) -> Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope | None\n```"
485
+ "body": "# Scrape\n\nFunctions for interacting with the `scrape` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Scrape\n\nScrape a URL\n\nFetches and processes a URL, returning content in one or more formats wrapped in a ScrapeEnvelope.\n\n**The response shape is decided by your request, not by how we route it.** In precedence order:\n\n1. `async: true` in the body, or `?async=true` in the query string (either one is enough; `false` in\none never cancels `true` in the other) → **202** with a `ScrapeQueuedEnvelope` receipt, returned\nimmediately. Poll `GET /v1/scrape/\\{id\\}` for the result.\n2. Otherwise, a request that needs a full page render — today that is any of `delay_ms > 0`,\n`solve_challenge: true`, or `outline` in `formats` — is **held open** until the render reaches a\nterminal state, then returns **200** with the content envelope (`success` or `failed`). If the\nrender is still running when the hold window expires (28 seconds by default), the request returns\nthe **202** receipt instead and the job continues in the background. A `solve_challenge` render can\noutlast the hold window, so expect the 202 receipt from such a request.\n3. Otherwise the request is served by the fast HTTP path and returns **200** with the content\nenvelope, typically in under a second.\n\n**A failed fetch is a result, not a transport error.** An unreachable host, a refused connection, or\na target whose bot protection defeats every proxy tier all come back on the same **200** as a\n`failed` envelope — never a 5xx. Narrow on the envelope's `status` before reading the body. A\nfailure the fast path decides inline is recorded as a failed job, so its envelope normally carries\nthat job's `id` and `GET /v1/scrape/\\{id\\}` returns the same envelope; if recording the failed job\nitself fails, the envelope still arrives on the same 200 with `id` set to `null` and there is\nnothing to poll. A failure a held render reaches carries that render's real `id`. Either way the\nrequest transfers no billable bytes and is charged nothing.\n\n**A target that rate-limits us is not ByteKit rate-limiting you.** The `failed` envelope's\n`error.code` is `target_rate_limited` when the target rate-limits the request. On the fast path that\nmeans our proxy attempts end on an HTTP 429 and no bot protection is identified on any attempt, even\nif the browser fallback then fails or reaches only an unidentified block page; the inline failure\ncarries `error.retry_after_seconds` when the target sent a usable `Retry-After`. On a held render\nthe browser's own answer decides: it observes a 429 on the page itself, or it fails outright after\nthe proxy attempts ended on an HTTP 429. A bot-protection verdict on an earlier fetch attempt does\nnot keep a held render `blocked` when the browser then observes the 429. A held render never carries\n`error.retry_after_seconds`. Retrying a `target_rate_limited` failure later is likely to work. A\nheld render whose browser reaches an unidentified 403 or 503 page after a proxy 429 is `blocked`. A\n429 that bot protection sends as a block stays `blocked` when it is the answer that decides the\ncode: the fast path's proxy attempts, or the browser render on a held render. Your own per-key limit\nis a separate case: it answers HTTP 429 `rate_limited` with a `Retry-After` header (see the `429`\nresponse).\n\nSo a 202 means one of exactly two things: you asked for one with `async: true` or `?async=true`, or\nthe hold window expired. `wait_for_selector` and `wait_until` are `ScreenshotRequest` options, not\n`ScrapeRequest` options — sending either to this endpoint returns `422 validation_error`, so neither\ncan produce a 202 here.\n\n**Parameters**\n\n- `async_ (bool | Unset)`\n- `body (ScrapeRequest)`\n- `url` — `str`\n- `formats` — `list[ScrapeRequestFormatsItem | ScrapeRequestJsonFormat] | Unset` — What to return. Each entry is either a string format (`raw`, `markdown`, `links` or `images`) or a `json` object entry that extracts structured data from the page. The string `\"json\"` is not a format value; the `json` entry is an object, described by `ScrapeRequestJsonFormat`. A list may hold at most one `json` entry, and a list holding only the `json` entry still captures `raw`. The `json` entry is accepted on `POST /v1/scrape`, `POST /v1/scrape/bulk` and `POST /v1/bulk` (scrape entries); monitor `formats` accept the string formats alone. Its result is `formats.json` on the response, and its charge is described on `ScrapeRequestJsonFormat`.\n- `country` — `str | Unset`\n- `delay_ms` — `int | Unset` — Milliseconds to wait after page load before capturing, for content that renders late. Any value above 0 puts the request on the full browser render path. Unless `async: true` is also set, the request is then HELD until the render finishes and returns 200 with the content envelope, or returns the 202 receipt if the hold window expires first. `0` (the default) keeps the request on the fast HTTP path, which returns 200 in one round trip.\n- `timeout_ms` — `int | Unset`\n- `async_` — `bool | Unset` — When true, the request returns 202 with a `ScrapeQueuedEnvelope` receipt immediately and the scrape runs in the background; poll `GET /v1/scrape/\\{id\\}` for the result. The `?async=true` query parameter is a second spelling of this field: the request is async when either one says true, and `false` in one never cancels `true` in the other. Asking for a receipt this way outranks every routing consequence: when neither is set (the default) a browser-path request is held to completion instead of being receipted. A 202 can still arrive without either, but only when the hold window expires.\n- `webhook_url` — `str | Unset` — Webhook endpoint URL (HTTPS only; http:// rejected with 400 invalid_url, reason scheme_unsupported)\n- `events` — `list[ScrapeRequestEventsItem] | Unset` — Webhook event types to deliver when webhook_url is set. Defaults to all three (queued, completed, failed); send an explicit subset to receive fewer.\n- `markdown_mode` — `ScrapeRequestMarkdownMode | Unset` — Markdown processing mode. article=article extraction (default), raw=minimal cleanup, llm=compact LLM-optimised output.\n- `markdown_query` — `str | Unset` — BM25 query string for relevance-ranked content filtering. Omit or leave empty to disable.\n- `markdown_links` — `ScrapeRequestMarkdownLinks | Unset` — Link rendering style in the markdown output. 'inline' (default) keeps `[text](url)` as-is. 'text' strips URLs, keeping only anchor text. 'none' strips URLs and removes reference definitions. 'references' converts to numbered `[text][N]` refs with a Links footer.\n- `markdown_images` — `ScrapeRequestMarkdownImages | Unset` — Image retention mode in the markdown output. 'inline' (default) keeps `![alt](url)` as-is. 'text' strips the URL, keeping only alt text. 'none' removes images entirely. 'references' converts to numbered `![alt][N]` refs with an Images footer. Distinct from markdown_filter_images (which drops low-signal images before conversion).\n- `with_links_summary` — `bool | Unset` — When true, appends a 'Links:\\n[1]: url\\n...' footer to the markdown output, built from the extracted link list. Automatically enabled when markdown_links is 'references'.\n- `with_images_summary` — `bool | Unset` — When true, appends an 'Images:\\n[1]: url\\n...' footer to the markdown output, built from the extracted image list.\n- `markdown_compact` — `bool | Unset` — Collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — `bool | Unset` — Filter low-signal images from the markdown output.\n- `markdown_include_media` — `bool | Unset` — When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`.\n- `markdown_include_warnings` — `bool | Unset` — When true, enables markdown-pipeline and tag-filter warnings for requests that include the `markdown` format. Artifact availability warnings such as `artifact_unavailable` may appear independently of this flag.\n- `markdown_include_stats` — `bool | Unset` — When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`.\n- `token_budget` — `int | Unset` — Maximum token count for the markdown output. When set and `markdown` is in `formats`, the output is truncated at the last paragraph → sentence → token boundary that keeps the estimated count under this limit. Absent → no truncation. Triggers a `markdown_tokens` field in the response.\n- `token_encoding` — `ScrapeRequestTokenEncoding | Unset` — Tokenizer encoding hint for `token_budget`. `cl100k_base` (default) matches GPT-4/4o; `o200k_base` matches GPT-4o-mini / o-series. Both use the same 4-char/token heuristic internally.\n- `mobile` — `bool | Unset` — When true, ask for the mobile version of the page. A page fetched over plain HTTP is requested with a mobile (Android) user agent. A page rendered in a browser renders in a phone-sized window but presents a desktop (Windows) browser identity, so a site that checks for a real phone may serve its desktop page. Default false (desktop). The value is part of the cache key, so mobile and desktop responses are cached independently.\n- `solve_challenge` — `bool | Unset` — Attempts to clear a Cloudflare challenge; success is not guaranteed. Billed as a normal browser render. On a synchronous `POST /v1/scrape` this routes the request to the held browser render; a solve can outlast the hold window (28 seconds by default), and the request then returns the 202 receipt while the job continues in the background. With `async: true` the 202 receipt is returned immediately.\n- `remove_base64_images` — `bool | Unset` — When true (default), base64-encoded `data:` image sources are stripped from the HTML before markdown conversion. Set to false to preserve base64 images in the pipeline output. Does not affect `raw`, which always returns the original source unchanged.\n- `include_tags` — `list[str] | Unset` — HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in the `markdown` output. Applied before `exclude_tags`. Does not affect `raw`, which always returns the full page.\n- `exclude_tags` — `list[str] | Unset` — HTML element names (not CSS selectors) to strip from the `markdown` output. Applied after `include_tags` when both are present. Does not affect `raw`, which always returns the full page.\n- `cache_ttl` — `ScrapeRequestCacheTtlType1 | str | Unset` — How long a freshly fetched URL may be served from cache. `0` (string or integer) skips the cache read; cache-eligible results are still written. `Nh`/`Nd` set a TTL (capped at 168 h / 7 d). Safety-classified WAF husks are returned live but never stored in the shared cache. Honoured on both the synchronous and asynchronous paths; the async success envelope reports the lookup outcome via the `cache` field.\n- `custom` — `ScrapeRequestCustom | Unset` — User-supplied JSON payload, echoed back on the success envelope (sync, async, webhook). Capped at 4096 UTF-8 bytes (`Buffer.byteLength`). Distinct from the system-owned `metadata` column. Does NOT affect cache-key inputs — two requests differing only in `custom` resolve to the same cache entry.\n- `clean_markdown` — `bool | Unset` — When `true` and `markdown` is in `formats`, the converted markdown is sent to Groq LLM for cleaning (boilerplate removal, ad stripping, formatting improvement) before being returned. Graceful degradation: any Groq failure (key unset, 4xx/5xx, timeout, empty response) returns the raw markdown unchanged plus a warning in the `warnings` array. Billing: 3× credits and bytes applied only when cleaning succeeds.\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body, async_=async_) -> Response[Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope]\nsync(client=client, body=body, async_=async_) -> Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope | None\nawait asyncio_detailed(client=client, body=body, async_=async_) -> Response[Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope]\nawait asyncio(client=client, body=body, async_=async_) -> Error | ScrapeErrorEnvelope | ScrapeSuccessEnvelope | ScrapeQueuedEnvelope | None\n```\n\n## Get Scrape\n\nGet scrape result\n\nAlways returns 200. Check the `status` discriminator for the scrape state.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope]\nsync(id=id, client=client) -> Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope | None\nawait asyncio_detailed(id=id, client=client) -> Response[Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope]\nawait asyncio(id=id, client=client) -> Error | ScrapeErrorEnvelope | ScrapeQueuedEnvelope | ScrapeSuccessEnvelope | None\n```"
481
486
  },
482
487
  "sdk/python/scrape-bulk": {
483
488
  "title": "Scrape Bulk",
@@ -487,7 +492,7 @@
487
492
  "sdk/python/screenshots": {
488
493
  "title": "Screenshots",
489
494
  "section": "SDK Reference",
490
- "body": "# Screenshots\n\nFunctions for interacting with the `screenshots` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Screenshot\n\nCapture a screenshot\n\nSync by default (holds up to 28s). Pass `async: true` in the body or `?async=true` in the\nquery string to return 202 immediately; either one is enough, and `false` in one never\ncancels `true` in the other.\nPoll via GET /v1/screenshots/\\{id\\}.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `async_ (bool | Unset)`\n- `body (ScreenshotRequest)`\n- `url` — `str`\n- `device` — `ScreenshotRequestDevice | Unset`\n- `viewport` — `None | Unset | Viewport`\n- `async_` — `bool | Unset` — When true, the request returns 202 immediately and the screenshot is captured in the background; poll `GET /v1/screenshots/\\{id\\}`. The `?async=true` query parameter is a second spelling of this field: the request is async when either one says true, and `false` in one never cancels `true` in the other.\n- `full_page` — `bool | Unset`\n- `format_` — `ScreenshotRequestFormat | Unset`\n- `quality` — `int | Unset`\n- `block_ads` — `bool | Unset`\n- `block_cookie_banners` — `bool | Unset`\n- `wait_until` — `ScreenshotRequestWaitUntil | Unset`\n- `wait_for_selector` — `None | str | Unset`\n- `delay_ms` — `int | Unset`\n- `scroll` — `bool | Unset`\n- `clip` — `Clip | None | Unset`\n- `dark_mode` — `bool | Unset`\n- `device_scale_factor` — `None | ScreenshotRequestDeviceScaleFactorType1 | ScreenshotRequestDeviceScaleFactorType2Type1 | ScreenshotRequestDeviceScaleFactorType3Type1 | Unset`\n- `include_html` — `bool | Unset`\n- `country` — `str | Unset`\n- `language` — `None | str | Unset`\n- `metadata` — `Metadata | Unset` — Arbitrary key-value metadata. Max 4096 bytes when JSON-serialized.\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body, async_=async_) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nsync(client=client, body=body, async_=async_) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\nawait asyncio_detailed(client=client, body=body, async_=async_) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nawait asyncio(client=client, body=body, async_=async_) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\n```\n\n## Get Screenshot\n\nGet screenshot status\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nsync(id=id, client=client) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\nawait asyncio_detailed(id=id, client=client) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nawait asyncio(id=id, client=client) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\n```"
495
+ "body": "# Screenshots\n\nFunctions for interacting with the `screenshots` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Screenshot\n\nCapture a screenshot\n\nSync by default (holds up to 28s). Pass `async: true` in the body or `?async=true` in the\nquery string to return 202 immediately; either one is enough, and `false` in one never\ncancels `true` in the other.\nPoll via GET /v1/screenshots/\\{id\\}.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `async_ (bool | Unset)`\n- `body (ScreenshotRequest)`\n- `url` — `str`\n- `device` — `ScreenshotRequestDevice | Unset`\n- `viewport` — `None | Unset | Viewport`\n- `async_` — `bool | Unset` — When true, the request returns 202 immediately and the screenshot is captured in the background; poll `GET /v1/screenshots/\\{id\\}`. The `?async=true` query parameter is a second spelling of this field: the request is async when either one says true, and `false` in one never cancels `true` in the other.\n- `full_page` — `bool | Unset`\n- `format_` — `ScreenshotRequestFormat | Unset`\n- `quality` — `int | Unset`\n- `block_ads` — `bool | Unset`\n- `block_cookie_banners` — `bool | Unset`\n- `wait_until` — `ScreenshotRequestWaitUntil | Unset`\n- `wait_for_selector` — `None | str | Unset`\n- `delay_ms` — `int | Unset`\n- `scroll` — `bool | Unset`\n- `clip` — `Clip | None | Unset`\n- `dark_mode` — `bool | Unset`\n- `device_scale_factor` — `None | ScreenshotRequestDeviceScaleFactorType1 | ScreenshotRequestDeviceScaleFactorType2Type1 | ScreenshotRequestDeviceScaleFactorType3Type1 | Unset` — Pixel density. Only `1` is supported; any other value is a 422 `validation_error`.\n- `include_html` — `bool | Unset`\n- `country` — `str | Unset`\n- `language` — `None | str | Unset`\n- `metadata` — `Metadata | Unset` — Arbitrary key-value metadata. Max 4096 bytes when JSON-serialized.\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body, async_=async_) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nsync(client=client, body=body, async_=async_) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\nawait asyncio_detailed(client=client, body=body, async_=async_) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nawait asyncio(client=client, body=body, async_=async_) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\n```\n\n## Get Screenshot\n\nGet screenshot status\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nsync(id=id, client=client) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\nawait asyncio_detailed(id=id, client=client) -> Response[Error | Error | ScreenshotResponse | ScreenshotResponse]\nawait asyncio(id=id, client=client) -> Error | Error | ScreenshotResponse | ScreenshotResponse | None\n```"
491
496
  },
492
497
  "sdk/python/search": {
493
498
  "title": "Search",
@@ -542,7 +547,7 @@
542
547
  "sdk/typescript/scrape": {
543
548
  "title": "Scrape",
544
549
  "section": "SDK Reference",
545
- "body": "# Scrape\n\nFetch a URL as raw HTML, clean markdown, or structured content. Accessed via `client.scrape`.\n\n## create\n\n```ts\nclient.scrape.create(opts: ScrapeOpts, requestOptions?: RequestOptions): Promise<ScrapeCreateResponse>\n```\n\nPOST /v1/scrape — create a scrape job.\n\nResolves to the 200 `success` content envelope or the 202 queued receipt;\nnarrow on `status` to tell them apart. A TERMINAL FAILURE THROWS: the server\ndelivers it as a `failed` envelope on HTTP 200 (a definitive upstream outcome\nis a result, not a transport error), and this method converts it into the\n`ByteKitError` you already catch — `err.code`, `err.message`, and `err.status`\n200. `scrape.get(id)` is unchanged and still returns `failed` as data.\n\nSee `ScrapeCreateResponse` for the full precedence: `async: true` receipts\nimmediately, a browser-path request without it is held open until the render\nreaches a terminal state (200) or the server's hold window expires (202 — a\nreceipt you did not ask for), and everything else takes the fast path (200).\n\nA held request therefore occupies the connection for as long as the render\ntakes, up to the server's hold window (28 s by default) — well inside this\nSDK's 120 s default `timeoutMs`, but worth raising `requestTimeoutMs` if you\nlowered it.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default. They\nare a different axis from `opts.timeout_ms`, which is the SERVER-side scrape budget.\n\n## get\n\n```ts\nclient.scrape.get(id: ScrapeId, requestOptions?: RequestOptions): Promise<ScrapeGetResponse>\n```\n\nGET /v1/scrape/\\{id\\} — poll a scrape by ID\n\n## Options (`ScrapeOpts`)\n\n- `url` (required) — `string`\n- `formats` — `Array<'raw' | 'markdown' | 'links' | 'images' | 'outline' | ScrapeJsonFormat>` — String formats, plus at most one `\\{ type: 'json', schema \\}` entry for structured extraction (the entry's result is `formats.json`).\n- `country` — `string`\n- `delay_ms` — `number`\n- `timeout_ms` — `number` — SERVER-side scrape budget in ms — how long the server may spend on the scrape itself. For the CLIENT-side abort budget (when this SDK gives up on the wire), see `RequestOptions.requestTimeoutMs`.\n- `async` — `boolean`\n- `webhook_url` — `string`\n- `events` — `Array<'queued' | 'completed' | 'failed'>`\n- `markdown_mode` — `MarkdownMode` — Markdown processing mode. article=article extraction (default), raw=minimal cleanup, llm=compact LLM-optimised output.\n- `markdown_query` — `string` — BM25 query string for relevance-ranked content filtering. Omit or leave empty to disable.\n- `markdown_links` — `MarkdownLinks` — Link rendering style in the markdown output.\n- `markdown_images` — `MarkdownImages` — Image retention mode in the markdown output. Distinct from `markdown_filter_images` (which drops low-signal images before conversion).\n- `with_links_summary` — `boolean` — When true, appends a `Links:` footer to the markdown output. Automatically enabled when `markdown_links` is `'references'`.\n- `with_images_summary` — `boolean` — When true, appends an `Images:` footer to the markdown output.\n- `markdown_compact` — `boolean` — Collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — `boolean` — Filter low-signal images from the markdown output.\n- `markdown_include_media` — `boolean` — When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`.\n- `markdown_include_warnings` — `boolean` — When true, the response includes markdown-pipeline and tag-filter warnings. `artifact_unavailable` may appear independently when a requested persisted format cannot be rehydrated.\n- `markdown_include_stats` — `boolean` — When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`.\n- `token_budget` — `number` — Maximum token count for the markdown output. Truncates at the last paragraph → sentence → token boundary under the limit. Absent → no truncation.\n- `token_encoding` — `TokenEncoding` — Tokenizer encoding hint for `token_budget`. `cl100k_base` (default) matches GPT-4/4o; `o200k_base` matches GPT-4o-mini / o-series.\n- `solve_challenge` — `boolean` — Attempts to clear a Cloudflare challenge; success is not guaranteed. Billed as a normal browser render. On a synchronous scrape this routes the request to the held browser render; a solve can outlast the hold window (28 seconds by default), and the request then returns the 202 receipt while the job continues in the background. With `async: true` the 202 receipt is returned immediately.\n- `mobile` — `boolean` — When true, emulate a mobile device (mobile UA + viewport). Default false (desktop). Part of the cache key, so mobile and desktop responses cache independently.\n- `remove_base64_images` — `boolean` — When true (default), base64-encoded `data:` image sources are stripped before markdown conversion. Set false to preserve them. Does not affect `raw`.\n- `include_tags` — `string[]` — HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in `markdown` output. Applied before `exclude_tags`. Does not affect `raw`.\n- `exclude_tags` — `string[]` — HTML element names (not CSS selectors) to strip from `markdown` output. Applied after `include_tags`. Does not affect `raw`.\n- `clean_markdown` — `boolean` — When true and `markdown` is in `formats`, the converted markdown is sent to Groq for cleaning before return. Graceful degradation on any Groq failure. Billing: 3× credits and bytes applied only when cleaning succeeds.\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. `'0'`/`0` skips the\ncache read (the result is still written), `'Nh'`/`'Nd'` set a TTL (capped at\n168h / 7d). Default `'48h'`. Honoured on both the synchronous and asynchronous\npaths; the async success envelope reports the outcome via the `cache` field.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, echoed back on the success envelope so callers\ncan correlate the response to caller-side state (job IDs, batch metadata).\nCapped at 4096 UTF-8 bytes after JSON serialization. Does NOT affect\ncache-key inputs — two requests differing only in `custom` share the same\ncache slot."
550
+ "body": "# Scrape\n\nFetch a URL as raw HTML, clean markdown, or structured content. Accessed via `client.scrape`.\n\n## create\n\n```ts\nclient.scrape.create(opts: ScrapeOpts, requestOptions?: RequestOptions): Promise<ScrapeCreateResponse>\n```\n\nPOST /v1/scrape — create a scrape job.\n\nResolves to the 200 `success` content envelope or the 202 queued receipt;\nnarrow on `status` to tell them apart. A TERMINAL FAILURE THROWS: the server\ndelivers it as a `failed` envelope on HTTP 200 (a definitive upstream outcome\nis a result, not a transport error), and this method converts it into the\n`ByteKitError` you already catch — `err.code`, `err.message`, and `err.status`\n200. `scrape.get(id)` is unchanged and still returns `failed` as data.\n\nSee `ScrapeCreateResponse` for the full precedence: `async: true` receipts\nimmediately, a browser-path request without it is held open until the render\nreaches a terminal state (200) or the server's hold window expires (202 — a\nreceipt you did not ask for), and everything else takes the fast path (200).\n\nA held request therefore occupies the connection for as long as the render\ntakes, up to the server's hold window (28 s by default) — well inside this\nSDK's 120 s default `timeoutMs`, but worth raising `requestTimeoutMs` if you\nlowered it.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default. They\nare a different axis from `opts.timeout_ms`, which is the SERVER-side scrape budget.\n\n## get\n\n```ts\nclient.scrape.get(id: ScrapeId, requestOptions?: RequestOptions): Promise<ScrapeGetResponse>\n```\n\nGET /v1/scrape/\\{id\\} — poll a scrape by ID\n\n## Options (`ScrapeOpts`)\n\n- `url` (required) — `string`\n- `formats` — `Array<'raw' | 'markdown' | 'links' | 'images' | 'outline' | ScrapeJsonFormat>` — String formats, plus at most one `\\{ type: 'json', schema \\}` entry for structured extraction (the entry's result is `formats.json`).\n- `country` — `string`\n- `delay_ms` — `number`\n- `timeout_ms` — `number` — SERVER-side scrape budget in ms — how long the server may spend on the scrape itself. For the CLIENT-side abort budget (when this SDK gives up on the wire), see `RequestOptions.requestTimeoutMs`.\n- `async` — `boolean`\n- `webhook_url` — `string`\n- `events` — `Array<'queued' | 'completed' | 'failed'>`\n- `markdown_mode` — `MarkdownMode` — Markdown processing mode. article=article extraction (default), raw=minimal cleanup, llm=compact LLM-optimised output.\n- `markdown_query` — `string` — BM25 query string for relevance-ranked content filtering. Omit or leave empty to disable.\n- `markdown_links` — `MarkdownLinks` — Link rendering style in the markdown output.\n- `markdown_images` — `MarkdownImages` — Image retention mode in the markdown output. Distinct from `markdown_filter_images` (which drops low-signal images before conversion).\n- `with_links_summary` — `boolean` — When true, appends a `Links:` footer to the markdown output. Automatically enabled when `markdown_links` is `'references'`.\n- `with_images_summary` — `boolean` — When true, appends an `Images:` footer to the markdown output.\n- `markdown_compact` — `boolean` — Collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — `boolean` — Filter low-signal images from the markdown output.\n- `markdown_include_media` — `boolean` — When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`.\n- `markdown_include_warnings` — `boolean` — When true, the response includes markdown-pipeline and tag-filter warnings. `artifact_unavailable` may appear independently when a requested persisted format cannot be rehydrated.\n- `markdown_include_stats` — `boolean` — When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`.\n- `token_budget` — `number` — Maximum token count for the markdown output. Truncates at the last paragraph → sentence → token boundary under the limit. Absent → no truncation.\n- `token_encoding` — `TokenEncoding` — Tokenizer encoding hint for `token_budget`. `cl100k_base` (default) matches GPT-4/4o; `o200k_base` matches GPT-4o-mini / o-series.\n- `solve_challenge` — `boolean` — Attempts to clear a Cloudflare challenge; success is not guaranteed. Billed as a normal browser render. On a synchronous scrape this routes the request to the held browser render; a solve can outlast the hold window (28 seconds by default), and the request then returns the 202 receipt while the job continues in the background. With `async: true` the 202 receipt is returned immediately.\n- `mobile` — `boolean` — When true, ask for the mobile page: a plain HTTP fetch sends a mobile (Android) user agent; a browser render uses a phone-sized window with a desktop (Windows) identity, so a site that checks for a real phone may serve its desktop page. Default false (desktop). Part of the cache key, so mobile and desktop responses cache independently.\n- `remove_base64_images` — `boolean` — When true (default), base64-encoded `data:` image sources are stripped before markdown conversion. Set false to preserve them. Does not affect `raw`.\n- `include_tags` — `string[]` — HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in `markdown` output. Applied before `exclude_tags`. Does not affect `raw`.\n- `exclude_tags` — `string[]` — HTML element names (not CSS selectors) to strip from `markdown` output. Applied after `include_tags`. Does not affect `raw`.\n- `clean_markdown` — `boolean` — When true and `markdown` is in `formats`, the converted markdown is sent to Groq for cleaning before return. Graceful degradation on any Groq failure. Billing: 3× credits and bytes applied only when cleaning succeeds.\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. `'0'`/`0` skips the\ncache read (the result is still written), `'Nh'`/`'Nd'` set a TTL (capped at\n168h / 7d). Default `'48h'`. Honoured on both the synchronous and asynchronous\npaths; the async success envelope reports the outcome via the `cache` field.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, echoed back on the success envelope so callers\ncan correlate the response to caller-side state (job IDs, batch metadata).\nCapped at 4096 UTF-8 bytes after JSON serialization. Does NOT affect\ncache-key inputs — two requests differing only in `custom` share the same\ncache slot."
546
551
  },
547
552
  "sdk/typescript/scrape-bulk": {
548
553
  "title": "Scrape Bulk",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunt-labs/bytekit-mcp",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "description": "ByteKit MCP server — exposes ByteKit web-data tools (scrape, screenshot, search, docs) to AI agents over the Model Context Protocol, hosted or as a local stdio server.",
5
5
  "license": "MIT",
6
6
  "type": "module",