For AI agents: a documentation index is available at /llms.txt
Skip to main content

Crawl API

BETA

The Crawl API is currently in beta. Parameters and response shapes may change in future releases.

The Crawl API is only available for Cloud plans. Contact us for more information here.

Asynchronously crawl a website and scrape every discovered page. Submit a starting URL and receive a crawl ID you can poll for status and results. Configure crawl depth, link-following rules, path filters, scrape output formats, and optional webhook notifications. Each scraped page is returned as structured, LLM-ready data.

Endpoints

  • Start a crawl: POST /crawl
  • Get crawl status and results: GET /crawl/{id}
  • List all crawl jobs: GET /crawl
  • Cancel a crawl: DELETE /crawl/{id}
  • Auth: token query parameter (?token=)
  • Content-Type: application/json
  • Response: application/json
Prerequisites
Video Tutorial

Visual learner? Check out this video Crawl, Search & Map the Web with Browserless REST APIs for a step-by-step tutorial.

Quickstart​

curl --request POST \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://www.browserless.io"
}'

Response

{
"success": true,
"id": "crawl_abc123def456",
"url": "https://production-sfo.browserless.io/crawl/crawl_abc123def456"
}

The url field is a status-check URL. Use it to poll for results via GET /crawl/{id}. It doesn't include your API token, so add ?token=YOUR_API_TOKEN_HERE when you call it.

Polling for results​

Once you have a crawl ID, poll GET /crawl/{id} to check progress and retrieve scraped pages. Results are paginated: each response holds up to 1,000 pages or about 10 MB of page entries, whichever comes first. Use the next URL to fetch the rest. Like url, it doesn't include your API token, so append &token=YOUR_API_TOKEN_HERE when you request it.

Query parameters

ParameterTypeDefaultDescription
tokenstring—Your API token (required).
skipnumber0Number of pages to skip for pagination (non-negative integer).
curl --request GET \
--url 'https://production-sfo.browserless.io/crawl/crawl_abc123def456?token=YOUR_API_TOKEN_HERE'

Response

{
"status": "completed",
"total": 15,
"completed": 15,
"failed": 0,
"expiresAt": "2025-07-01T12:00:00.000Z",
"next": null,
"data": [
{
"status": "completed",
"contentUrl": "https://crawl-artifacts.s3.us-east-1.amazonaws.com/crawls/crawl_abc123def456/page_0a1b2c3d4e5f.json?X-Amz-Algorithm=AWS4-HMAC-SHA256&...",
"metadata": {
"title": "Browserless - Headless Browser Automation",
"description": "Headless browser automation, without the hosting headaches.",
"language": "en",
"scrapedAt": "2025-06-30T10:00:00.000Z",
"sourceURL": "https://www.browserless.io/",
"statusCode": 200,
"error": null
}
}
// ...more pages
]
}

Result retention​

Crawl results stay available for your plan's retention period, counted from when the crawl finishes (completed, failed, or cancelled):

PlanResults kept for
Free1 day
Prototyping7 days
Starter30 days
Scale and larger plans90 days

expiresAt in the status response gives the exact time for your crawl. After it passes, GET /crawl/{id} returns 410 Gone and the crawl no longer appears in GET /crawl. Each contentUrl is a separate, shorter-lived link: it expires 1 hour after the status response that returned it, so poll again for a fresh link instead of storing it.

Control how deep the crawler follows links and whether it stays within the original domain.

allowSubdomains follows links to hosts that end in a dot plus the start URL's host. Starting from https://browserless.io covers www.browserless.io and docs.browserless.io. Starting from https://www.browserless.io only covers hosts under www.browserless.io, so docs.browserless.io isn't followed. To include every subdomain, start from the bare domain.

curl --request POST \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://browserless.io",
"maxDepth": 3,
"limit": 50,
"allowSubdomains": true,
"allowExternalLinks": false
}'

Sitemap control​

The sitemap parameter controls whether the crawler reads the site's XML sitemap. Only the start page reads it: the sitemap adds up to limit URLs, which are crawled at depth 1. Sitemap URLs go through the same host and path filters as links found on pages. Every page after the start page discovers links from its own content, whatever the mode.

