More endpoints
POST /v1/parse

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
FieldTypeRequiredDescription
urlstringYes (JSON path only)URL of a PDF or DOCX document to fetch and parse.
formatstringNo"markdown" (default), "text" or "rag". "rag" adds heading-aware chunks[] to the response. On a multipart upload, send it as a form field.
chunkSizenumberNorag only. Characters per chunk, default 1,000, clamped to 100–20,000.
chunkOverlapnumberNorag only. Characters shared by neighbouring chunks, default 100.
maxPagesintegerNoPDF 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.
asyncbooleanNotrue: 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.
webhookstringNoA 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.

FieldTypeDescription
okbooleantrue 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
parserstringSame value as method
source"upload" | "url"Where the document came from
markdownstringDocument content converted to markdown (one ## Page n section per page with text)
textstringPlain-text extraction
format"pdf" | "docx"Detected document format
pages_totalnumber | nullPages in the document. null for DOCX, which has no fixed pages
pages_parsednumber | nullPages whose text was extracted
pagesnumber | undefinedSame as pages_total (kept for older clients)
truncatedbooleantrue when the parser stopped before the last page
truncated_reasonstringmax_pages (your maxPages ended the parse), deadline, memory, cpu, cancelled, crash or text_budget
partial_reasonstringno_text_layer when some pages are scanned or image-only
pages_without_textnumber[]1-based pages with no extractable text
outputFormatstringThe format you asked for
chunksobject[] | undefinedrag only: { position, text, heading, headingLevel, headingPath, charStart, charEnd, url? }
totalChunksnumber | undefinedrag only: number of chunks
chunksTruncatedboolean | undefinedrag only: true when chunking stopped at the 2,000-chunk cap
cachedbooleantrue when served from the 24h cache. A cached partial stays partial
credits_chargednumberCredits 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 result is gone and the job shows expired: true. An uploaded document is dropped from the queue as soon as the job has read it.
  • Webhook. With webhook, the job POSTs a signed parse.completed or parse.failed event with the job id, status, page counts and credits_charged. Fetch the content from GET /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 400 zdr_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_unavailable with sync_max_pages. Nothing is parsed or charged; send maxPages within 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_changed and 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:

LimitValueWhen exceeded
Pages parsed in the request50the parse runs as an async job (202)
Pages in a document parsed in the request300an 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 job2,000413 page_limit, before any page is parsed
Job parse time, CPU10 min, 9 minas for a request
Job parser memory512 MB heap, 1 GB RSSas for a request
Job result kept24 hresult is dropped, expired: true
Job credit hold1 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 MB413 file_too_large / download_too_large
Decompressed streams256 MB413 decompression_limit
Image size50 million pixelslarger images are skipped
Parse time60 spages already read are returned as partial (truncated_reason: "deadline"); none read → 504 parse_timeout
Download time30 s504 download_timeout
Parser memory256 MB heap, 512 MB RSSpartial with truncated_reason: "memory", or 422 parse_resource_limit
Parser CPU45 spartial with truncated_reason: "cpu", or 422 parse_resource_limit
Extracted text20 million characterspartial 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.

StatuscodeCause
400missing_file / invalid_multipartMultipart request with no usable file part
400missing_url / invalid_url / invalid_jsonJSON path without a valid url
400blocked_urlURL rejected by the SSRF guard (private, loopback or metadata address, including via redirect)
400invalid_max_pagesmaxPages is not a positive integer
400invalid_async / invalid_webhookasync is not a boolean, or webhook is not a public http(s) URL
400zdr_unsupportedThe document needs an async job and the key or account has zero data retention
402Credit balance exhaustedFree plan: the balance cannot cover the pages to be parsed. Body includes required and balance. No page was parsed
413page_limitMore pages than the limit that applies (2,000 pages where jobs run, 300 pages with async: false). Body includes pages_total and max_pages
413file_too_large / download_too_large / decompression_limitSize limits above
422no_text_layerNo page has extractable text (scanned or image-only)
422invalid_document / encrypted_documentCorrupt, unsupported or password-protected file
422fetch_failedURL fetch returned a non-2xx status or failed
422parse_resource_limit / parser_crashedThe parser hit a memory/CPU limit or exited before reading any page
503parser_busyAll parser slots are in use; retry after retry_after seconds
503parser_unavailableThe server's runtime cannot start the isolated parser (it never falls back to an unrestricted one)
503async_unavailableThe document needs an async job and this server has no job queue. Body includes pages_total and sync_max_pages
503enqueue_failedThe job could not be queued; the hold was refunded. Retry shortly
503enqueue_uncertainThe 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
504parse_timeout / download_timeoutDeadline 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.