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: WaitRetry-Afterseconds when the header is present (429 RATE_LIMITEDand transient500 INTERNAL). Otherwise use exponential backoff starting at1second, 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 contactsupport@crawlapi.dev.- Non-JSON gateway errors: If an upstream gateway returns
502or504with 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');
}import os
import time
import requests
def scrape_with_retry(url: str, fmt: str = "markdown") -> dict:
for attempt in range(3):
response = requests.post(
"https://api.crawlapi.dev/v1/scrape",
headers={"Authorization": f"Bearer {os.environ['CRAWLAPI_API_KEY']}"},
json={"url": url, "format": fmt},
timeout=65,
)
if response.status_code in (502, 504):
if attempt == 2:
response.raise_for_status()
time.sleep(2**attempt)
continue
body = response.json()
if body["success"]:
return body["data"]
if not body["error"]["retryable"] or attempt == 2:
raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
retry_after = response.headers.get("Retry-After")
wait_s = int(retry_after) if retry_after and retry_after.isdigit() else 2**attempt
time.sleep(wait_s)
raise RuntimeError("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
| Code | HTTP | Retryable | Meaning and remedy |
|---|---|---|---|
INVALID_REQUEST | 400 | no | 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 |
UNSAFE_URL | 400 | no | Not a public Send a public |
UNAUTHORIZED | 401 | no | The API key is missing, unknown, or revoked. Send one active API key as |
ACCOUNT_SUSPENDED | 403 | no | 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_CREDITS | 402 | no | The account balance has no credits left for this request. Add credits at app.crawlapi.dev/billing, then resend the same request. |
ROUTE_NOT_FOUND | 404 | no | No endpoint exists at this path; use Send |
METHOD_NOT_ALLOWED | 405 | no | The HTTP method is not allowed on this path. Use the HTTP method listed in the |
RATE_LIMITED | 429 | yes | The account reached its per-minute or concurrency limit, or the service is temporarily busy. Wait at least |
HOST_NOT_FOUND | 422 | no | The domain name does not resolve. Check the domain for typos; retrying the same URL returns the same error. |
NOT_FOUND | 404 | no | 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 |
GONE | 410 | no | The target site says this page has been permanently removed (HTTP 410). Remove the URL from your list; the site permanently deleted it ( |
LOGIN_REQUIRED | 422 | no | 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 |
UNSUPPORTED_CONTENT | 422 | no | 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_PDF | 422 | no | 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. |
BLOCKED | 422 | depends | The target site's bot protection refused access, or the site requires payment (HTTP 402). Retry with backoff up to 3 attempts while |
NO_CONTENT | 422 | depends | No usable content was produced: an empty shell, too little readable text, a cookie or age wall, or If you requested |
TARGET_ERROR | 422 | depends | The target site failed on its side: a 5xx response, a connection or TLS failure, or a malformed reply. Retry later while |
TIMEOUT | 408 | yes | The request reached its Increase |
ENGINE_FAILED | 500 | yes | 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 |
INTERNAL | 500 | yes | An unexpected error occurred on our side. Quote Retry after |
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.