Skip to content

Create a model

POST
/api/models
curl --request POST \
--url https://api.langparse.dev/api/models \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <X-Api-Key>' \
--data '{ "name": "Invoice", "fields": [ { "title": "Invoice Number", "type": "text", "required": true } ] }'

Create a model — a named extraction schema. fields define what to pull (text / number / date / boolean / select / list / object); list and object fields nest their own children. Optionally attach an extraction strategy, a validation rule, and outputTags.

Media typeapplication/json
object
name
required
string
slug

Friendly, URL-safe key (unique per org). Auto-derived from the name when omitted; editable. Usable in place of the model id.

string
fields
Array<object>
object
title
required
string
name

Output JSON key. Any style (kept verbatim); snake_case is derived from title when omitted.

string
type
required
string
Allowed values: text number date boolean select list object image synthesize
required
boolean
multiple

List: repeated rows (default true). object: array of objects (default false).

boolean
transform

Per-field JS (value, doc) => newValue.

string
validators

Validator ids to run on the value — built-in (e.g. iban, nzbn, abn, vat_eu, aba_routing, iso_date) or a custom val_…. A failure flags the document for review.

Array<string>
children
Array<object> recursive
rule

Document validation JS (doc, ctx) => void.

string
enhance

Enhance scan-like pages (deskew / denoise / contrast / crop) before extraction. Digital PDFs are untouched.

boolean
reconcile

Totals reconciliation — flag when total ≠ sum of the items list’s amount field.

object
total

Top-level number field holding the document total.

string
items

Top-level list field holding the line items.

string
amount

Field within each list row holding the line amount.

string
tolerance

Absolute rounding tolerance (default 0.01).

number
outputTags
Array<object>

An S3 object tag projected from parsed data. Use ${data.field}, ${dest.uri/bucket/key} or literals.

object
name
required
string
expression
required
string
toSource

Tag the original source file (S3 sources).

boolean
toDestination

Tag the delivered output object.

boolean
strategy

{ kind: single|consensus, extractors: […], judge? }

object
key
additional properties
any
Example
{
"name": "Invoice",
"fields": [
{
"title": "Invoice Number",
"type": "text",
"required": true
}
]
}

The created model.

Media typeapplication/json
object
data
required

A model (schema + strategy + output tags). Own key id; slug is a friendly, unique-per-org handle accepted anywhere the id is.

object
key
additional properties
any
Example
{
"data": {
"id": "mdl_inv01",
"slug": "invoice",
"name": "Invoice",
"description": "Supplier invoices with line items, taxes and totals.",
"fieldCount": 12,
"fieldPreview": [
"Invoice Number",
"Invoice Date",
"Total"
],
"strategy": "single",
"features": [],
"coverUrl": null,
"updatedAt": "2026-07-07T04:50:26.659Z",
"fields": []
}
}

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"
}