ModeDescription
"auto"(default) The start page queues its sitemap URLs plus the links found on it. If the site has no sitemap, the crawler uses only the on-page links.
"force"The start page queues only its sitemap URLs, not its on-page links. If no sitemap is found, the start page fails with No sitemap found (sitemap mode: force) and the crawl ends failed. Pages below the start page still follow their on-page links up to maxDepth, so set "maxDepth": 1 to crawl only the start page and its sitemap URLs.
"skip"Ignores the sitemap entirely. Only discovers URLs by following on-page links.
curl --request POST \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://www.browserless.io",
"sitemap": "force"
}'

Path filtering​

Use includePaths and excludePaths to control which discovered URLs the crawler visits. Both take arrays of JavaScript regular expressions, tested against the URL's path only, without the host or query string and with a single trailing slash removed, so ^/blog$ matches both /blog and /blog/. A URL that matches any excludePaths pattern is skipped. When you provide includePaths patterns, a URL must match at least one of them. The crawler always visits the start URL and filters sitemap URLs the same way as on-page links. Each pattern can be up to 200 characters. The API rejects patterns with nested quantifiers such as (a+)+ with 400.

Patterns are regular expressions, not glob patterns. To skip PDF links, use "excludePaths": ["\\.pdf$"] in the JSON request body, not *.pdf. A pattern with invalid regex syntax returns 400 Bad Request naming the field and its position. Patterns longer than 200 characters or flagged as unsafe because of nested quantifiers also return 400 Bad Request with the reason. These rejected requests aren't billed.

curl --request POST \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://www.browserless.io",
"includePaths": ["^/blog"],
"excludePaths": ["^/blog/draft"]
}'

Scrape options​

Control how each crawled page is scraped with the scrapeOptions object. Choose output formats, filter content, and set per-page timeouts.

Content filters (onlyMainContent, includeTags, excludeTags) only shape the content you get back. Links are still discovered from the full page, so use includePaths and excludePaths to control which pages are crawled.

curl --request POST \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://www.browserless.io",
"limit": 10,
"scrapeOptions": {
"formats": ["markdown", "html"],
"onlyMainContent": true,
"excludeTags": ["nav", "footer"]
}
}'

Webhook notifications​

Receive real-time notifications as pages are scraped or when the crawl completes or fails. Provide an HTTPS URL and choose which events to subscribe to.

curl --request POST \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://www.browserless.io",
"webhook": {
"url": "https://your-server.com/webhook",
"events": ["page", "completed", "failed"]
}
}'

Each event is sent as a JSON POST to your webhook URL:

Eventtypedata
pagecrawl.pagepageId, url, statusCode, and a 1-hour contentUrl for the scraped page. Sent only for pages that were scraped successfully.
completedcrawl.completedurl, status, total, completed, and failed. A completed crawl can still have failed pages.
failedcrawl.failedSame fields as completed. success is false and error says why. If every page failed, error is "Every page failed to scrape" and each page's own error is in the crawl results. If something stopped the whole crawl (for example, the profile was deleted), error is that message. To receive a webhook when you cancel with DELETE, include failed in webhook.events; the default is only completed. The cancellation event has data.status: "cancelled" and error: "Cancelled by user".
{
"success": false,
"type": "crawl.failed",
"id": "crawl_abc123",
"data": {
"url": "https://example.com",
"status": "failed",
"total": 3,
"completed": 0,
"failed": 3
},
"error": "Every page failed to scrape"
}

The webhook URL must use HTTPS and must not point to a private or internal network address. Browserless doesn't follow redirects from your receiver, so a 3xx response counts as a failed delivery. Respond with a 2xx status at the final URL.

Using a profile​

Crawl authenticated pages by passing a saved profile via the ?profile= query parameter. The browser loads the profile's cookies, localStorage, and IndexedDB before navigating, so every crawled page is accessed as the logged-in user.

curl --request POST \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE&profile=acme-prod' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://app.example.com/docs",
"limit": 20,
"maxDepth": 2
}'
tip

Create and manage profiles via the Authenticated Profiles workflow. The profile name is scoped to your API token. Other tokens cannot access your profiles.

Cancelling a crawl​

Cancel a running crawl by sending a DELETE request with the crawl ID. Pages already scraped remain available.

If the crawl is already in a terminal state (completed, failed, or cancelled), the API returns a 409 Conflict:

{
"success": false,
"error": "Crawl is already completed (requestId: req_abc123)",
"message": "Crawl is already completed (requestId: req_abc123)",
"id": "crawl_abc123def456",
"status": "completed"
}

