Define what to extract: Specs
What you get
A Spec is the one definition of the data you want from a kind of document: its fields, their types and formats, the values they may take, and the checks they must pass. Talonic reads each document, fills every field in your Spec, and links each value to the page and passage it came from. This page is for the person who decides what a team extracts, in the app or from code.
Before you start
- Editing and publishing a Spec needs the Member role or above.
- API keys need
specs:readto read Specs andspecs:writeto create schemas or change the rail. - Upload three to five representative documents first: one typical, one with unusual layout, one with missing values. They become your samples.
What a Spec holds
- Fields: a name, a display name, a type (
string,number,integer,boolean,date,enum,array,object) and an optional description. A one-line description ("Invoice total including tax") is the single biggest lever on accuracy; Talonic also suggests field names it has already seen in your documents. - Lists and tables: an
arrayofobjectfields captures line items and other repeating rows, one row per item. - Formats and allowed values: a pattern a value must match (for example
^PO-\d{6}$) with a choice of what happens on a mismatch (clear it, flag it, or replace it with a fixed value), a date or number output format, allowed values for anenum, length limits, and checks across fields such asdue_date >= invoice_date. - Reference values: a table of codes and labels (country names to ISO codes, contract types to your internal codes), uploaded as CSV or linked to a reference dataset, so values come out in your codes. Unmatched values are flagged for you to add.
- Instructions: plain-language guidance for a hard field, such as where to look or how to compute it.
- Checks and review: validation checkpoints that hold failing values for review (see Check and validate results).
Do it in the app
- Open Specs (
/specs) and click New Spec. Describe what you need in a sentence ("supplier invoices: vendor, number, dates, totals and line items") and attach sample documents, or import fields from an Excel, CSV or JSON file. - Review the suggested fields: rename them, set types and formats, add allowed values or a reference table, and drag rows into the order your output columns should have.
- Pin up to five sample documents and click Preview. Talonic runs the whole Spec over exactly those samples, so a preview before and after a change is directly comparable.
- Adjust instructions or formats for any field that came out wrong, and preview again.
- Click Publish. Each publish creates a new numbered version; runs use the published version, never your draft.
- To undo a change, open the version history, compare two versions, and roll back. A rollback publishes the old configuration as a new version, so history is never rewritten.
Do it with the API
Specs are authored in the app. The API reads them and their versions at /v1/specs, /v1/specs/{id} and /v1/specs/{id}/versions. A Spec publishes onto a schema with its own id: read schema_id from the Spec, and the schema's spec_id to go back. You can also define a schema directly with POST /v1/schemas (JSON Schema, a fields array, or a flat name-to-type map) and use it with /v1/extract or as the base of a Spec. A schema owned by a Spec is read-only over the API (409), because the next publish would overwrite the change.
curl -X POST https://api.talonic.com/v1/schemas \
-H "Authorization: Bearer $TALONIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoice Schema",
"definition": {
"invoice_number": "string",
"vendor_name": "string",
"invoice_date": "date",
"total_amount": "number"
}
}'
curl "https://api.talonic.com/v1/specs/e2144027-39c0-44e8-a196-72be1e360749/versions" \
-H "Authorization: Bearer $TALONIC_API_KEY"import { Talonic } from '@talonic/node'
const talonic = new Talonic({ apiKey: process.env.TALONIC_API_KEY })
const schema = await talonic.schemas.create({
name: 'Invoice Schema',
definition: {
fields: [
{ name: 'vendor_name', type: 'string', description: 'Legal name of the vendor' },
{ name: 'total_amount', type: 'number', required: true },
{ name: 'line_items', type: 'array', children: [
{ name: 'description', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'unit_price', type: 'number' },
] },
],
},
}){
"data": [
{ "version": 3, "content_hash": "9f2c…", "created_at": "2026-04-25T14:30:00.000Z", "is_materialized": true },
{ "version": 2, "content_hash": "41ab…", "created_at": "2026-04-22T10:05:00.000Z", "is_materialized": false }
]
}is_materialized marks the version a new run uses. Identical content_hash values mean identical Specs, so storing the hash your integration was tested against is a cheap way to notice a change. For schemas not owned by a Spec, GET /v1/schemas/{id}/versions/diff?from=2&to=3 compares versions and POST /v1/schemas/{id}/versions/rollback with version_number restores one as a new version. Reference: List Specs, Published versions, Create a schema.
Do it with an agent
talonic_list_specs and talonic_get_spec read Specs; talonic_save_schema, talonic_update_schema and talonic_get_schema manage schemas; talonic_run_spec runs a published Spec. Ask: "Draft a schema for our delivery notes with sender, recipient, date and a table of items, then show me the fields."
Limits and costs
- Up to five pinned samples per Spec. Schema names up to 100 characters.
- Creating, editing and publishing a Spec is not charged. When it runs, each value Talonic has to work out costs 20 credits; values filled from what Talonic already knows from your documents are free. See Billing, credits and usage.
- Patterns are checked for safety when saved, and values longer than 1,000 characters are not pattern-checked.
Errors
| Parameter | Type | Description |
|---|---|---|
| 400 | validation_error | The definition produced no fields, or an id is not a UUID. Send at least one field. |
| 404 | not_found | No Spec with this id. If you used a schema id, call `GET /v1/schemas/{id}` and read `spec_id`. |
| 409 | conflict | The schema is owned by a Spec. Edit and publish it in the app. |
| 429 | rate_limited | Wait for `Retry-After`, then retry. |
PUT /v1/schemas/{id} recreates every field from its name, type, description and required flag only, so instructions and reference tables set in the app are dropped. Send only name or description to rename.Next
Frequently asked questions
Why does my Spec id return 404 on /v1/schemas?+
GET /v1/specs/{id} and use the schema_id it returns, or read spec_id from a schema to find its Spec.