Skip to content

Update a model (schema, strategy, output tags…)

PUT
/api/models/{modelId}
curl --request PUT \
--url https://api.langparse.dev/api/models/mdl_inv01 \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <X-Api-Key>' \
--data '{ "name": "Invoice", "slug": "invoice", "fields": [ { "title": "Invoice Number", "name": "example", "type": "text", "required": true, "multiple": true, "transform": "example", "validators": [ "example" ], "children": [] } ], "rule": "example", "enhance": true, "reconcile": { "total": "example", "items": "example", "amount": "example", "tolerance": 1 }, "outputTags": [ { "name": "InvoiceTotal", "expression": "${data.invoice_total}", "toSource": true, "toDestination": true } ], "strategy": {} }'

Update a model. Send the full model body — this replaces the schema, strategy, validation rule, and output tags, so omitted properties are cleared. Existing parsed documents are unaffected.

modelId
required
string
Example
mdl_inv01
Media typeapplication/json
object
name
required
string
Example
Invoice
slug

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

string
Example
invoice
fields
Array<object>
object
title
required
string
Example
Invoice Number
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
Example
InvoiceTotal
expression
required
string
Example
${data.invoice_total}
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

The updated 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
Examplegenerated
{
"data": {}
}

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

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