Success response (200):

{
"status": "cancelled"
}
curl --request DELETE \
--url 'https://production-sfo.browserless.io/crawl/crawl_abc123def456?token=YOUR_API_TOKEN_HERE'

Listing all crawls​

List all crawl jobs for your account. Results are paginated. Use nextCursor to fetch the next page. Crawls whose results have expired aren't listed.

Query parameters

ParameterTypeDefaultDescription
tokenstring—Your API token (required).
limitnumber20Results per page (1–100).
cursorstring—Omit cursor or pass cursor= for the first page. For the next page, pass nextCursor from the previous response unchanged. A non-empty cursor that cannot be decoded returns HTTP 400 with an error starting cursor is invalid.
statusstring—Filter by status: "in-progress", "completed", "failed", or "cancelled".
curl --request GET \
--url 'https://production-sfo.browserless.io/crawl?token=YOUR_API_TOKEN_HERE'

Response

{
"crawls": [
{
"id": "crawl_def456abc789",
"url": "https://docs.browserless.io",
"status": "in-progress",
"total": 50,
"completed": 23,
"createdAt": "2025-06-30T10:00:00.000Z",
"completedAt": null
},
{
"id": "crawl_abc123def456",
"url": "https://www.browserless.io",
"status": "completed",
"total": 15,
"completed": 15,
"createdAt": "2025-06-30T09:00:00.000Z",
"completedAt": "2025-06-30T09:05:00.000Z"
}
],
"nextCursor": "eyJpZCI6ImNyYXdsX2FiYzEyM2RlZjQ1NiIsImNyZWF0ZWRBdCI6MTc1MTI3NDAwMDAwMH0"
}

Request body​

POST /crawl​

