Error response schema, retry code, and every API error code.

On this page

Every API error returns the same JSON shape with success: false, request_id, and an error object.

Error object

{
  "success": false,
  "request_id": "req_41e813f088955c316776",
  "error": {
    "code": "BLOCKED",
    "message": "The site's bot protection (Akamai) refused access.",
    "retryable": true,
    "doc_url": "https://docs.crawlapi.dev/errors#BLOCKED",
    "target_status": 403,
    "vendor": "akamai"
  }
}
Field Presence Meaning
code Always Machine-readable error code from the table below
message Always Plain-text summary of what happened
retryable Always Whether retrying the same request may succeed
doc_url Always Direct link to this code’s entry below
param On INVALID_REQUEST Offending request field (url, format, timeout, or unknown key)
required_credits On INSUFFICIENT_CREDITS Credits required for this request (1)
target_status When target answered HTTP status code returned by the target site
vendor When identified Protection service that refused access

request_id is also sent in the x-request-id response header. Include it when writing to support.

Retry policy

Treat error.retryable on the response as authoritative rather than inferring retryability from the HTTP status or code alone (for example, BLOCKED sets retryable: false on HTTP 402, and NO_CONTENT sets retryable: false when format: "json" finds no structured data).

  • retryable: true: Wait Retry-After seconds when the header is present (429 RATE_LIMITED and transient 500 INTERNAL). Otherwise use exponential backoff starting at 1 second, up to 3 total attempts.
  • retryable: false: Stop immediately. Retrying the same request returns the same error.
  • 401 UNAUTHORIZED / 402 INSUFFICIENT_CREDITS: Fix your key or add credits before retrying.
  • 403 ACCOUNT_SUSPENDED: Stop all requests and contact support@crawlapi.dev.
  • Non-JSON gateway errors: If an upstream gateway returns 502 or 504 with a non-JSON body during a brief blip, retry with backoff.
