POST /v1/parse
File → markdown. Accepts either a multipart file upload or a JSON { url } pointing at a document, and returns markdown + extracted text.
Supports PDF and DOCX. DOCX is read with a built-in extractor that keeps paragraph text and heading levels (tables come through as paragraphs; images are skipped).
Pricing
A PDF costs 1 credit per page parsed: each page whose text was extracted. A 300-page PDF costs 300 credits; set maxPages to cap it. Pages with no text layer are free, a DOCX costs 1 credit per document, and a parse that extracts nothing costs 0. Every response reports credits_charged.
The credits are held before the first page is read, once the page count is known: min(page count, maxPages). The hold is settled to the pages actually parsed and refunded on error. On the Free plan, a balance that cannot cover the hold returns 402 and no page is parsed. A cached result costs the same as the parse that produced it.
Request: multipart upload
curl -X POST https://api.superscraper.dev/v1/parse \
-H "x-api-key: ss_live_xxxxxxxxxxxxxxxxxxxx" \
-F "file=@invoice.pdf"Request: JSON body (fetch a URL)
POST /v1/parse
Content-Type: application/json
x-api-key: YOUR_KEY| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes (JSON path only) | URL of a PDF or DOCX document to fetch and parse. |
format | string | No | "markdown" (default), "text" or "rag". "rag" adds heading-aware chunks[] to the response. On a multipart upload, send it as a form field. |
chunkSize | number | No | rag only. Characters per chunk, default 1,000, clamped to 100–20,000. |
chunkOverlap | number | No | rag only. Characters shared by neighbouring chunks, default 100. |
maxPages | integer | No | PDF only. Parse only the first N pages and pay for at most N. A positive integer, clamped to the page limit: 2,000 pages where async jobs run, else the in-request limit of 300 pages. It never raises that limit. On a multipart upload, send it as a form field. |
async | boolean | No | true: always run as a job. false: never run as a job (documents above the in-request limit of 300 pages then return 413). Leave it out and a PDF with more than 50 pages to parse runs as a job. See Large documents. |
webhook | string | No | A public http or https URL called when a job ends (parse.completed or parse.failed). Ignored when the parse runs in the request. |
curl -X POST https://api.superscraper.dev/v1/parse \
-H "x-api-key: ss_live_xxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/contracts/license-2026.pdf", "maxPages": 20}'Response
HTTP 200 when at least one page (or the DOCX body) was extracted.
| Field | Type | Description |
|---|---|---|
ok | boolean | true on 200 |
status | "ok" | "partial" | partial means some pages had no text layer, or the parser stopped early (see truncated) |
method | "pdfjs" | "docx" | "pdf-inspector" | "anydoc" | Parser that produced the content. The last two appear only when the server runs the native parser engine. Kept unchanged on cache hits |
parser | string | Same value as method |
source | "upload" | "url" | Where the document came from |
markdown | string | Document content converted to markdown (one ## Page n section per page with text) |
text | string | Plain-text extraction |
format | "pdf" | "docx" | Detected document format |
pages_total | number | null | Pages in the document. null for DOCX, which has no fixed pages |
pages_parsed | number | null | Pages whose text was extracted |
pages | number | undefined | Same as pages_total (kept for older clients) |
truncated | boolean | true when the parser stopped before the last page |
truncated_reason | string | max_pages (your maxPages ended the parse), deadline, memory, cpu, cancelled, crash or text_budget |
partial_reason | string | no_text_layer when some pages are scanned or image-only |
pages_without_text | number[] | 1-based pages with no extractable text |
outputFormat | string | The format you asked for |
chunks | object[] | undefined | rag only: { position, text, heading, headingLevel, headingPath, charStart, charEnd, url? } |
totalChunks | number | undefined | rag only: number of chunks |
chunksTruncated | boolean | undefined | rag only: true when chunking stopped at the 2,000-chunk cap |
cached | boolean | true when served from the 24h cache. A cached partial stays partial |
credits_charged | number | Credits this call cost: 1 per PDF page parsed, 1 for a DOCX, 0 on failure |
Example response
{
"ok": true,
"status": "partial",
"method": "pdfjs",
"parser": "pdfjs",
"source": "url",
"markdown": "## Page 1\n\nContractor License Agreement ...",
"text": "Contractor License Agreement ...",
"format": "pdf",
"pages_total": 4,
"pages_parsed": 3,
"pages": 4,
"truncated": false,
"partial_reason": "no_text_layer",
"pages_without_text": [4],
"cached": false,
"credits_charged": 3
}Large documents: async jobs
A PDF with more than 50 pages to parse (min(page count, maxPages)), a document above the in-request limit of 300 pages, or a request with async: true runs as a job. The API counts the pages first, before any page is read, and answers 202:
{
"ok": true,
"jobId": "parse_6f1c9a2e-0b7d-4c55-9a8e-2f3d1e4b5a60",
"status": "queued",
"source": "url",
"format": "pdf",
"pages_total": 480,
"pages_to_parse": 480,
"credits_held": 480,
"result_ttl_seconds": 86400,
"status_url": "/v1/jobs/parse_6f1c9a2e-0b7d-4c55-9a8e-2f3d1e4b5a60"
}Poll GET /v1/jobs/{jobId} with the same key. While it runs, progress goes from 0 to 100 and progressDetail reports pages_done of pages_to_parse. When status is completed, result holds the same fields as a 200 response, plus page_status: one entry per page, parsed, no_text_layer or not_parsed (past maxPages). A job whose parse fails has status: "failed", an error that starts with the code (for example no_text_layer: ...) and progressDetail.code.
- Billing. The credits for the pages to parse are held when the job is queued (402 on the Free plan if the balance cannot cover them, and nothing is queued). When the job ends they are settled to the pages actually parsed and the rest is refunded. A failed job costs 0.
- Result lifetime. A finished job and its result are kept for 24 hours, then
resultis gone and the job showsexpired: true. An uploaded document is dropped from the queue as soon as the job has read it. - Webhook. With
webhook, the job POSTs a signedparse.completedorparse.failedevent with the job id, status, page counts andcredits_charged. Fetch the content fromGET /v1/jobs/{jobId}; the event does not carry it. - Zero data retention. A job stores its result, so a key or account with zero data retention cannot start one:
async: true, or a document that needs a job, returns 400zdr_unsupported. Documents up to the in-request limit of 300 pages still parse in the request. - No job queue. Where the server has no job queue, a document that needs a job returns 503
async_unavailablewithsync_max_pages. Nothing is parsed or charged; sendmaxPageswithin that number to parse in the request. - A job reads the document again in the worker. If a linked document has grown past the pages held for it, the job fails with
document_changedand is refunded. - A job parses only while its credit hold is live. If the job could not start before the hold ran out, it fails with
parse_job_expired, parses nothing and costs nothing. - A job uses the same isolated parser and honest statuses as a request. Page images are not produced.
Scanned documents
There is no OCR on this endpoint yet. A page without a text layer is listed in pages_without_text; a document where no page has text returns 422 no_text_layer. We do not guess at text we could not read.
Limits
Each parse runs in its own short-lived process with no network access and no credentials. The limits are:
| Limit | Value | When exceeded |
|---|---|---|
| Pages parsed in the request | 50 | the parse runs as an async job (202) |
| Pages in a document parsed in the request | 300 | an async job; with async: false, or where no job can run, 413 page_limit / 503 async_unavailable, before any page is parsed |
| Pages in a document parsed by a job | 2,000 | 413 page_limit, before any page is parsed |
| Job parse time, CPU | 10 min, 9 min | as for a request |
| Job parser memory | 512 MB heap, 1 GB RSS | as for a request |
| Job result kept | 24 h | result is dropped, expired: true |
| Job credit hold | 1 h (never less than one job run plus a minute) | a job not started in time fails parse_job_expired, refunded |
| Document size (upload or download) | 25 MB | 413 file_too_large / download_too_large |
| Decompressed streams | 256 MB | 413 decompression_limit |
| Image size | 50 million pixels | larger images are skipped |
| Parse time | 60 s | pages already read are returned as partial (truncated_reason: "deadline"); none read → 504 parse_timeout |
| Download time | 30 s | 504 download_timeout |
| Parser memory | 256 MB heap, 512 MB RSS | partial with truncated_reason: "memory", or 422 parse_resource_limit |
| Parser CPU | 45 s | partial with truncated_reason: "cpu", or 422 parse_resource_limit |
| Extracted text | 20 million characters | partial with truncated_reason: "text_budget" |
| Parses at once (download included) | 2 (8 waiting) | 503 parser_busy with retry_after |
The parser can also run on a native engine, which reads PDFs with pdf-inspector and DOCX files with AnyDoc, on the server, inside the same isolated process and limits. Your document is never sent to a third-party service. method names the parser that ran.
Size limits apply to the decoded body, so a gzip-encoded or chunked download is cut off at the same point as a plain one.
Errors
Every error carries code, error (message), ok: false, status: "failed", method, source, pages_total, pages_parsed and credits_charged: 0. Failed parses are not billed.
| Status | code | Cause |
|---|---|---|
| 400 | missing_file / invalid_multipart | Multipart request with no usable file part |
| 400 | missing_url / invalid_url / invalid_json | JSON path without a valid url |
| 400 | blocked_url | URL rejected by the SSRF guard (private, loopback or metadata address, including via redirect) |
| 400 | invalid_max_pages | maxPages is not a positive integer |
| 400 | invalid_async / invalid_webhook | async is not a boolean, or webhook is not a public http(s) URL |
| 400 | zdr_unsupported | The document needs an async job and the key or account has zero data retention |
| 402 | Credit balance exhausted | Free plan: the balance cannot cover the pages to be parsed. Body includes required and balance. No page was parsed |
| 413 | page_limit | More pages than the limit that applies (2,000 pages where jobs run, 300 pages with async: false). Body includes pages_total and max_pages |
| 413 | file_too_large / download_too_large / decompression_limit | Size limits above |
| 422 | no_text_layer | No page has extractable text (scanned or image-only) |
| 422 | invalid_document / encrypted_document | Corrupt, unsupported or password-protected file |
| 422 | fetch_failed | URL fetch returned a non-2xx status or failed |
| 422 | parse_resource_limit / parser_crashed | The parser hit a memory/CPU limit or exited before reading any page |
| 503 | parser_busy | All parser slots are in use; retry after retry_after seconds |
| 503 | parser_unavailable | The server's runtime cannot start the isolated parser (it never falls back to an unrestricted one) |
| 503 | async_unavailable | The document needs an async job and this server has no job queue. Body includes pages_total and sync_max_pages |
| 503 | enqueue_failed | The job could not be queued; the hold was refunded. Retry shortly |
| 503 | enqueue_uncertain | The queue could not confirm the job. Poll status_url: if the job exists it runs and bills; if it answers 404, nothing is charged and the held credits return when the hold expires |
| 504 | parse_timeout / download_timeout | Deadline reached before any page was read, or the document server was too slow |
Notes
- Results are cached for 24 hours by content hash (uploads) or URL, and by
maxPages. Stops caused by the deadline, memory, CPU or cancellation are never cached. Async jobs neither read nor write this cache; their result lives with the job. - With
SCRAPER_MOCK_MODE=true, both paths return a small fixed sample document (mock: true), useful for integration testing without burning credits.