FieldTypeRequiredDefaultDescription
urlstringYes—The URL to crawl. Must be http:// or https://.
limitnumberNo100Maximum number of pages to crawl (min 1, clamped to your plan's limit).
maxDepthnumberNo5Maximum link-follow depth from the root URL (0–20).
maxRetriesnumberNo1Number of retry attempts per failed page (0–5).
allowExternalLinksbooleanNofalseWhether to follow links to external domains.
allowSubdomainsbooleanNofalseWhether to follow links to subdomains of the start URL's host (hosts ending in .<host>). Start from the bare domain, for example https://browserless.io, to include www. and other subdomains.
sitemapstringNo"auto"Sitemap handling strategy: "auto", "force", or "skip".
includePathsstring[]No[]Regular expressions (not globs) matched against the URL path to include. Invalid patterns return 400 Bad Request.
excludePathsstring[]No[]Regular expressions (not globs) matched against the URL path to exclude. Invalid patterns return 400 Bad Request.
delaynumberNo200Delay between requests in milliseconds (0–10,000).
scrapeOptionsobjectNo—Options controlling how each page is scraped. See below.
webhookobjectNo—Webhook configuration for crawl event notifications. See below.

scrapeOptions​

FieldTypeRequiredDefaultDescription
formatsstring[]No["markdown"]Output formats: "markdown", "html", "rawText"
onlyMainContentbooleanNotrueWhether to extract only the main content of the page.
includeTagsstring[]No[]HTML tag selectors to include.
excludeTagsstring[]No[]HTML tag selectors to exclude.
waitFornumberNo0Time in milliseconds to wait after page load before scraping (0–30,000).
headersobjectNo—Custom HTTP headers to send with each page request. host, authorization, proxy-authorization, cookie, set-cookie, x-forwarded-for, x-real-ip, and forwarded are removed before the request is sent. A header with an invalid name, or a value that isn't a string or contains a line break or NUL character, returns 400.
timeoutnumberNo150000Navigation timeout per page in milliseconds. Must be between 1,000 and 180,000; values outside that range return 400.
proxystringNo"residential"Proxy network to route page fetches through: "residential" (6 units/MB) or "datacenter" (2 units/MB).

webhook​

FieldTypeRequiredDefaultDescription
urlstringYes—The HTTPS URL to send webhook events to.
eventsstring[]No["completed"]Which events to send: "page", "completed", "failed". Defaults to ["completed"] when omitted.

Response fields​

POST /crawl (start)​

FieldTypeDescription
successbooleanWhether the crawl was started successfully.
idstringThe unique crawl job ID. Use this to poll for status and results.
urlstringStatus-check URL for polling results via GET /crawl/{id}.

GET /crawl/{id} (status and results)​

FieldTypeDescription
statusstringCrawl status: "in-progress", "completed", "failed", or "cancelled".
totalnumberTotal number of pages discovered.
completednumberNumber of pages successfully scraped.
failednumberNumber of pages that failed to scrape.
expiresAtstring | nullISO 8601 timestamp when the crawl's results expire: when the crawl finished plus your plan's retention period (see Result retention). null while the crawl is still in progress.
nextstring | nullURL to fetch the next page of results (uses skip offset parameter). null when all results have been returned.
dataCrawlPageResponse[]Array of scraped page results. See below.

CrawlPageResponse​

FieldTypeDescription
statusstringPage status: "queued", "in-progress", "completed", "failed", or "cancelled".
contentUrlstring | nullPre-signed S3 URL to fetch the full scraped content for this page. Expires after 1 hour. null if the page has not yet completed.
metadata.titlestring | nullPage title. null if not extracted.
metadata.descriptionstring | nullPage meta description. null if not extracted.
metadata.languagestring | nullDetected page language. null if not detected.
metadata.scrapedAtstring | nullISO 8601 timestamp when the page was scraped. null if not yet scraped.
metadata.sourceURLstringThe original URL that was scraped.
metadata.statusCodenumber | nullHTTP status code for a completed page. A failed scrape attempt can still report the site's response code (for example, 404). null if the page hasn't been scraped yet, the failed attempt got no response, or the fetch succeeded but billing or storage failed afterward.
metadata.errorstring | nullError message if the page failed to scrape. null on success.

GET /crawl (list all)​

FieldTypeDescription
crawlsCrawlListItem[]Array of crawl jobs.
nextCursorstring | nullCursor for fetching the next page of results. null when there are no more results.

CrawlListItem​

FieldTypeDescription
idstringThe crawl job ID.
urlstringThe root URL being crawled.
statusstringCrawl status: "in-progress", "completed", "failed", or "cancelled".
totalnumberTotal pages discovered.
completednumberPages successfully scraped.
createdAtstringISO 8601 timestamp when the crawl was created.
completedAtstring | nullISO 8601 timestamp when the crawl finished. null if still running.

Error responses​

Errors returned by the crawl handlers are JSON with success: false and an error string that includes the request ID. For compatibility, message contains the same string. Only 409 Conflict responses include the crawl id and status.

Example 404 Not Found response:

{
"success": false,
"error": "Crawl not found (requestId: req_abc123)",
"message": "Crawl not found (requestId: req_abc123)"
}

Requests rejected before they reach a crawl handler, such as for a missing or invalid API key, malformed JSON, or schema validation errors, return plain text instead.

All crawl endpoints may return the following error responses:

StatusDescription
400 Bad RequestInvalid parameters, unrecognized query params, an invalid regular expression in includePaths/excludePaths (they are regular expressions, not globs), or an invalid header name or value in scrapeOptions.headers.
401 UnauthorizedMissing or invalid API token.
404 Not FoundCrawl ID does not exist or belongs to another token.
409 Conflict(DELETE only) The crawl is already in a terminal state (completed, failed, or cancelled).
410 Gone(GET /crawl/{id} only) The crawl's results have expired. See Result retention.
429 Too Many RequestsConcurrent crawl limit reached for your plan (POST /crawl), or the worker is briefly at capacity for status requests (GET /crawl/{id}). Retry shortly.
503 Service UnavailableCrawl service is unavailable or temporarily degraded, or crawl creation is briefly busy for your token. Retry shortly, after the Retry-After header's delay when it's present.

FAQ & Troubleshooting​

Why am I getting a 401 Unauthorized error?

Your API token is missing or invalid. Include it as a ?token= query parameter or in the Authorization header. Verify the token in your account dashboard.

Crawled pages come back empty or missing content

Set scrapeOptions.waitFor to wait longer after each page loads (up to 30,000 ms) if the page renders its content after the initial load. For slow pages, raise scrapeOptions.timeout (up to 180,000 ms). /crawl doesn't accept other REST API options such as waitForTimeout or waitForSelector, and returns 400 for fields it doesn't recognize.

Next steps​

Was this page helpful?