Skip to content

Parse a document

POST
/api/v1/documents
curl --request POST \
--url https://api.langparse.dev/api/v1/documents \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <X-Api-Key>' \
--data '{ "file": { "id": "file_mrb1a2c3d4" }, "model": "mdl_inv01" }'

Parse a file into a document. Provide a file (a FileRef) and exactly one parsing strategy: model (a specific model), router (classify across a router, then parse), schemaless (infer the structure), or auto (detect the best model, then parse). ⚠️ Do not combine strategies — e.g. sending both model and router is a 400. Async: returns 202 with a poll URL.

Media typeapplication/json

Parse request. file is required; then exactly one of model / router / schemaless / auto.

object
file
required
One of:
By id
object
id
required

An existing file id (from POST /v1/files or a folder listing).

string
hint

Free-text steer for schemaless/auto (e.g. “pull the line items”).

string
extractor

Override the extractor (vision) model.

string
pages

1-indexed pages to parse; omit for all.

Array<integer>
callbackUrl

POSTed the result when parsing finishes (instead of polling).

string
callbackSecret

HMAC secret for the callback signature.

string
resultShape
string
Allowed values: full data-only
idempotencyKey

Repeat-safe: the same key returns the original document (also accepted as the Idempotency-Key header).

string
One of:
With a model
object
model
required

Model id (mdl_…) OR its friendly key/slug — parse with this model.

string
Examples

Parse an existing file with a model

{
"file": {
"id": "file_mrb1a2c3d4"
},
"model": "mdl_inv01"
}

Accepted — poll pollUrl for the result.

Media typeapplication/json
object
data
required

Async accept — the parse is queued. Poll pollUrl.

object
id
string
status
string
Allowed values: queued
debugId
string
pollUrl
string
Example
{
"data": {
"id": "doc_mrb1x9y8z7",
"status": "queued",
"pollUrl": "/api/v1/documents/doc_mrb1x9y8z7"
}
}

Invalid body, or more than one strategy (model/router/schemaless/auto) was provided.

Media typeapplication/json

Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.

object
statusCode
integer
statusMessage
string
Example
{
"statusCode": 404,
"statusMessage": "Document not found"
}

Missing or invalid API key.

Media typeapplication/json

Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.

object
statusCode
integer
statusMessage
string
Example
{
"statusCode": 404,
"statusMessage": "Document not found"
}

Insufficient credits — top up to continue parsing.

Media typeapplication/json

Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.

object
statusCode
integer
statusMessage
string
Example
{
"statusCode": 404,
"statusMessage": "Document not found"
}

Model / router / file not found.

Media typeapplication/json

Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.

object
statusCode
integer
statusMessage
string
Example
{
"statusCode": 404,
"statusMessage": "Document not found"
}