Author a Spec
Create a Spec from a document or an export, edit its draft, check it, test it on sample files, publish it and read rows with evidence, all with an API key or OAuth.
Everything you do in the Spec editor you can do over the API: create a Spec, edit its draft, check it, test it on samples, publish it, compare versions, roll back, share it, draft rules and review ground truth. The API calls the same operations as the editor, so a Spec authored here opens in the editor exactly as you left it, and the other way round.
Access
Reads need the specs:read scope and writes specs:write; testing also needs runs:write, because a test is a run. A credential never reaches further than the person it acts for: each write is allowed exactly when that person may make the same change in the Spec editor of this workspace. In a workspace where Spec changes are managed by Talonic, writes return 403 with reason: insufficient_role. Ask GET /v1/specs/authoring first and an agent knows what it can do before it tries.
/v1/specs/authoringResponse fields
runs:write too).From a sample file to rows with evidence
- Upload a sample file (
POST /v1/documentsorPOST /v1/sources/{id}/documents) and keep itsdocument_id. - Create the Spec with its fields:
POST /v1/specswithnameand adoc. - Check it:
POST /v1/specs/{id}/check. Fix every entry inerrorswithPUT /v1/specs/{id}/draft. - Test it on the sample:
POST /v1/specs/{id}/testwithdocument_ids. Polllinks.progress, then readlinks.resultswith?include=provenance. - Publish:
POST /v1/specs/{id}/publish. New runs now use this version. - Run it on new documents:
POST /v1/runwith the publishedschema_idasspec_id, and read the rows the same way.
Create, check, test and publish
# 1. create the Spec with two fields
curl -X POST https://api.talonic.com/v1/specs \
-H "Authorization: Bearer $TALONIC_API_KEY" -H "Content-Type: application/json" \
-d '{"name":"Invoices","doc":{"format":1,"name":"Invoices",
"fields":[
{"field_id":"f-vendor","name":"vendor_name","data_type":"string","description":"Legal name of the issuing company"},
{"field_id":"f-total","name":"total_amount","data_type":"number","description":"Invoice total including tax"}],
"stages":[{"id":"s-source","type":"source"},{"id":"s-extract","type":"extraction","config":{}},{"id":"s-deliver","type":"deliver"}],
"gates":[],"policies":[]}}'
# 2. check the draft
curl -X POST https://api.talonic.com/v1/specs/$SPEC_ID/check \
-H "Authorization: Bearer $TALONIC_API_KEY"
# 3. test it on the uploaded sample
curl -X POST https://api.talonic.com/v1/specs/$SPEC_ID/test \
-H "Authorization: Bearer $TALONIC_API_KEY" -H "Content-Type: application/json" \
-d '{"document_ids":["'$DOCUMENT_ID'"]}'
# 4. rows with evidence, once the test run completes
curl "https://api.talonic.com/v1/pipelines/$PIPELINE_ID/results?include=provenance" \
-H "Authorization: Bearer $TALONIC_API_KEY"
# 5. publish
curl -X POST https://api.talonic.com/v1/specs/$SPEC_ID/publish \
-H "Authorization: Bearer $TALONIC_API_KEY" -H "Content-Type: application/json" \
-d '{"expected_draft_revision": 1}'GET /v1/specs/{id}/draft, and use its doc as your template.Create, import and rename
/v1/specsBody
format: 1). Omit for an empty draft./v1/specs/importBody
/v1/specs/{id}Errors
Error responses
specs:write (or runs:write for a test).Frequently asked questions
Can an API key change a Spec my Admin could not change in the editor?+
Is a Spec live as soon as I create it?+
Where do I get a valid Spec document?+
GET /v1/specs/{id}/draft and reuse its doc, or import a Spec JSON export the editor produced.