async function scrapeWithRetry(url: string, format: 'markdown' | 'json' = 'markdown') {
  for (let attempt = 0; attempt < 3; attempt++) {
    const response = await fetch('https://api.crawlapi.dev/v1/scrape', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.CRAWLAPI_API_KEY}`,
        'content-type': 'application/json',
      },
      body: JSON.stringify({ url, format }),
    });
    if (response.status === 502 || response.status === 504) {
      if (attempt === 2) throw new Error(`HTTP ${response.status}`);
      await new Promise((resolve) => setTimeout(resolve, 1000 * 2 ** attempt));
      continue;
    }
    const body = await response.json();
    if (body.success) return body.data;
    if (!body.error.retryable || attempt === 2) {
      throw new Error(`${body.error.code}: ${body.error.message}`);
    }
    const retryAfter = Number(response.headers.get('retry-after'));
    const waitMs =
      Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1000 : 1000 * 2 ** attempt;
    await new Promise((resolve) => setTimeout(resolve, waitMs));
  }
  throw new Error('Retries exhausted');
}

HTTP 422 and sign-in walls

Seven target failures share HTTP 422: BLOCKED, NO_CONTENT, HOST_NOT_FOUND, LOGIN_REQUIRED, UNSUPPORTED_CONTENT, SCANNED_PDF, and TARGET_ERROR. Always branch on error.code, not on HTTP status alone.

If a target page serves a readable sign-in wall (such as a login prompt or age notice), crawlapi returns HTTP 200 with metadata.login_required: true and the wall’s text. Check data.metadata.login_required before indexing content.

Quick diagnosis by status

Status What to check
200 with unexpected text Check metadata.login_required (sign-in wall) and metadata.truncated (2 MiB cap).
400 Read error.param and error.message, fix the request, and do not retry unchanged.
401 Verify CRAWLAPI_API_KEY is present and active at app.crawlapi.dev/keys (see API keys and billing).
402 Top up credits at app.crawlapi.dev/billing before retrying (see Credits and pricing).
403 Account is suspended — pause traffic and contact support@crawlapi.dev.
404 / 410 Target page is missing or removed; do not retry unchanged.
408 Page exceeded your timeout deadline; raise timeout up to 60000 ms or see Timeouts.
422 Branch on error.code and error.retryable (see table below).
429 Honor Retry-After and check Rate limits.
5xx Transient service or gateway error; retry with exponential backoff up to 3 attempts.

All error codes

Filter error codes

Error codes with their HTTP status, retry rule, meaning, and remedy
CodeHTTPRetryableMeaning and remedy
INVALID_REQUEST400no

The request body could not be accepted: malformed JSON, a missing or unknown field, or a value out of range.

Fix the field named in error.param and error.message, then resend POST /v1/scrape with a JSON body containing url, optional format, and optional timeout.

UNSAFE_URL400no

Not a public http or https address: an unsupported scheme, embedded credentials, a malformed URL, or a private or local network address.

Send a public http or https URL with no username or password in the URL.

UNAUTHORIZED401no

The API key is missing, unknown, or revoked.

Send one active API key as Authorization: Bearer or x-api-key; manage keys at app.crawlapi.dev/keys.

ACCOUNT_SUSPENDED403no

The API key is active, but the account it belongs to is suspended.

Stop retrying: no key of a suspended account works. Write to support@crawlapi.dev to resolve the suspension.

INSUFFICIENT_CREDITS402no

The account balance has no credits left for this request.

Add credits at app.crawlapi.dev/billing, then resend the same request.

ROUTE_NOT_FOUND404no

No endpoint exists at this path; use POST /v1/scrape.

Send POST /v1/scrape (with no trailing slash).

METHOD_NOT_ALLOWED405no

The HTTP method is not allowed on this path.

Use the HTTP method listed in the Allow header (POST for /v1/scrape).

RATE_LIMITED429yes

The account reached its per-minute or concurrency limit, or the service is temporarily busy. Retry-After says when to retry.

Wait at least Retry-After seconds before retrying; read RateLimit to see remaining per-minute and concurrency room.

HOST_NOT_FOUND422no

The domain name does not resolve.

Check the domain for typos; retrying the same URL returns the same error.

NOT_FOUND404no

The target site says this page does not exist, including a "not found" page served with HTTP 200.

Check the URL; retrying returns the same error and costs 0 credits.

GONE410no

The target site says this page has been permanently removed (HTTP 410).

Remove the URL from your list; the site permanently deleted it (0 credits).

LOGIN_REQUIRED422no

The page requires signing in and has no readable wall text to return, or the document is password-protected.

Pass a public URL. Sign-in walls with readable text return HTTP 200 with metadata.login_required: true for 0 credits.

UNSUPPORTED_CONTENT422no

The URL serves content the service cannot read: neither HTML nor a supported document (for example an image, an archive, or an unreadable or oversized file).

Use another URL: only HTML and documents (PDF, Office, OpenDocument, EPUB, RTF, CSV, JSON and feeds) can be read.

SCANNED_PDF422no

Most pages of this PDF are scanned images; OCR is not supported.

Supply a PDF with an embedded text layer or run OCR before scraping.

BLOCKED422depends

The target site's bot protection refused access, or the site requires payment (HTTP 402).

Retry with backoff up to 3 attempts while retryable is true. Sites returning HTTP 402 set retryable: false.

NO_CONTENT422depends

No usable content was produced: an empty shell, too little readable text, a cookie or age wall, or format=json found no records.

If you requested format=json, try format=markdown; otherwise retry only while retryable is true.

TARGET_ERROR422depends

The target site failed on its side: a 5xx response, a connection or TLS failure, or a malformed reply.

Retry later while retryable is true.

TIMEOUT408yes

The request reached its timeout deadline before finishing.

Increase timeout up to 60000 ms or retry later.

ENGINE_FAILED500yes

A failure on our side while reading or processing the page; nothing was charged.

Retry the same request; the failure was on our side and cost 0 credits.

INTERNAL500yes

An unexpected error occurred on our side. Quote request_id if you contact support; nothing was charged.

Retry after Retry-After when present; if it persists, send request_id to support.

Reporting an issue

When reporting a reproducible failure, email support@crawlapi.dev with the request_id (from the JSON body or x-request-id header), HTTP status, and error.code.

esc
↑↓navigate↵openescclose
Documentation