Skip to main content
POST

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

How to parse a document. The same options apply to POST /parse and to every document in POST /parse/batch.

url
string<uri>

A link to the document, starting with http:// or https://. Links to private or internal addresses aren't allowed. Send this, fileId or a file upload, not more than one.

Example:

"https://arxiv.org/pdf/1706.03762"

fileId
string<uuid>

The fileId of a document you parsed, estimated or uploaded in the last 24 hours. It isn't downloaded or uploaded again.

Example:

"0b007010-b3f6-4398-a3ba-e5c2518839c8"

mode
enum<string>
default:auto

How pages are read.

  • auto: reads each page's text, and uses AI only on pages that are scans or images.
  • fast: reads text only. Scanned pages come back empty with an error and aren't charged.
  • ocr: reads every page with AI. Slower, and best for scans and handwriting.
Available options:
auto,
fast,
ocr
pages
string

PDF pages to parse, as pages and ranges separated by commas. "10-" means page 10 to the end. Pages past the end are skipped. Other formats ignore this and are parsed whole, with a warning.

Maximum string length: 500
Example:

"1-5,9"

maxPages
integer

Parse at most this many pages, counted from the start of pages (or of the document). PDFs only.

Required range: x >= 1
Example:

3

includePages
boolean
default:false

Adds pages to the result, with each page's Markdown on its own. perPage is accepted as another name for this field. Only applies when the result comes back inline; when polling, use ?pages=true instead.

pageMarkers
boolean
default:false

Puts a <!-- page N --> line before each page in markdown.

prompt
string

What to extract from the document, in plain English, such as "The paper's title and the authors' names". The answer is in json. Costs AI credits on top of the page credits.

Maximum string length: 5000
schema
object

A JSON Schema for the extracted data. The answer is in json and follows this shape. Can be sent with or without a prompt. In a multipart request, send it as a JSON string.

dryRun
boolean
default:false

Returns the page count and the credits the parse would cost, without parsing or charging anything. The document is still stored, so you can parse it next with the returned fileId.

wait
boolean
default:true

Waits up to 20 seconds for the result and returns it inline. Set to false to get a job to poll straight away. POST /parse only; a batch never waits.

Response

The document finished within 20 seconds (status is completed or failed), or dryRun was true and this is the estimate.

A parse job, with its result once it has finished.

jobId
string<uuid>

The job's ID. Use it with GET /parse/{jobId}.

status
enum<string>
  • queued: waiting to start.
  • running: being parsed. progress says how far it has got.
  • completed: finished. The result is in markdown, and json when you asked for extraction.
  • failed: couldn't be parsed. error says why, and you aren't charged.
Available options:
queued,
running,
completed,
failed
fileName
string

The document's file name, or the last part of the link it came from.

sourceUrl
string | null

The link the document was downloaded from, after redirects. null for uploads.

fileId
string<uuid>

The stored document's ID. Send it as fileId to parse the same document again for 24 hours without uploading or downloading it again.

format
string | null

The document's format, such as PDF, Word, Excel or PowerPoint.

totalPages
integer | null

How many pages the document has. For formats without pages, an estimate of one page per 3,000 characters of text.

pagesParsed
integer | null

How many pages were read and charged. null until the job finishes.

creditsUsed
integer

Credits charged for this job, including AI credits for extraction. 0 until the job has completed, and for a failed job.

error
string

Only when status is failed. Why the document couldn't be parsed, such as "This PDF is password protected. Remove the password and try again."

progress
object

Only while the job is queued or running, once it has started reading pages.

markdown
string

Once completed. The whole document as Markdown, pages joined by blank lines.

pages
object[]

Only when you asked for it (includePages, or ?pages=true when polling). Each page on its own.

json
any

Only when you sent a prompt or schema. The extracted data.

warnings
string[]

Once completed. Anything worth knowing about the result, such as "2 of 15 pages couldn't be read and aren't charged." or that page selection was ignored for a non-PDF document. Empty when there's nothing to report.

metadata
object

Once completed. Facts about the parsed document.

durationMs
integer | null

Once completed. How long parsing took, in milliseconds.