@talonic/docs 0.21.29 → 0.21.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content.js +1264 -152
- package/dist/seo.js +1185 -23
- package/openapi.json +1185 -23
- package/package.json +1 -1
- package/dist/tailwind-preset.d.cts +0 -45
- package/dist/tailwind-preset.d.ts +0 -45
package/dist/content.js
CHANGED
|
@@ -18166,7 +18166,8 @@ var sections31 = [
|
|
|
18166
18166
|
"`process.completed` \u2014 A document processing run finished all steps and the result is available.",
|
|
18167
18167
|
"`process.failed` \u2014 A document processing run failed. The error payload includes the step name and error detail.",
|
|
18168
18168
|
"`run.completed` \u2014 A `POST /v1/run` Spec pipeline finished; structured output is available (review-held fields null). The payload carries `records[]` \u2014 always an array, one `{document_id, filename, data, metadata?, batch_id?}` entry per output row (`metadata`/`batch_id` are the submitting request's per-input tags, present only when set) \u2014 alongside the legacy `structured_data` field kept for compatibility; prefer `records`.",
|
|
18169
|
-
"`run.failed` \u2014 A `POST /v1/run` Spec pipeline failed because every document errored during ingest or extraction. When the failure occurred at the ingest leg, the `error` payload includes `document_ids`, the best-effort list of documents that were being ingested."
|
|
18169
|
+
"`run.failed` \u2014 A `POST /v1/run` Spec pipeline failed because every document errored during ingest or extraction. When the failure occurred at the ingest leg, the `error` payload includes `document_ids`, the best-effort list of documents that were being ingested.",
|
|
18170
|
+
"`run.cancelled` \u2014 A Spec pipeline was stopped through `POST /v1/run/:id/cancel` or `POST /v1/pipelines/:id/cancel`. Every live `/v1/run` request on the pipeline receives its own event (`run_id` set); the pipeline-level copy has none. The payload carries `reason` and `cancelled_at`, never output rows; results completed before the cancel stay readable."
|
|
18170
18171
|
] },
|
|
18171
18172
|
{ type: "paragraph", text: "Most integrations subscribe to `extraction.complete` to trigger downstream processing, for example writing structured data to a database or notifying a user. A typical workflow is to pass `webhook_url` on `POST /v1/extract`, then handle the callback payload in your server without polling. New webhook configurations subscribe to `extraction.complete` and `extraction.failed` by default." },
|
|
18172
18173
|
{ type: "paragraph", text: "The `data` object of each payload is event-specific. For `extraction.complete` it includes the `document_id`, `extraction_id`, `filename`, `field_count`, and `confidence_overall` score. Use the `extraction_id` to fetch the full result via `GET /v1/extractions/:id` when the payload does not contain all the fields you need." },
|
|
@@ -33934,10 +33935,10 @@ var sections56 = [
|
|
|
33934
33935
|
seoTitle: "Poll a Spec Run \u2014 GET /v1/run/:id \u2014 Talonic Docs",
|
|
33935
33936
|
description: "Poll a /v1/run request by id: run status folded with live pipeline progress, per-document completion counts, and the echoed batch_id and metadata tags.",
|
|
33936
33937
|
content: [
|
|
33937
|
-
{ type: "paragraph", text: "The **Poll a Run** endpoint, `GET /v1/run/:id`, reads a `/v1/run` request by the `run_id` returned on submission. The response folds the request row together with the compiled pipeline's live progress. The public status vocabulary is
|
|
33938
|
+
{ type: "paragraph", text: "The **Poll a Run** endpoint, `GET /v1/run/:id`, reads a `/v1/run` request by the `run_id` returned on submission. The response folds the request row together with the compiled pipeline's live progress. The public status vocabulary is four states: `processing` covers both ingestion/OCR (before a pipeline exists) and the compiled pipeline actually executing, ending at `completed`, `failed`, or `cancelled` (the run, or the pipeline behind it, was stopped through `POST /v1/run/:id/cancel` or `POST /v1/pipelines/:id/cancel`)." },
|
|
33938
33939
|
{ type: "paragraph", text: "Once the pipeline exists, `pipeline_id` is set and a `progress` object reports per-document counts \u2014 how many documents finished, and how many errored. A run reports `failed` only when **every** document errored (no usable output); a run where some documents succeeded and some errored completes with the error count visible in `progress.error_documents`." },
|
|
33939
33940
|
{ type: "paragraph", text: "The response also echoes `documents[]` \u2014 the same array returned at submission, each entry augmented with a per-document `status` (`processing`, `completed`, or `failed`) so you can tell which specific inputs are still in flight without waiting for the whole run to finish. `documents[]` is omitted for runs submitted before this field existed." },
|
|
33940
|
-
{ type: "callout", variant: "info", text: "Poll this endpoint, not the pipeline: the run request is the stable public handle, and its status is folded live at read time. The same terminal states also fire the run.completed / run.failed webhooks, so poll or subscribe \u2014 whichever fits your integration." },
|
|
33941
|
+
{ type: "callout", variant: "info", text: "Poll this endpoint, not the pipeline: the run request is the stable public handle, and its status is folded live at read time. The same terminal states also fire the run.completed / run.failed / run.cancelled webhooks, so poll or subscribe \u2014 whichever fits your integration. To stop a run, POST /v1/run/:id/cancel \u2014 it cancels the whole pipeline behind the request, including other requests appended to it." },
|
|
33941
33942
|
{
|
|
33942
33943
|
type: "endpoint",
|
|
33943
33944
|
method: "GET",
|
|
@@ -33962,7 +33963,7 @@ var sections56 = [
|
|
|
33962
33963
|
params: [
|
|
33963
33964
|
{ name: "run_id", type: "uuid", description: "The run request id." },
|
|
33964
33965
|
{ name: "spec_id", type: "uuid", description: "The Spec being run." },
|
|
33965
|
-
{ name: "status", type: "string", description: "processing, completed, or
|
|
33966
|
+
{ name: "status", type: "string", description: "processing, completed, failed, or cancelled. processing covers both the pre-pipeline ingestion/OCR wait and the pipeline actually executing; cancelled means the run was stopped and finished documents keep their results." },
|
|
33966
33967
|
{ name: "pipeline_id", type: "uuid | null", description: "The compiled pipeline, once it exists." },
|
|
33967
33968
|
{ name: "pipeline_mode", type: "string", description: "Present only when recorded: the effective mode the run resolved to (new or append). Under append the pipeline is shared across requests, and status/progress are scoped to THIS request's own documents." },
|
|
33968
33969
|
{ name: "input_count", type: "integer", description: "Total inputs accepted at submission." },
|
|
@@ -34041,7 +34042,7 @@ var sections56 = [
|
|
|
34041
34042
|
content: [
|
|
34042
34043
|
{ type: "paragraph", text: '`GET /v1/run/{id}/results` returns **this `/v1/run` request\'s own structured rows** as poll-able JSON \u2014 the same governed read behind `GET /v1/pipelines/{id}/results` (review holdback, demoted-field projection, `__` diagnostics filtering, assembly awareness), scoped to exactly the documents *this call* submitted. It answers "what did MY submitted documents produce," which is the question most `/v1/run` integrations actually have, without needing to track the compiled `pipeline_id` at all.' },
|
|
34043
34044
|
{ type: "paragraph", text: "This route is ALWAYS the per-document view, scoped to the request's own `documents[]` echo, uniformly across `new` and `append` pipeline modes. This is a **deliberate divergence** from the per-run `run.completed` webhook: for an unscoped, non-append assembly run, that webhook actually delivers COMPOSED rows. Composed output for an assembly run lives at `GET /v1/pipelines/{id}/results?view=composed` instead \u2014 this response's `links.composed_results` points there once a pipeline exists, so the divergence is always discoverable from the response itself." },
|
|
34044
|
-
{ type: "paragraph", text: "Only `document_id` and `include` filter the rows here. `run_id`, `view`, `since`, `until`, and `status` are pipeline-route-only parameters \u2014 supplying any of them 400s with `unsupported_filter` rather than silently ignoring it, since the run itself already IS the scope and its time window is already bounded. `include=cells,provenance,audit` behave exactly as on the pipeline route: `cells` for per-field value/status/confidence/source, `provenance` for
|
|
34045
|
+
{ type: "paragraph", text: "Only `document_id` and `include` filter the rows here. `run_id`, `view`, `since`, `until`, and `status` are pipeline-route-only parameters \u2014 supplying any of them 400s with `unsupported_filter` rather than silently ignoring it, since the run itself already IS the scope and its time window is already bounded. `include=cells,provenance,provenance.nested,audit` behave exactly as on the pipeline route: `cells` for per-field value/status/confidence/source, `provenance` for the per-field entry the webhook sidecar also carries (kind, quote, `match` grade, confidence, path, markdown offsets), `provenance.nested` for per-leaf entries of structured fields, `audit` for the bounded cell-version trail \u2014 see [Pipeline Results](get-pipeline-results) for the full shape and the held-value redaction rules (a held field's value is never exposed under any include)." },
|
|
34045
34046
|
{ type: "paragraph", text: "Two zero-states return `200` with an empty page and a `scope_note` explaining why \u2014 never `404` \u2014 since pollers hit these windows constantly: no compiled pipeline exists yet for this run (still ingesting, or it failed before a pipeline was created), or the run predates per-request document tracking (an echo-less legacy row whose membership is unknowable, so an honest empty page beats a guess). The envelope's `status` folds the same three-state vocabulary as `GET /v1/run/{id}` (`processing`/`completed`/`failed`) and, unlike the pipeline route's own `status`, it DOES settle even when the underlying pipeline is shared under append mode \u2014 poll this route, not the pipeline route, for append integrations that need a status that eventually reaches `completed`." },
|
|
34046
34047
|
{ type: "callout", variant: "info", text: 'Prefer this endpoint over GET /v1/pipelines/{id}/results whenever your integration thinks in terms of "my /v1/run call", not "the pipeline it landed on" \u2014 it needs no pipeline_id bookkeeping and its status always settles, even under append mode.' },
|
|
34047
34048
|
{
|
|
@@ -34055,7 +34056,7 @@ var sections56 = [
|
|
|
34055
34056
|
title: "Query parameters",
|
|
34056
34057
|
params: [
|
|
34057
34058
|
{ name: "document_id", type: "string", description: "Comma-separated document UUIDs (1-100), intersected with this run's own documents echo." },
|
|
34058
|
-
{ name: "include", type: "string", description: "Comma-separated subset of cells, provenance, audit." },
|
|
34059
|
+
{ name: "include", type: "string", description: "Comma-separated subset of cells, provenance, provenance.nested, audit." },
|
|
34059
34060
|
{ name: "limit", type: "integer", default: "25", description: "Maximum records per page (max 100)." },
|
|
34060
34061
|
{ name: "cursor", type: "string", description: "Pagination cursor from a previous response's pagination.next_cursor." }
|
|
34061
34062
|
]
|
|
@@ -39462,7 +39463,7 @@ curl -s -X POST "https://api.talonic.com/v1/pipelines/$PIPELINE_ID/data-product"
|
|
|
39462
39463
|
{ name: "until", type: "string", description: "ISO 8601 timestamp. Only records with completed_at at or before this bound." },
|
|
39463
39464
|
{ name: "status", type: "string", description: "Comma-separated subset of complete, partial, error, processing." },
|
|
39464
39465
|
{ name: "view", type: "string", description: "composed or documents. Defaults to composed when the run has an assembly product set, else documents." },
|
|
39465
|
-
{ name: "include", type: "string", description: "Comma-separated subset of cells, provenance, audit." },
|
|
39466
|
+
{ name: "include", type: "string", description: "Comma-separated subset of cells, provenance, provenance.nested, audit. provenance.nested adds one entry per scalar leaf of a structured (array/object) field." },
|
|
39466
39467
|
{ name: "limit", type: "integer", default: "25", description: "Maximum records per page (max 100)." },
|
|
39467
39468
|
{ name: "cursor", type: "string", description: "Pagination cursor from a previous response's pagination.next_cursor." }
|
|
39468
39469
|
]
|
|
@@ -39490,7 +39491,7 @@ curl -s -X POST "https://api.talonic.com/v1/pipelines/$PIPELINE_ID/data-product"
|
|
|
39490
39491
|
{ name: "data", type: "array", description: "The result records for this page." },
|
|
39491
39492
|
{ name: "data[].fields", type: "object", description: "field_key -> clean value. Held fields are null; demoted fields and __ diagnostics are absent." },
|
|
39492
39493
|
{ name: "data[].cells", type: "object", description: "Present only with include=cells. field_key -> { value, status, confidence, source, document_id, filename }." },
|
|
39493
|
-
{ name: "data[].provenance", type: "object", description: "Present only with include=provenance. field_key -> { kind, text?, derived_reason?, source_document_id?, page_index
|
|
39494
|
+
{ name: "data[].provenance", type: "object", description: "Present only with include=provenance. field_key -> { path, kind, match, text?, derived_reason?, source_document_id?, char_start?, char_end?, page_index?, confidence } \u2014 the same entry shape the pipeline.capture webhook sidecar carries. match (exact | approximate | none) grades the quote against GET /v1/documents/{id}/markdown; char_start/char_end are UTF-16 offsets into that markdown. Held fields project kind-only with match none." },
|
|
39494
39495
|
{ name: "data[].audit", type: "object", description: "Present only with include=audit. field_key -> the cell-version trail, held-redacted whole-trail if the latest version is held." },
|
|
39495
39496
|
{ name: "pagination", type: "object", description: "{ total, limit, has_more, next_cursor } \u2014 cursor keyed on record_id." },
|
|
39496
39497
|
{ name: "pending_review_count", type: "integer", description: "Held cells in this page's records only." },
|
|
@@ -39850,7 +39851,8 @@ curl -s https://api.talonic.com/v1/pipelines/a1b2c3d4-e5f6-7890-abcd-ef123456789
|
|
|
39850
39851
|
related: [
|
|
39851
39852
|
{ label: "Get Pipeline", slug: "get-pipeline" },
|
|
39852
39853
|
{ label: "List Pipelines", slug: "list-pipelines" },
|
|
39853
|
-
{ label: "Run Pipeline", slug: "run-pipeline" }
|
|
39854
|
+
{ label: "Run Pipeline", slug: "run-pipeline" },
|
|
39855
|
+
{ label: "Cancel Pipeline", slug: "cancel-pipeline" }
|
|
39854
39856
|
],
|
|
39855
39857
|
faq: [
|
|
39856
39858
|
{ question: "Does deleting a run delete its source documents?", answer: "No. Deletion removes the run's owned data (value cells, record sets, documents, field states), but the Spec's seed record set and the underlying source documents are untouched." },
|
|
@@ -39860,6 +39862,93 @@ curl -s https://api.talonic.com/v1/pipelines/a1b2c3d4-e5f6-7890-abcd-ef123456789
|
|
|
39860
39862
|
{ question: "What do reads of the run return after the delete?", answer: "GET /v1/pipelines/{id}, /progress, and /results all return 404 not_found once the delete commits, and the run no longer appears in GET /v1/pipelines. Treat that 404 as terminal in polling loops: stop polling and drop any cached poll URLs, since the id will never resolve again." }
|
|
39861
39863
|
],
|
|
39862
39864
|
mentions: ["delete pipeline run", "value cells", "record sets", "tenant isolation", "irreversible deletion", "retention hold", "reconciliation case"]
|
|
39865
|
+
},
|
|
39866
|
+
{
|
|
39867
|
+
slug: "cancel-pipeline",
|
|
39868
|
+
parentSlug: "pipelines",
|
|
39869
|
+
title: "Cancel Pipeline",
|
|
39870
|
+
seoTitle: "Cancel a Running Pipeline \u2014 POST /v1/pipelines/:id/cancel \u2014 Talonic Docs",
|
|
39871
|
+
description: "Stop a running document processing pipeline: no new work starts, documents still in flight are marked cancelled, finished documents keep their results, and the run stays available for new submissions.",
|
|
39872
|
+
content: [
|
|
39873
|
+
{ type: "paragraph", text: "`POST /v1/pipelines/{id}/cancel` **stops a running pipeline**. From the moment the call returns, no new phase starts for any of its documents; documents that were still mid-phase finish their current step and are then marked cancelled; documents that had already completed keep their results and stay readable through `GET /v1/pipelines/{id}/results`. The run's status becomes `cancelled`, and every live `POST /v1/run` request attached to the pipeline is cancelled with it (each receives its own `run.cancelled` webhook)." },
|
|
39874
|
+
{ type: "paragraph", text: "A cancel is not a delete. Nothing is removed, and the pipeline keeps accepting work afterwards: a new `/v1/run` submission in append mode, `POST /v1/pipelines/{id}/rerun`, or adding documents reopens it exactly like a completed run. Cancelling stops further spend; it does not refund calls that were already made." },
|
|
39875
|
+
{ type: "paragraph", text: "The call is idempotent. Cancelling a run that is already `completed`, `cancelled`, or `archived` returns `200` with `already: true` and changes nothing, so a retrying client never fails on its own success. Requires an API key with the `write` scope." },
|
|
39876
|
+
{ type: "callout", variant: "info", text: "Documents that were in flight at the moment of the cancel finish their current phase before stopping (a single model call at most). The response's `documents.cancelled` count is final once `status` reads `cancelled`; poll `GET /v1/pipelines/{id}/progress` to watch the last documents drain." },
|
|
39877
|
+
{
|
|
39878
|
+
type: "endpoint",
|
|
39879
|
+
method: "POST",
|
|
39880
|
+
path: "/v1/pipelines/{id}/cancel",
|
|
39881
|
+
summary: "Stop a running pipeline.",
|
|
39882
|
+
blocks: [
|
|
39883
|
+
{
|
|
39884
|
+
type: "param-table",
|
|
39885
|
+
title: "Body parameters",
|
|
39886
|
+
params: [
|
|
39887
|
+
{ name: "reason", type: "string", required: false, description: "Optional free text (up to 500 characters) recorded on the run and carried by the run.cancelled webhook." }
|
|
39888
|
+
]
|
|
39889
|
+
}
|
|
39890
|
+
]
|
|
39891
|
+
},
|
|
39892
|
+
{
|
|
39893
|
+
type: "code",
|
|
39894
|
+
language: "bash",
|
|
39895
|
+
title: "Request",
|
|
39896
|
+
code: `curl -X POST https://api.talonic.com/v1/pipelines/a1b2c3d4-e5f6-7890-abcd-ef1234567890/cancel \\
|
|
39897
|
+
-H "Authorization: Bearer $TALONIC_API_KEY" \\
|
|
39898
|
+
-H "Content-Type: application/json" \\
|
|
39899
|
+
-d '{"reason": "wrong Spec version"}'`
|
|
39900
|
+
},
|
|
39901
|
+
{ type: "heading", level: 2, id: "cancel-pipeline-response", text: "Response" },
|
|
39902
|
+
{
|
|
39903
|
+
type: "param-table",
|
|
39904
|
+
title: "Response fields",
|
|
39905
|
+
params: [
|
|
39906
|
+
{ name: "id", type: "string", description: "UUID of the pipeline run." },
|
|
39907
|
+
{ name: "status", type: "string", description: "The run's status after the call: cancelled, or the terminal state it already had." },
|
|
39908
|
+
{ name: "already", type: "boolean", description: "True when the run was already terminal and nothing changed." },
|
|
39909
|
+
{ name: "cancelled_at", type: "string | null", description: "ISO-8601 timestamp of the cancellation." },
|
|
39910
|
+
{ name: "documents", type: "object", description: "{ total, completed, cancelled, errored } \u2014 completed documents keep their results; cancelled are the ones this call stopped." },
|
|
39911
|
+
{ name: "run_requests", type: "string[]", description: "run_ids of the /v1/run requests cancelled along with the pipeline." },
|
|
39912
|
+
{ name: "jobs", type: "object", description: "{ removed, failed, scanned, scan_capped, timed_out } \u2014 best-effort removal of the run's queued jobs; a survivor stops at its next checkpoint." }
|
|
39913
|
+
]
|
|
39914
|
+
},
|
|
39915
|
+
{
|
|
39916
|
+
type: "code",
|
|
39917
|
+
title: "Response",
|
|
39918
|
+
code: `{
|
|
39919
|
+
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
39920
|
+
"status": "cancelled",
|
|
39921
|
+
"already": false,
|
|
39922
|
+
"cancelled_at": "2026-08-28T10:15:00.000Z",
|
|
39923
|
+
"documents": { "total": 120, "completed": 83, "cancelled": 37, "errored": 0 },
|
|
39924
|
+
"run_requests": ["9f3c1e2a-0b7d-4c8e-9a1f-2d3e4f5a6b7c"],
|
|
39925
|
+
"jobs": { "removed": 37, "failed": 0, "scanned": 412, "scan_capped": false, "timed_out": false }
|
|
39926
|
+
}`
|
|
39927
|
+
},
|
|
39928
|
+
{ type: "heading", level: 2, id: "cancel-pipeline-errors", text: "Errors" },
|
|
39929
|
+
{
|
|
39930
|
+
type: "param-table",
|
|
39931
|
+
title: "Error responses",
|
|
39932
|
+
params: [
|
|
39933
|
+
{ name: "400", type: "bad_request", description: "Invalid pipeline ID format, or an active organization is required (the master view cannot cancel)." },
|
|
39934
|
+
{ name: "401", type: "unauthorized", description: "Missing or invalid API key." },
|
|
39935
|
+
{ name: "404", type: "not_found", description: "No pipeline with this ID exists for your organization." },
|
|
39936
|
+
{ name: "429", type: "rate_limited", description: "Too many requests. Retry after the period indicated in the Retry-After header." }
|
|
39937
|
+
]
|
|
39938
|
+
}
|
|
39939
|
+
],
|
|
39940
|
+
related: [
|
|
39941
|
+
{ label: "Get Pipeline", slug: "get-pipeline" },
|
|
39942
|
+
{ label: "Pipeline Progress", slug: "get-pipeline-progress" },
|
|
39943
|
+
{ label: "Delete Pipeline", slug: "delete-pipeline" }
|
|
39944
|
+
],
|
|
39945
|
+
faq: [
|
|
39946
|
+
{ question: "What happens to documents that were being processed?", answer: "They finish the phase they are in (at most one model call) and are then marked cancelled. Documents that had already finished keep their results." },
|
|
39947
|
+
{ question: "Can I resume a cancelled run?", answer: "Yes. Rerun it, add documents, or submit to it again in append mode: the run reopens exactly like a completed one. Cancelled documents are retried with the rerun / retry endpoints." },
|
|
39948
|
+
{ question: "Does cancelling refund credits?", answer: "No. Cancelling stops further model calls; calls already made are billed as usual." },
|
|
39949
|
+
{ question: "I submitted through /v1/run \u2014 which endpoint do I use?", answer: "POST /v1/run/{id}/cancel resolves the run to its pipeline and cancels the whole pipeline, including any other requests appended to it; each affected request receives its own run.cancelled webhook." }
|
|
39950
|
+
],
|
|
39951
|
+
mentions: ["cancel pipeline run", "stop processing", "run.cancelled webhook", "idempotent cancel", "append mode"]
|
|
39863
39952
|
}
|
|
39864
39953
|
];
|
|
39865
39954
|
|
|
@@ -46028,264 +46117,1287 @@ var sections_default = [
|
|
|
46028
46117
|
slug: "sdk-introduction",
|
|
46029
46118
|
parentSlug: "sdk-overview",
|
|
46030
46119
|
title: "Introduction",
|
|
46031
|
-
seoTitle: "Node SDK Introduction \u2014
|
|
46032
|
-
description: "Official Talonic SDK for Node.js and TypeScript
|
|
46120
|
+
seoTitle: "Talonic Node.js SDK Introduction \u2014 TypeScript Client Docs",
|
|
46121
|
+
description: "Official Talonic SDK for Node.js and TypeScript: extract structured, schema-validated data from any document with typed resources, retries, and a CLI.",
|
|
46033
46122
|
content: [
|
|
46034
|
-
{
|
|
46035
|
-
|
|
46036
|
-
|
|
46123
|
+
{
|
|
46124
|
+
type: "paragraph",
|
|
46125
|
+
text: "Official Talonic SDK for Node.js and TypeScript. Extract structured, schema-validated data from any document."
|
|
46126
|
+
},
|
|
46127
|
+
{
|
|
46128
|
+
type: "paragraph",
|
|
46129
|
+
text: "The SDK wraps the [Talonic REST API](https://talonic.com/docs/api) with a typed client, automatic retries, structured errors, and a CLI. Zero runtime dependencies."
|
|
46130
|
+
},
|
|
46131
|
+
{
|
|
46132
|
+
type: "paragraph",
|
|
46133
|
+
text: "The client exposes resource objects for every API namespace: **documents**, **extractions**, **schemas**, **jobs**, **fields**, **credits**, **pricing**, and **usage**. Each resource provides typed methods that return structured responses with rate-limit and cost metadata attached."
|
|
46134
|
+
},
|
|
46135
|
+
{
|
|
46136
|
+
type: "paragraph",
|
|
46137
|
+
text: "Every HTTP call goes through a shared transport layer that handles authentication, retries with exponential backoff, timeout enforcement, and error mapping. You configure these behaviors once in the constructor and every method call inherits them."
|
|
46138
|
+
},
|
|
46139
|
+
{
|
|
46140
|
+
type: "paragraph",
|
|
46141
|
+
text: "The top-level `extract()` method is the fastest path from document to structured data. Pass a local file path, a remote URL, in-memory bytes, or a previously uploaded `document_id` alongside an inline schema or a saved `schema_id`. The SDK reads the file, uploads it as multipart form data, and returns typed JSON in a single await. Every response also carries `rateLimit` and `cost` metadata parsed from response headers, so you can build budget-aware pipelines without extra API calls."
|
|
46142
|
+
},
|
|
46143
|
+
{
|
|
46144
|
+
type: "code",
|
|
46145
|
+
language: "typescript",
|
|
46146
|
+
title: "Create a client and extract",
|
|
46147
|
+
code: "import { Talonic } from '@talonic/node'\n\nconst talonic = new Talonic({ apiKey: process.env.TALONIC_API_KEY! })\n\n// Extract structured data from a local PDF\nconst result = await talonic.extract({\n file_path: './contract.pdf',\n schema: {\n type: 'object',\n properties: {\n parties: {\n type: 'array',\n items: {\n type: 'object',\n properties: { name: { type: 'string' }, role: { type: 'string' } },\n },\n },\n effective_date: { type: 'string', format: 'date' },\n termination_clause: { type: 'string' },\n governing_law: { type: 'string' },\n },\n },\n})\n\nconsole.log(result.data)\n// { parties: [{ name: 'Acme Corp', role: 'Licensor' }, ...], effective_date: '2025-01-15', ... }\nconsole.log(result.cost)\n// { costCredits: 8, costEur: 0.04, balanceCredits: 1892, ... }"
|
|
46148
|
+
},
|
|
46149
|
+
{
|
|
46150
|
+
type: "paragraph",
|
|
46151
|
+
text: "Beyond extraction, the SDK provides full CRUD access to your workspace. Use `talonic.documents` to list, inspect, re-extract, filter, and delete uploaded files. Use `talonic.schemas` to create and manage reusable extraction definitions that keep your output consistent across calls and team members. Use `talonic.jobs` for asynchronous batch extraction across many documents, and `talonic.credits.getBalance()` to monitor your workspace credit balance, burn rate, and projected runway."
|
|
46152
|
+
},
|
|
46153
|
+
{
|
|
46154
|
+
type: "code",
|
|
46155
|
+
language: "typescript",
|
|
46156
|
+
title: "Explore your workspace",
|
|
46157
|
+
code: "// List all documents in your workspace\nconst docs = await talonic.documents.list({ limit: 10 })\nconsole.log(docs.data.map(d => d.filename))\n\n// Search across documents, fields, sources, and schemas\nconst hits = await talonic.search('indemnification clause')\nconsole.log(hits.documents)\nconsole.log(hits.fieldMatches)\n\n// Check your credit balance\nconst balance = await talonic.credits.getBalance()\nconsole.log(`${balance.balance_credits} credits remaining (${balance.projected_runway_days} days runway)`)"
|
|
46158
|
+
},
|
|
46159
|
+
{
|
|
46160
|
+
type: "paragraph",
|
|
46161
|
+
text: "The SDK ships both ESM and CJS builds with full TypeScript declarations, so it integrates cleanly into any modern Node.js project. Every error is a typed `TalonicError` subclass with `status`, `code`, and `requestId` properties, making it straightforward to handle failures in a structured way. The global `search()` method lets you query across documents, fields, sources, and schemas in a single call, useful for building search interfaces or validating that data exists before running an extraction."
|
|
46162
|
+
},
|
|
46163
|
+
{
|
|
46164
|
+
type: "callout",
|
|
46165
|
+
text: "**Looking for the AI agent path?** [`@talonic/mcp`](https://talonic.com/docs/mcp) wraps this SDK as a Model Context Protocol server. Install it into Claude Desktop, Cursor, Cline, Continue, or Cowork and any MCP-aware agent can extract documents directly."
|
|
46166
|
+
}
|
|
46037
46167
|
],
|
|
46038
46168
|
related: [
|
|
46039
|
-
{
|
|
46040
|
-
|
|
46041
|
-
|
|
46169
|
+
{
|
|
46170
|
+
label: "Installation",
|
|
46171
|
+
slug: "sdk-installation"
|
|
46172
|
+
},
|
|
46173
|
+
{
|
|
46174
|
+
label: "Quick Start",
|
|
46175
|
+
slug: "sdk-quickstart"
|
|
46176
|
+
},
|
|
46177
|
+
{
|
|
46178
|
+
label: "Extract",
|
|
46179
|
+
slug: "sdk-extract"
|
|
46180
|
+
}
|
|
46042
46181
|
],
|
|
46043
46182
|
faq: [
|
|
46044
|
-
{
|
|
46045
|
-
|
|
46183
|
+
{
|
|
46184
|
+
question: "What is @talonic/node?",
|
|
46185
|
+
answer: "The official Talonic SDK for Node.js and TypeScript. It extracts structured, schema-validated data from any document with a typed client, automatic retries, and structured errors."
|
|
46186
|
+
},
|
|
46187
|
+
{
|
|
46188
|
+
question: "Does the Talonic SDK have dependencies?",
|
|
46189
|
+
answer: "No. @talonic/node has zero runtime dependencies and requires Node.js 18 or newer."
|
|
46190
|
+
},
|
|
46191
|
+
{
|
|
46192
|
+
question: "What resources does the SDK expose?",
|
|
46193
|
+
answer: "The client exposes documents, extractions, schemas, jobs, fields, credits, pricing, and usage as typed resource objects. Each provides methods that map to the corresponding REST API endpoints."
|
|
46194
|
+
},
|
|
46195
|
+
{
|
|
46196
|
+
question: "What file formats does the Talonic SDK support?",
|
|
46197
|
+
answer: "The SDK supports PDF, PNG, JPG, TIFF, WebP, BMP, GIF, DOCX, DOC, XLSX, XLS, PPTX, PPT, TXT, Markdown, CSV, TSV, JSON, XML, HTML, EML, MSG, and ZIP files. MIME types are inferred from the file extension, or you can set content_type explicitly."
|
|
46198
|
+
},
|
|
46199
|
+
{
|
|
46200
|
+
question: "Does the SDK include a search method?",
|
|
46201
|
+
answer: "Yes. The top-level talonic.search() method runs a global omnisearch across documents, fields, sources, and schemas. It returns categorized hits for each entity type and accepts an optional limit parameter to control results per type."
|
|
46202
|
+
},
|
|
46203
|
+
{
|
|
46204
|
+
question: "How does the SDK handle rate limiting and costs?",
|
|
46205
|
+
answer: "Every response includes rateLimit metadata (limit, remaining, resetAt) parsed from X-RateLimit-* headers. Extract responses also carry cost metadata (costCredits, costEur, balanceCredits) parsed from X-Talonic-Cost-* headers. The SDK retries 429 rate-limit responses automatically, respecting the server-provided reset timestamp."
|
|
46206
|
+
}
|
|
46046
46207
|
],
|
|
46047
|
-
mentions: [
|
|
46208
|
+
mentions: [
|
|
46209
|
+
"Node.js",
|
|
46210
|
+
"TypeScript",
|
|
46211
|
+
"SDK",
|
|
46212
|
+
"document extraction"
|
|
46213
|
+
]
|
|
46048
46214
|
},
|
|
46049
46215
|
{
|
|
46050
46216
|
slug: "sdk-installation",
|
|
46051
46217
|
parentSlug: "sdk-overview",
|
|
46052
46218
|
title: "Installation",
|
|
46053
|
-
seoTitle: "Install Talonic Node SDK
|
|
46054
|
-
description: "Install the
|
|
46219
|
+
seoTitle: "Install @talonic/node \u2014 Talonic Node.js SDK Setup Guide",
|
|
46220
|
+
description: "Install the official Talonic Node.js SDK with npm, yarn, pnpm, or bun. Requires Node.js 18+, ships ESM and CJS builds, and has zero runtime dependencies.",
|
|
46055
46221
|
content: [
|
|
46056
|
-
{
|
|
46057
|
-
|
|
46222
|
+
{
|
|
46223
|
+
type: "code",
|
|
46224
|
+
language: "bash",
|
|
46225
|
+
code: "npm install @talonic/node"
|
|
46226
|
+
},
|
|
46227
|
+
{
|
|
46228
|
+
type: "paragraph",
|
|
46229
|
+
text: "The SDK requires Node.js 18 or newer and has zero runtime dependencies, so installing it adds exactly one package to your `node_modules`. There is nothing else to configure: no build step, no peer dependencies, and no native bindings. The published package includes the compiled JavaScript, TypeScript declaration files, and the `talonic` CLI binary."
|
|
46230
|
+
},
|
|
46231
|
+
{
|
|
46232
|
+
type: "paragraph",
|
|
46233
|
+
text: "The package works with npm, yarn, pnpm, and bun. It ships ESM and CJS builds with full TypeScript declarations, so it integrates cleanly into any modern Node.js project without additional configuration."
|
|
46234
|
+
},
|
|
46235
|
+
{
|
|
46236
|
+
type: "paragraph",
|
|
46237
|
+
text: "The SDK relies on the built-in `fetch` available in Node.js 18+. If you are running an older Node.js version, pass a fetch polyfill (such as `node-fetch`) via the `fetch` constructor option."
|
|
46238
|
+
},
|
|
46239
|
+
{
|
|
46240
|
+
type: "code",
|
|
46241
|
+
language: "bash",
|
|
46242
|
+
title: "Install with other package managers",
|
|
46243
|
+
code: "# yarn\nyarn add @talonic/node\n\n# pnpm\npnpm add @talonic/node\n\n# bun\nbun add @talonic/node"
|
|
46244
|
+
},
|
|
46245
|
+
{
|
|
46246
|
+
type: "paragraph",
|
|
46247
|
+
text: "After installation the `talonic` CLI binary is available in your project. Run `npx talonic --help` to verify the install. The CLI covers the most common operations \u2014 extraction, schema listing, and document listing \u2014 so you can test your API key from the terminal before writing any code. If you installed globally with `npm install -g @talonic/node`, the `talonic` command is available directly without `npx`."
|
|
46248
|
+
},
|
|
46249
|
+
{
|
|
46250
|
+
type: "heading",
|
|
46251
|
+
level: 3,
|
|
46252
|
+
id: "get-api-key",
|
|
46253
|
+
text: "Get an API key (30 seconds)"
|
|
46254
|
+
},
|
|
46255
|
+
{
|
|
46256
|
+
type: "paragraph",
|
|
46257
|
+
text: "Every user runs against their own Talonic workspace, so each user needs their own key. Workspaces are fully isolated: the documents you upload, the schemas you create, and the extractions you run are private to your workspace and invisible to every other account. Keys carry the `tlnc_` prefix and authenticate every SDK and CLI call via a bearer header."
|
|
46258
|
+
},
|
|
46259
|
+
{
|
|
46260
|
+
type: "list",
|
|
46261
|
+
ordered: true,
|
|
46262
|
+
items: [
|
|
46263
|
+
"Sign up at [app.talonic.com](https://app.talonic.com). Free tier: 50 extractions per day, no credit card.",
|
|
46264
|
+
"Settings \u2192 API Keys \u2192 Create New Key.",
|
|
46265
|
+
"Copy the `tlnc_` value.",
|
|
46266
|
+
"Set it as the `TALONIC_API_KEY` environment variable, or pass it directly to the client constructor."
|
|
46267
|
+
]
|
|
46268
|
+
},
|
|
46269
|
+
{
|
|
46270
|
+
type: "code",
|
|
46271
|
+
language: "typescript",
|
|
46272
|
+
title: "Verify your installation",
|
|
46273
|
+
code: "import { Talonic } from '@talonic/node'\n\nconst talonic = new Talonic({ apiKey: process.env.TALONIC_API_KEY! })\n\n// Quick smoke test: check your credit balance\nconst balance = await talonic.credits.getBalance()\nconsole.log(`Connected! Balance: ${balance.balance_credits} credits (${balance.tier} tier)`)"
|
|
46274
|
+
},
|
|
46275
|
+
{
|
|
46276
|
+
type: "paragraph",
|
|
46277
|
+
text: "The constructor validates that the `apiKey` is a non-empty string and that a `fetch` implementation is available. It throws a `TypeError` immediately if either check fails, so you will catch configuration problems at startup rather than on the first API call. The SDK does not validate the `tlnc_` prefix or contact the server during construction; authentication errors surface on the first actual request as a `TalonicAuthError` with status 401 or 403."
|
|
46278
|
+
},
|
|
46279
|
+
{
|
|
46280
|
+
type: "code",
|
|
46281
|
+
language: "bash",
|
|
46282
|
+
title: "Verify from the terminal",
|
|
46283
|
+
code: '# Set your API key\nexport TALONIC_API_KEY=tlnc_your_key_here\n\n# Test the connection by listing your saved schemas\nnpx talonic schemas list\n# { "data": [ ... ], "pagination": { ... }, ... }'
|
|
46284
|
+
},
|
|
46285
|
+
{
|
|
46286
|
+
type: "callout",
|
|
46287
|
+
text: "Store your API key in an environment variable or secrets manager. Never commit `tlnc_` values to version control."
|
|
46288
|
+
}
|
|
46058
46289
|
],
|
|
46059
46290
|
related: [
|
|
46060
|
-
{
|
|
46061
|
-
|
|
46291
|
+
{
|
|
46292
|
+
label: "Authentication",
|
|
46293
|
+
slug: "sdk-authentication"
|
|
46294
|
+
},
|
|
46295
|
+
{
|
|
46296
|
+
label: "Quick Start",
|
|
46297
|
+
slug: "sdk-quickstart"
|
|
46298
|
+
}
|
|
46062
46299
|
],
|
|
46063
46300
|
faq: [
|
|
46064
|
-
{
|
|
46301
|
+
{
|
|
46302
|
+
question: "How do I install the Talonic SDK?",
|
|
46303
|
+
answer: "Run npm install @talonic/node. Requires Node.js 18+ with zero runtime dependencies. Also works with yarn, pnpm, and bun."
|
|
46304
|
+
},
|
|
46305
|
+
{
|
|
46306
|
+
question: "How do I get a Talonic API key?",
|
|
46307
|
+
answer: "Sign up at app.talonic.com (free tier, no credit card), then go to Settings > API Keys > Create New Key. Keys use the tlnc_ prefix."
|
|
46308
|
+
},
|
|
46309
|
+
{
|
|
46310
|
+
question: "Does the SDK ship ESM and CJS builds?",
|
|
46311
|
+
answer: "Yes. The package includes both ESM and CJS builds with full TypeScript declarations. It integrates into any modern Node.js project without additional bundler configuration, and the types are auto-discovered by TypeScript without manual setup."
|
|
46312
|
+
},
|
|
46313
|
+
{
|
|
46314
|
+
question: "How do I verify my installation is working?",
|
|
46315
|
+
answer: "After installing, create a Talonic client with your API key and call talonic.credits.getBalance(). If the call succeeds and returns your balance, the SDK is correctly installed and your key is valid. From the terminal, run npx talonic schemas list as an equivalent smoke test."
|
|
46316
|
+
}
|
|
46065
46317
|
],
|
|
46066
|
-
mentions: [
|
|
46318
|
+
mentions: [
|
|
46319
|
+
"npm",
|
|
46320
|
+
"API key",
|
|
46321
|
+
"Node.js 18"
|
|
46322
|
+
]
|
|
46067
46323
|
},
|
|
46068
46324
|
{
|
|
46069
46325
|
slug: "sdk-authentication",
|
|
46070
46326
|
parentSlug: "sdk-overview",
|
|
46071
46327
|
title: "Authentication",
|
|
46072
|
-
seoTitle: "
|
|
46073
|
-
description: "
|
|
46328
|
+
seoTitle: "API Key Authentication \u2014 Talonic Node.js SDK Setup Docs",
|
|
46329
|
+
description: "Create a Talonic API key at app.talonic.com and authenticate the Node SDK via the TALONIC_API_KEY environment variable or the apiKey constructor option.",
|
|
46074
46330
|
content: [
|
|
46075
|
-
{
|
|
46076
|
-
|
|
46077
|
-
"
|
|
46078
|
-
|
|
46079
|
-
|
|
46080
|
-
"
|
|
46081
|
-
|
|
46082
|
-
|
|
46331
|
+
{
|
|
46332
|
+
type: "paragraph",
|
|
46333
|
+
text: "Every request the SDK makes is authenticated with a workspace API key. Keys carry the `tlnc_` prefix and are sent as an `Authorization: Bearer` header on every HTTP call, so you never handle raw headers yourself. Each user runs against their own Talonic workspace: the documents you upload, the schemas you create, and the extractions you run are private to your workspace and invisible to every other account."
|
|
46334
|
+
},
|
|
46335
|
+
{
|
|
46336
|
+
type: "paragraph",
|
|
46337
|
+
text: "Getting a key takes about thirty seconds. Sign up at [app.talonic.com](https://app.talonic.com) \u2014 the free tier includes 50 extractions per day with no credit card \u2014 then open Settings \u2192 API Keys \u2192 Create New Key and copy the `tlnc_` value. Set it as the `TALONIC_API_KEY` environment variable, or pass it directly to the client constructor via the `apiKey` option if your deployment injects secrets differently."
|
|
46338
|
+
},
|
|
46339
|
+
{
|
|
46340
|
+
type: "code",
|
|
46341
|
+
language: "typescript",
|
|
46342
|
+
title: "Authenticate the client",
|
|
46343
|
+
code: "import { Talonic } from '@talonic/node'\n\n// Recommended: read the key from the environment\nconst talonic = new Talonic({ apiKey: process.env.TALONIC_API_KEY! })\n\n// The same key also powers the bundled CLI:\n// export TALONIC_API_KEY=tlnc_your_key_here\n// npx talonic schemas list"
|
|
46344
|
+
},
|
|
46345
|
+
{
|
|
46346
|
+
type: "paragraph",
|
|
46347
|
+
text: "The constructor validates that `apiKey` is a non-empty string and throws a `TypeError` immediately if it is missing, so misconfiguration surfaces at startup rather than mid-pipeline. It does not contact the server or validate the `tlnc_` prefix during construction: an invalid or revoked key surfaces on the first real request as a `TalonicAuthError` with status 401, and a key lacking permission for an operation surfaces as the same class with status 403."
|
|
46348
|
+
},
|
|
46349
|
+
{
|
|
46350
|
+
type: "code",
|
|
46351
|
+
language: "typescript",
|
|
46352
|
+
title: "Handle authentication failures",
|
|
46353
|
+
code: "import { Talonic, TalonicAuthError } from '@talonic/node'\n\nconst talonic = new Talonic({ apiKey: process.env.TALONIC_API_KEY! })\n\ntry {\n const schemas = await talonic.schemas.list()\n console.log(`Authenticated \u2014 ${schemas.data.length} schemas visible`)\n} catch (err) {\n if (err instanceof TalonicAuthError) {\n // 401: key missing/invalid/revoked; 403: insufficient permissions\n console.error(`Auth failed (status ${err.status}): ${err.message}`)\n process.exit(1)\n }\n throw err\n}"
|
|
46354
|
+
},
|
|
46355
|
+
{
|
|
46356
|
+
type: "paragraph",
|
|
46357
|
+
text: "Authentication errors are never retried: the SDK throws `TalonicAuthError` on the first 401 or 403 response regardless of the `maxRetries` setting, because retrying a bad credential cannot succeed. That makes a cheap read-only call such as `talonic.schemas.list()` a good startup health check \u2014 it verifies the key, the network path, and the base URL in one request without consuming any credits."
|
|
46358
|
+
},
|
|
46359
|
+
{
|
|
46360
|
+
type: "callout",
|
|
46361
|
+
variant: "warning",
|
|
46362
|
+
text: "Treat `tlnc_` keys like passwords: store them in environment variables or a secrets manager, never commit them to version control, and rotate them from the dashboard (Settings \u2192 API Keys) if one leaks. The CLI deliberately has no `--api-key` flag so keys stay out of shell history."
|
|
46363
|
+
}
|
|
46083
46364
|
],
|
|
46084
46365
|
related: [
|
|
46085
|
-
{
|
|
46086
|
-
|
|
46366
|
+
{
|
|
46367
|
+
label: "Configuration",
|
|
46368
|
+
slug: "sdk-configuration"
|
|
46369
|
+
},
|
|
46370
|
+
{
|
|
46371
|
+
label: "Quick Start",
|
|
46372
|
+
slug: "sdk-quickstart"
|
|
46373
|
+
},
|
|
46374
|
+
{
|
|
46375
|
+
label: "Error Classes",
|
|
46376
|
+
slug: "sdk-error-classes"
|
|
46377
|
+
}
|
|
46087
46378
|
],
|
|
46088
46379
|
faq: [
|
|
46089
|
-
{
|
|
46380
|
+
{
|
|
46381
|
+
question: "How do I get a Talonic API key?",
|
|
46382
|
+
answer: "Sign up at app.talonic.com (the free tier includes 50 extractions per day, no credit card), then go to Settings > API Keys > Create New Key and copy the tlnc_ value. Set it as TALONIC_API_KEY or pass it to the constructor as apiKey."
|
|
46383
|
+
},
|
|
46384
|
+
{
|
|
46385
|
+
question: "Does the SDK validate my API key when I create the client?",
|
|
46386
|
+
answer: "No. The constructor only checks that apiKey is a non-empty string; it makes no network calls. An invalid key surfaces on the first request as a TalonicAuthError with status 401, and insufficient permissions surface as status 403."
|
|
46387
|
+
},
|
|
46388
|
+
{
|
|
46389
|
+
question: "Are API keys shared across a workspace?",
|
|
46390
|
+
answer: "Keys belong to a workspace, and workspaces are fully isolated from each other. Anyone with a key for a workspace sees that workspace's documents, schemas, and extractions \u2014 so issue separate keys per environment and rotate them from the dashboard when needed."
|
|
46391
|
+
},
|
|
46392
|
+
{
|
|
46393
|
+
question: "Are authentication failures retried?",
|
|
46394
|
+
answer: "No. 401 and 403 responses are non-retryable: the SDK throws TalonicAuthError immediately regardless of maxRetries, because retrying a bad credential cannot succeed. Fix or rotate the key and retry the call yourself."
|
|
46395
|
+
}
|
|
46090
46396
|
],
|
|
46091
|
-
mentions: [
|
|
46397
|
+
mentions: [
|
|
46398
|
+
"API key",
|
|
46399
|
+
"TALONIC_API_KEY",
|
|
46400
|
+
"tlnc_",
|
|
46401
|
+
"authentication",
|
|
46402
|
+
"workspace"
|
|
46403
|
+
]
|
|
46092
46404
|
},
|
|
46093
46405
|
{
|
|
46094
46406
|
slug: "sdk-quickstart",
|
|
46095
46407
|
parentSlug: "sdk-overview",
|
|
46096
46408
|
title: "Quick Start",
|
|
46097
|
-
seoTitle: "
|
|
46098
|
-
description: "Extract structured data from a
|
|
46409
|
+
seoTitle: "Quick Start \u2014 Extract Document Data with Talonic Node SDK",
|
|
46410
|
+
description: "Extract structured data from a PDF in five lines of TypeScript: create a Talonic client, call extract() with a schema, and read typed, validated results.",
|
|
46099
46411
|
content: [
|
|
46100
|
-
{
|
|
46412
|
+
{
|
|
46413
|
+
type: "paragraph",
|
|
46414
|
+
text: "Extract structured data from a document in five lines. Create a client, call **extract()** with a file and schema, and read the typed result."
|
|
46415
|
+
},
|
|
46416
|
+
{
|
|
46417
|
+
type: "code",
|
|
46418
|
+
language: "typescript",
|
|
46419
|
+
title: "Extract an invoice",
|
|
46420
|
+
code: "import { Talonic } from '@talonic/node'\n\nconst talonic = new Talonic({ apiKey: process.env.TALONIC_API_KEY! })\n\nconst result = await talonic.extract({\n file_path: './invoice.pdf',\n schema: {\n type: 'object',\n properties: {\n vendor_name: { type: 'string' },\n invoice_number: { type: 'string' },\n total_amount: { type: 'number' },\n due_date: { type: 'string', format: 'date' },\n },\n },\n})\n\nconsole.log(result.data)\n// { vendor_name: 'Acme Corp', invoice_number: 'INV-2024-0847', total_amount: 14250, due_date: '2024-03-15' }"
|
|
46421
|
+
},
|
|
46422
|
+
{
|
|
46423
|
+
type: "paragraph",
|
|
46424
|
+
text: 'The `result` object contains the extracted `data` matching your schema, plus `rateLimit` and `cost` metadata. The `data` fields are typed according to your schema definition, so `total_amount` comes back as a number and `due_date` as a date string. Pass a full JSON Schema with `type: "object"` and `properties` for reliable results; when you omit the `required` array, the SDK auto-populates it from `properties` so the API cannot silently return `null` for fields you clearly intended to extract.'
|
|
46425
|
+
},
|
|
46426
|
+
{
|
|
46427
|
+
type: "paragraph",
|
|
46428
|
+
text: "You can also pass `file_url` for remote files or `file` with `filename` for in-memory bytes (Blob, Buffer, or Uint8Array). For documents already uploaded to your workspace, pass `document_id` to skip the upload step entirely. The SDK accepts exactly one file source per call and validates this at runtime, throwing a `TalonicError` with code `missing_file_source` or `multiple_file_sources` if the constraint is violated."
|
|
46429
|
+
},
|
|
46430
|
+
{
|
|
46431
|
+
type: "code",
|
|
46432
|
+
language: "typescript",
|
|
46433
|
+
title: "Extract from a URL",
|
|
46434
|
+
code: "// Extract from a remote file \u2014 no local download needed\nconst result = await talonic.extract({\n file_url: 'https://example.com/reports/q4-2025.pdf',\n schema: {\n type: 'object',\n properties: {\n report_title: { type: 'string' },\n period: { type: 'string' },\n revenue: { type: 'number' },\n net_income: { type: 'number' },\n highlights: { type: 'array', items: { type: 'string' } },\n },\n },\n})\n\nconsole.log(result.data.revenue) // 4250000\nconsole.log(result.confidence?.overall) // 0.94\nconsole.log(result.document.pages) // 12"
|
|
46435
|
+
},
|
|
46436
|
+
{
|
|
46437
|
+
type: "paragraph",
|
|
46438
|
+
text: "All **extract()** calls are async and return a `Promise`. The SDK handles retries, timeouts, and error mapping automatically, so you only need a single `try/catch` around your call for error handling. Retryable failures (429, 5xx, network errors, timeouts) are retried up to `maxRetries` times with exponential backoff, so transient hiccups do not require manual retry logic."
|
|
46439
|
+
},
|
|
46440
|
+
{
|
|
46441
|
+
type: "code",
|
|
46442
|
+
language: "typescript",
|
|
46443
|
+
title: "Extract with error handling",
|
|
46444
|
+
code: "import { Talonic, TalonicAuthError, TalonicValidationError, TalonicError } from '@talonic/node'\n\nconst talonic = new Talonic({ apiKey: process.env.TALONIC_API_KEY! })\n\ntry {\n const result = await talonic.extract({\n file_path: './receipt.png',\n schema: {\n type: 'object',\n properties: {\n merchant: { type: 'string' },\n date: { type: 'string', format: 'date' },\n total: { type: 'number' },\n items: {\n type: 'array',\n items: {\n type: 'object',\n properties: { name: { type: 'string' }, price: { type: 'number' } },\n },\n },\n },\n },\n })\n console.log(`Extracted ${result.data.items?.length ?? 0} line items from ${result.document.filename}`)\n console.log(`Cost: ${result.cost?.costCredits} credits, balance: ${result.cost?.balanceCredits}`)\n} catch (err) {\n if (err instanceof TalonicAuthError) {\n console.error('Invalid API key \u2014 check TALONIC_API_KEY')\n } else if (err instanceof TalonicValidationError) {\n console.error(`Bad request: ${err.message} (code: ${err.code})`)\n } else if (err instanceof TalonicError) {\n console.error(`Talonic error: ${err.code} (status ${err.status}, request ${err.requestId})`)\n }\n}"
|
|
46445
|
+
},
|
|
46446
|
+
{
|
|
46447
|
+
type: "paragraph",
|
|
46448
|
+
text: "The `extract()` response includes rich metadata beyond the extracted data. The `document` block contains the filename, page count, file size, detected MIME type, and detected language. The optional `confidence` block provides an overall confidence score and per-field scores. The `processing` block reports duration, pages processed, and the region that handled the request. Use these fields to build quality gates and observability into your extraction pipeline."
|
|
46449
|
+
},
|
|
46450
|
+
{
|
|
46451
|
+
type: "code",
|
|
46452
|
+
language: "typescript",
|
|
46453
|
+
title: "Re-extract a previously uploaded document with a saved schema",
|
|
46454
|
+
code: "// Use document_id + schema_id to re-extract without re-uploading\nconst result = await talonic.extract({\n document_id: 'doc_abc123',\n schema_id: 'sch_def456',\n instructions: 'Focus on the indemnification and liability sections',\n include_markdown: true,\n})\n\nconsole.log(result.data) // structured extraction\nconsole.log(result.markdown) // raw OCR markdown (when include_markdown is true)\nconsole.log(result.schema) // { source: 'saved', id: 'sch_def456', definition: { ... } }"
|
|
46455
|
+
},
|
|
46456
|
+
{
|
|
46457
|
+
type: "callout",
|
|
46458
|
+
text: "This example uses top-level `await`. If your environment does not support it, wrap the code in an `async` function."
|
|
46459
|
+
}
|
|
46101
46460
|
],
|
|
46102
46461
|
related: [
|
|
46103
|
-
{
|
|
46104
|
-
|
|
46105
|
-
|
|
46106
|
-
|
|
46107
|
-
|
|
46108
|
-
|
|
46462
|
+
{
|
|
46463
|
+
label: "Extract",
|
|
46464
|
+
slug: "sdk-extract"
|
|
46465
|
+
},
|
|
46466
|
+
{
|
|
46467
|
+
label: "Schemas",
|
|
46468
|
+
slug: "sdk-schemas"
|
|
46469
|
+
},
|
|
46470
|
+
{
|
|
46471
|
+
label: "Configuration",
|
|
46472
|
+
slug: "sdk-configuration"
|
|
46473
|
+
}
|
|
46109
46474
|
],
|
|
46110
|
-
|
|
46475
|
+
faq: [
|
|
46476
|
+
{
|
|
46477
|
+
question: "How do I extract data from a PDF with the Talonic SDK?",
|
|
46478
|
+
answer: "Import Talonic, create a client with your API key, and call talonic.extract() with a file path and schema. The result contains structured, schema-validated JSON."
|
|
46479
|
+
},
|
|
46480
|
+
{
|
|
46481
|
+
question: "What does the extract result contain?",
|
|
46482
|
+
answer: "The result includes a data object with fields matching your schema, plus rateLimit (limit, remaining, resetAt) and cost (credits consumed, EUR value, post-call balance) metadata. It also contains document metadata (filename, pages, size_bytes, mime_type), optional confidence scores (overall and per-field), and processing info (duration_ms, region)."
|
|
46483
|
+
},
|
|
46484
|
+
{
|
|
46485
|
+
question: "Can I extract from a URL instead of a local file?",
|
|
46486
|
+
answer: "Yes. Pass file_url instead of file_path to extract from a remote document. The SDK fetches the file server-side, so you do not need to download it first."
|
|
46487
|
+
},
|
|
46488
|
+
{
|
|
46489
|
+
question: "Can I pass natural-language instructions to guide extraction?",
|
|
46490
|
+
answer: "Yes. The extract() method accepts an optional instructions parameter where you can provide natural-language guidance like 'Focus on the indemnification section' or 'Extract amounts in USD only'. Instructions are forwarded to the extraction engine alongside the schema to improve accuracy for ambiguous documents."
|
|
46491
|
+
},
|
|
46492
|
+
{
|
|
46493
|
+
question: "How do I extract only specific pages from a PDF?",
|
|
46494
|
+
answer: "Pass the options.page_range parameter with a page specification like '1-5' or '1,3,7-10'. This tells the extraction engine to process only those pages, which reduces processing time and credit consumption for large documents."
|
|
46495
|
+
},
|
|
46496
|
+
{
|
|
46497
|
+
question: "What happens if I pass both schema and schema_id?",
|
|
46498
|
+
answer: "The SDK throws a TalonicError with code 'multiple_schemas' immediately, before making any API call. You must provide at most one schema source: either an inline schema object or a schema_id referencing a saved schema."
|
|
46499
|
+
}
|
|
46500
|
+
],
|
|
46501
|
+
mentions: [
|
|
46502
|
+
"extract",
|
|
46503
|
+
"schema",
|
|
46504
|
+
"TypeScript"
|
|
46505
|
+
]
|
|
46111
46506
|
},
|
|
46112
46507
|
{
|
|
46113
46508
|
slug: "sdk-configuration",
|
|
46114
46509
|
parentSlug: "sdk-client",
|
|
46115
46510
|
title: "Configuration",
|
|
46116
|
-
seoTitle: "
|
|
46117
|
-
description: "Configure the Talonic client
|
|
46118
|
-
content: [
|
|
46119
|
-
{
|
|
46120
|
-
|
|
46121
|
-
|
|
46122
|
-
|
|
46123
|
-
|
|
46124
|
-
|
|
46125
|
-
|
|
46126
|
-
|
|
46511
|
+
seoTitle: "Client Configuration Options \u2014 Talonic Node.js SDK Docs",
|
|
46512
|
+
description: "Configure the Talonic client constructor: apiKey, baseUrl, timeout, maxRetries, and a custom fetch implementation for testing, proxies, and polyfills.",
|
|
46513
|
+
content: [
|
|
46514
|
+
{
|
|
46515
|
+
type: "paragraph",
|
|
46516
|
+
text: "Create a `Talonic` instance by passing a configuration object to the constructor. The only required field is `apiKey`; all other options have sensible defaults. The client validates the key format on construction and throws a `TypeError` if it is missing or empty."
|
|
46517
|
+
},
|
|
46518
|
+
{
|
|
46519
|
+
type: "code",
|
|
46520
|
+
language: "typescript",
|
|
46521
|
+
title: "All options",
|
|
46522
|
+
code: "import { Talonic } from '@talonic/node'\n\nconst talonic = new Talonic({\n apiKey: process.env.TALONIC_API_KEY!,\n baseUrl: 'https://api.talonic.com', // default\n timeout: 60_000, // ms; default 60s\n maxRetries: 3, // 429, 500, 502, 503, 504, network, timeout\n fetch: customFetch, // optional override (e.g. for testing)\n})"
|
|
46523
|
+
},
|
|
46524
|
+
{
|
|
46525
|
+
type: "paragraph",
|
|
46526
|
+
text: "The `TalonicConfig` interface defines the constructor shape. The `apiKey` field is the only required parameter and must be a non-empty string. The constructor does not validate the `tlnc_` prefix or make any network calls; it only checks that the key is present and that a `fetch` implementation is available. Authentication failures surface on the first API call as a `TalonicAuthError` with status 401 (invalid key) or 403 (insufficient permissions)."
|
|
46527
|
+
},
|
|
46528
|
+
{
|
|
46529
|
+
type: "paragraph",
|
|
46530
|
+
text: "The `fetch` option lets you inject a custom implementation for testing or proxying. In production on Node.js 18+, the SDK uses the built-in `globalThis.fetch` automatically. If no fetch implementation is available (Node < 18 without a polyfill), the constructor throws a `TypeError` with a clear message."
|
|
46531
|
+
},
|
|
46532
|
+
{
|
|
46533
|
+
type: "code",
|
|
46534
|
+
language: "typescript",
|
|
46535
|
+
title: "Testing with a mock fetch",
|
|
46536
|
+
code: "import { Talonic } from '@talonic/node'\n\n// Inject a custom fetch for testing\nconst mockFetch = async (url: string, init?: RequestInit) => {\n console.log(`Request: ${init?.method} ${url}`)\n return new Response(JSON.stringify({ balance_credits: 1000, tier: 'free' }), {\n status: 200,\n headers: { 'content-type': 'application/json' },\n })\n}\n\nconst talonic = new Talonic({\n apiKey: 'tlnc_test_key',\n fetch: mockFetch as typeof fetch,\n})\n\nconst balance = await talonic.credits.getBalance()\nconsole.log(balance.balance_credits) // 1000"
|
|
46537
|
+
},
|
|
46538
|
+
{
|
|
46539
|
+
type: "paragraph",
|
|
46540
|
+
text: "Adjust `timeout` for long-running extractions on large documents; the default of 60 seconds covers most cases. For multi-page PDFs or image-heavy documents, consider increasing to 120 seconds or more. Set `maxRetries` to `0` to disable automatic retries entirely, which is useful during development when you want to see errors immediately. In production, the default of 3 retries with exponential backoff handles most transient failures without any manual intervention."
|
|
46541
|
+
},
|
|
46542
|
+
{
|
|
46543
|
+
type: "code",
|
|
46544
|
+
language: "typescript",
|
|
46545
|
+
title: "Production configuration",
|
|
46546
|
+
code: "// Production: higher timeout for large documents, default retries\nconst talonic = new Talonic({\n apiKey: process.env.TALONIC_API_KEY!,\n timeout: 120_000, // 2 minutes for large documents\n maxRetries: 3, // default \u2014 retries 429, 5xx, network, timeout\n})\n\n// Development: fast feedback, no retries\nconst devClient = new Talonic({\n apiKey: process.env.TALONIC_API_KEY!,\n timeout: 30_000,\n maxRetries: 0, // fail immediately on errors\n})"
|
|
46547
|
+
},
|
|
46548
|
+
{
|
|
46549
|
+
type: "paragraph",
|
|
46550
|
+
text: "The `baseUrl` option defaults to `https://api.talonic.com` and is useful for pointing at staging environments or local proxies during development. Trailing slashes are stripped automatically. Every HTTP request sent by the SDK includes an `Authorization: Bearer <apiKey>` header, a `User-Agent: talonic-node/<version>` header, and `Accept: application/json`. For non-FormData bodies, `Content-Type: application/json` is set automatically. You can override headers on individual requests through the transport layer, but the constructor-level options cover all common configuration needs."
|
|
46551
|
+
},
|
|
46552
|
+
{
|
|
46553
|
+
type: "callout",
|
|
46554
|
+
text: "API keys use the `tlnc_` prefix. Store them in environment variables or a secrets manager rather than hard-coding them in source files."
|
|
46555
|
+
},
|
|
46556
|
+
{
|
|
46557
|
+
type: "param-table",
|
|
46558
|
+
params: [
|
|
46559
|
+
{
|
|
46560
|
+
name: "apiKey",
|
|
46561
|
+
type: "string",
|
|
46562
|
+
required: true,
|
|
46563
|
+
description: "Your Talonic API key. Starts with `tlnc_`."
|
|
46564
|
+
},
|
|
46565
|
+
{
|
|
46566
|
+
name: "baseUrl",
|
|
46567
|
+
type: "string",
|
|
46568
|
+
description: "API base URL. Trailing slashes are stripped automatically.",
|
|
46569
|
+
default: "https://api.talonic.com"
|
|
46570
|
+
},
|
|
46571
|
+
{
|
|
46572
|
+
name: "timeout",
|
|
46573
|
+
type: "number",
|
|
46574
|
+
description: "Request timeout in milliseconds. Applies per-request including retries.",
|
|
46575
|
+
default: "60000"
|
|
46576
|
+
},
|
|
46577
|
+
{
|
|
46578
|
+
name: "maxRetries",
|
|
46579
|
+
type: "number",
|
|
46580
|
+
description: "Max retry attempts for transient failures (429, 5xx, network, timeout). Set to 0 to disable.",
|
|
46581
|
+
default: "3"
|
|
46582
|
+
},
|
|
46583
|
+
{
|
|
46584
|
+
name: "fetch",
|
|
46585
|
+
type: "function",
|
|
46586
|
+
description: "Custom fetch implementation for testing, instrumentation, or polyfilling Node < 18."
|
|
46587
|
+
}
|
|
46588
|
+
]
|
|
46589
|
+
}
|
|
46127
46590
|
],
|
|
46128
46591
|
related: [
|
|
46129
|
-
{
|
|
46130
|
-
|
|
46592
|
+
{
|
|
46593
|
+
label: "Retries & Backoff",
|
|
46594
|
+
slug: "sdk-retries"
|
|
46595
|
+
},
|
|
46596
|
+
{
|
|
46597
|
+
label: "Installation",
|
|
46598
|
+
slug: "sdk-installation"
|
|
46599
|
+
},
|
|
46600
|
+
{
|
|
46601
|
+
label: "Authentication",
|
|
46602
|
+
slug: "sdk-authentication"
|
|
46603
|
+
}
|
|
46131
46604
|
],
|
|
46132
|
-
faq: [
|
|
46133
|
-
|
|
46605
|
+
faq: [
|
|
46606
|
+
{
|
|
46607
|
+
question: "How do I configure the Talonic SDK client?",
|
|
46608
|
+
answer: "Pass an options object to new Talonic() with apiKey (required), and optional baseUrl, timeout, maxRetries, and fetch. All options except apiKey have sensible defaults."
|
|
46609
|
+
},
|
|
46610
|
+
{
|
|
46611
|
+
question: "Can I disable automatic retries?",
|
|
46612
|
+
answer: "Yes. Set maxRetries to 0 in the constructor options. The SDK will throw on the first failure without retrying. This is useful during development for fast feedback on errors."
|
|
46613
|
+
},
|
|
46614
|
+
{
|
|
46615
|
+
question: "What happens if no fetch implementation is available?",
|
|
46616
|
+
answer: "The constructor throws a TypeError with the message 'no fetch implementation available'. On Node.js 18+ the built-in fetch is used automatically; on older versions, pass a polyfill via the fetch option."
|
|
46617
|
+
},
|
|
46618
|
+
{
|
|
46619
|
+
question: "Does the constructor validate the API key with the server?",
|
|
46620
|
+
answer: "No. The constructor only checks that apiKey is a non-empty string and that a fetch implementation exists. It does not make any network calls. Authentication errors (invalid key, insufficient permissions) surface on the first API call as TalonicAuthError with status 401 or 403."
|
|
46621
|
+
},
|
|
46622
|
+
{
|
|
46623
|
+
question: "What headers does the SDK send with every request?",
|
|
46624
|
+
answer: "Every request includes Authorization: Bearer <apiKey>, User-Agent: talonic-node/<version>, and Accept: application/json. For JSON bodies, Content-Type: application/json is set automatically. FormData bodies (used by extract) omit Content-Type to let the browser set the multipart boundary."
|
|
46625
|
+
}
|
|
46626
|
+
],
|
|
46627
|
+
mentions: [
|
|
46628
|
+
"configuration",
|
|
46629
|
+
"apiKey",
|
|
46630
|
+
"timeout",
|
|
46631
|
+
"maxRetries"
|
|
46632
|
+
]
|
|
46134
46633
|
},
|
|
46135
46634
|
{
|
|
46136
46635
|
slug: "sdk-extract",
|
|
46137
46636
|
parentSlug: "sdk-client",
|
|
46138
46637
|
title: "Extract",
|
|
46139
|
-
seoTitle: "
|
|
46140
|
-
description: "
|
|
46638
|
+
seoTitle: "extract() Method \u2014 Talonic Node SDK Document Extraction",
|
|
46639
|
+
description: "Call talonic.extract() with a file and JSON Schema to receive structured, validated data plus confidence scores and per-call cost metadata in one await.",
|
|
46141
46640
|
content: [
|
|
46142
|
-
{
|
|
46143
|
-
|
|
46144
|
-
|
|
46641
|
+
{
|
|
46642
|
+
type: "paragraph",
|
|
46643
|
+
text: "The top-level `extract()` method is the primary entry point. Send a document and schema, receive structured validated data."
|
|
46644
|
+
},
|
|
46645
|
+
{
|
|
46646
|
+
type: "code",
|
|
46647
|
+
language: "typescript",
|
|
46648
|
+
title: "Extract with inline schema",
|
|
46649
|
+
code: "const result = await talonic.extract({\n file_path: './invoice.pdf',\n schema: {\n type: 'object',\n properties: {\n vendor_name: { type: 'string' },\n invoice_number: { type: 'string' },\n total_amount: { type: 'number' },\n line_items: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n description: { type: 'string' },\n quantity: { type: 'number' },\n unit_price: { type: 'number' },\n },\n },\n },\n },\n },\n})\n\nconsole.log(result.data)\n// { vendor_name: 'Acme Corp', total_amount: 1234.56, ... }\nconsole.log(result.extraction_id) // 'ext_abc123'\nconsole.log(result.confidence) // { overall: 0.95, fields: { vendor_name: 0.99, ... } }"
|
|
46650
|
+
},
|
|
46651
|
+
{
|
|
46652
|
+
type: "paragraph",
|
|
46653
|
+
text: "The method signature is `extract(params: ExtractParams): Promise<WithRateLimit<ExtractResult>>`. The `ExtractParams` interface accepts exactly one file source: `file` (in-memory Blob, Buffer, or Uint8Array), `file_path` (local path read with `fs/promises`), `file_url` (remote URL fetched server-side), or `document_id` (re-extract an existing document). Provide at most one schema source: `schema` (inline object or JSON string) or `schema_id` (UUID of a saved schema). Omit both for auto-discovery, though this is not recommended in production as it may return 500 on some deployments."
|
|
46654
|
+
},
|
|
46655
|
+
{
|
|
46656
|
+
type: "paragraph",
|
|
46657
|
+
text: "Under the hood, **extract()** reads the file from disk (or fetches it from a URL), uploads it as multipart form data, and returns the structured result in a single round-trip. The response includes a `cost` block with credit consumption and a `rateLimit` object parsed from response headers."
|
|
46658
|
+
},
|
|
46659
|
+
{
|
|
46660
|
+
type: "code",
|
|
46661
|
+
language: "typescript",
|
|
46662
|
+
title: "Extract from a URL with options",
|
|
46663
|
+
code: "const result = await talonic.extract({\n file_url: 'https://example.com/contracts/nda-2025.pdf',\n schema_id: 'sch_def456',\n instructions: 'Focus on termination and non-compete clauses',\n include_markdown: true,\n options: {\n page_range: '1-5',\n language_hint: 'en',\n strict: true,\n },\n})\n\nconsole.log(result.markdown) // raw OCR text (because include_markdown: true)\nconsole.log(result.document.pages) // 5\nconsole.log(result.processing?.duration_ms) // 2340"
|
|
46664
|
+
},
|
|
46665
|
+
{
|
|
46666
|
+
type: "paragraph",
|
|
46667
|
+
text: "Additional parameters fine-tune extraction behavior. The `instructions` field accepts natural-language guidance forwarded to the extraction engine. Set `include_markdown: true` to receive the raw OCR-converted markdown alongside structured data. The `options` object supports `page_range` (e.g. `'1-5'` or `'1,3,7-10'` for PDFs), `language_hint` (ISO 639-1 code), `strict` mode (omit fields not in the schema), and `include_raw_text`. The `content_type` parameter lets you override MIME type inference when the file extension is misleading."
|
|
46668
|
+
},
|
|
46669
|
+
{
|
|
46670
|
+
type: "paragraph",
|
|
46671
|
+
text: "For best results, always supply a `schema` or `schema_id` rather than relying on auto-discovery. Inline schemas work well for one-off extractions, while saved schemas (via `schema_id`) keep your extraction definitions consistent across calls and team members."
|
|
46672
|
+
},
|
|
46673
|
+
{
|
|
46674
|
+
type: "code",
|
|
46675
|
+
language: "typescript",
|
|
46676
|
+
title: "Extract in-memory bytes",
|
|
46677
|
+
code: "import { readFile } from 'node:fs/promises'\n\n// Pass a Buffer or Uint8Array directly\nconst buffer = await readFile('./scan.tiff')\nconst result = await talonic.extract({\n file: buffer,\n filename: 'scan.tiff',\n content_type: 'image/tiff',\n schema: {\n type: 'object',\n properties: {\n patient_name: { type: 'string' },\n date_of_service: { type: 'string', format: 'date' },\n diagnosis_codes: { type: 'array', items: { type: 'string' } },\n total_charges: { type: 'number' },\n },\n },\n})\n\n// The ExtractResult includes document metadata\nconsole.log(result.document.mime_type) // 'image/tiff'\nconsole.log(result.document.size_bytes) // 4521984\nconsole.log(result.document.language_detected) // 'en'"
|
|
46678
|
+
},
|
|
46679
|
+
{
|
|
46680
|
+
type: "paragraph",
|
|
46681
|
+
text: "The `ExtractResult` response is a rich object. The `extraction_id` is a stable identifier you can use with `talonic.extractions.get()` or `talonic.extractions.getData()` to retrieve the result later. The `document` block includes `id`, `filename`, `pages`, `size_bytes`, `mime_type`, `type_detected`, and `language_detected`. The `confidence` block provides `overall` and per-field scores between 0 and 1. The `schema` block shows the source (`'inline'` or `'saved'`), the resolved definition, and a `save_url` for persisting inline schemas. The `links` block provides URLs for the extraction, document, and dashboard views."
|
|
46682
|
+
},
|
|
46683
|
+
{
|
|
46684
|
+
type: "paragraph",
|
|
46685
|
+
text: "The SDK validates parameters before making the API call. Passing zero or more than one file source throws a `TalonicError` with code `missing_file_source` or `multiple_file_sources`. Passing both `schema` and `schema_id` throws `multiple_schemas`. When using JSON Schema format with `properties` but no `required` array, the SDK auto-populates `required` with all property keys to prevent the silent-empty-data footgun where the API returns null for every field."
|
|
46686
|
+
},
|
|
46687
|
+
{
|
|
46688
|
+
type: "callout",
|
|
46689
|
+
text: "Every **extract()** response carries `cost` metadata (credits consumed, EUR value, post-call balance) and `rateLimit` info. Use these to build budget-aware pipelines without extra API calls."
|
|
46690
|
+
}
|
|
46145
46691
|
],
|
|
46146
46692
|
related: [
|
|
46147
|
-
{
|
|
46148
|
-
|
|
46149
|
-
|
|
46693
|
+
{
|
|
46694
|
+
label: "Schemas",
|
|
46695
|
+
slug: "sdk-schemas"
|
|
46696
|
+
},
|
|
46697
|
+
{
|
|
46698
|
+
label: "Documents",
|
|
46699
|
+
slug: "sdk-documents"
|
|
46700
|
+
},
|
|
46701
|
+
{
|
|
46702
|
+
label: "Quick Start",
|
|
46703
|
+
slug: "sdk-quickstart"
|
|
46704
|
+
}
|
|
46150
46705
|
],
|
|
46151
|
-
faq: [
|
|
46152
|
-
|
|
46706
|
+
faq: [
|
|
46707
|
+
{
|
|
46708
|
+
question: "What inputs does talonic.extract() accept?",
|
|
46709
|
+
answer: "It accepts file_path (local file), file_url (remote URL), file (in-memory Blob, Buffer, or Uint8Array with filename), or document_id (previously uploaded). Provide a schema or schema_id for the extraction definition."
|
|
46710
|
+
},
|
|
46711
|
+
{
|
|
46712
|
+
question: "Does extract() return cost information?",
|
|
46713
|
+
answer: "Yes. Every extract response includes a cost block with costCredits, costEur, balanceCredits, cellsResolvedRegistry, and cellsResolvedAi parsed from response headers."
|
|
46714
|
+
},
|
|
46715
|
+
{
|
|
46716
|
+
question: "Can I extract the same document with different schemas?",
|
|
46717
|
+
answer: "Yes. Pass the document_id from a previous upload along with a new schema or schema_id. The document is not re-uploaded, saving bandwidth and credits."
|
|
46718
|
+
},
|
|
46719
|
+
{
|
|
46720
|
+
question: "What does the auto-populate required behavior do?",
|
|
46721
|
+
answer: "When you pass a JSON Schema with properties but no required array, the SDK automatically adds all property keys to required. This prevents the silent-empty-data issue where the API returns null with confidence 0 for every field you intended to extract."
|
|
46722
|
+
},
|
|
46723
|
+
{
|
|
46724
|
+
question: "What file formats does extract() support?",
|
|
46725
|
+
answer: "The SDK supports PDF, PNG, JPG, TIFF, WebP, BMP, GIF, DOCX, DOC, XLSX, XLS, PPTX, PPT, TXT, Markdown, CSV, TSV, JSON, XML, HTML, EML, MSG, and ZIP. MIME types are inferred from the file extension. Use content_type to override when the extension is misleading."
|
|
46726
|
+
},
|
|
46727
|
+
{
|
|
46728
|
+
question: "How do I include the raw OCR text in the response?",
|
|
46729
|
+
answer: "Set include_markdown: true in the extract params. The response will include a markdown field containing the full OCR-converted text that the extraction engine used as input. This is useful for debugging extraction quality or building custom post-processing."
|
|
46730
|
+
}
|
|
46731
|
+
],
|
|
46732
|
+
mentions: [
|
|
46733
|
+
"extract",
|
|
46734
|
+
"schema",
|
|
46735
|
+
"file_path",
|
|
46736
|
+
"file_url",
|
|
46737
|
+
"document_id"
|
|
46738
|
+
]
|
|
46153
46739
|
},
|
|
46154
46740
|
{
|
|
46155
46741
|
slug: "sdk-documents",
|
|
46156
46742
|
parentSlug: "sdk-resources",
|
|
46157
46743
|
title: "Documents",
|
|
46158
|
-
seoTitle: "
|
|
46159
|
-
description: "List,
|
|
46744
|
+
seoTitle: "Documents Resource \u2014 Talonic Node SDK API Reference",
|
|
46745
|
+
description: "List, retrieve, filter, re-extract, and delete workspace documents with talonic.documents, including OCR markdown retrieval and cursor-based pagination.",
|
|
46160
46746
|
content: [
|
|
46161
|
-
{
|
|
46747
|
+
{
|
|
46748
|
+
type: "paragraph",
|
|
46749
|
+
text: "The **documents** resource lets you manage uploaded files in your workspace. Every call to **extract()** creates a document automatically, but you can also list, inspect, re-extract, filter, and delete documents independently."
|
|
46750
|
+
},
|
|
46751
|
+
{
|
|
46752
|
+
type: "code",
|
|
46753
|
+
language: "typescript",
|
|
46754
|
+
title: "Core document operations",
|
|
46755
|
+
code: "// List documents with cursor-based pagination\nconst docs = await talonic.documents.list({ limit: 50 })\nconsole.log(docs.data.map(d => d.filename))\nconsole.log(docs.pagination) // { next_cursor: '...', has_more: true }\n\n// Get a single document with full metadata\nconst doc = await talonic.documents.get('doc_abc123')\nconsole.log(doc.filename) // 'invoice.pdf'\nconsole.log(doc.status) // 'completed'\nconsole.log(doc.pages) // 3\nconsole.log(doc.triage) // { sensitivity: 'internal', pii_detected: true, ... }\n\n// Get OCR markdown\nconst md = await talonic.documents.getMarkdown('doc_abc123')\nconsole.log(md.markdown) // '# Invoice\\n\\nVendor: Acme Corp...'"
|
|
46756
|
+
},
|
|
46757
|
+
{
|
|
46758
|
+
type: "paragraph",
|
|
46759
|
+
text: "The `list()` method accepts `ListDocumentsParams` with filtering by `source_id`, `status` (`'pending'`, `'processing'`, `'completed'`, `'error'`), date range (`after`, `before` as ISO 8601 strings), and full-text `search` across filenames and extracted content. Pagination uses cursor-based navigation: pass `limit` for page size and `cursor` from a previous response's `pagination.next_cursor` to fetch the next page. The legacy `page` and `per_page` parameters are accepted as aliases but cursor-based is the canonical form. Results include a `pagination` object with `next_cursor` and `has_more`."
|
|
46760
|
+
},
|
|
46761
|
+
{
|
|
46762
|
+
type: "paragraph",
|
|
46763
|
+
text: "Use **getMarkdown()** to retrieve the raw OCR output for a document. This is useful for debugging extraction quality or building custom post-processing pipelines on top of the parsed text."
|
|
46764
|
+
},
|
|
46765
|
+
{
|
|
46766
|
+
type: "code",
|
|
46767
|
+
language: "typescript",
|
|
46768
|
+
title: "Filter documents by extracted field values",
|
|
46769
|
+
code: "// Filter documents using composable conditions on extracted fields\nconst filtered = await talonic.documents.filter({\n conditions: [\n { field: 'vendor.name', operator: 'eq', value: 'Acme Corp' },\n { field: 'total_amount', operator: 'gt', value: 10000 },\n ],\n sort: { field: 'invoice_date', direction: 'desc' },\n limit: 25,\n})\n\nconsole.log(filtered.total) // 47\nconsole.log(filtered.documents) // [{ id: '...', filename: '...', fieldValues: { ... } }, ...]"
|
|
46770
|
+
},
|
|
46771
|
+
{
|
|
46772
|
+
type: "paragraph",
|
|
46773
|
+
text: "The **filter()** method lets you query documents by extracted field values using composable conditions. Each condition specifies a `field` (canonical name like `'vendor.name'`) or `fieldId` (UUID), an `operator` (`eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `between`, `contains`, `is_empty`, `is_not_empty`), and a `value`. The `between` operator also accepts `valueTo` for range queries. Results include `fieldValues` with the matched field data for each document hit. You can optionally scope results to a specific source connection with `source_connection_id`."
|
|
46774
|
+
},
|
|
46775
|
+
{
|
|
46776
|
+
type: "code",
|
|
46777
|
+
language: "typescript",
|
|
46778
|
+
title: "Re-extract and delete",
|
|
46779
|
+
code: "// Re-run extraction on an existing document (e.g. after schema update)\nconst reExtracted = await talonic.documents.reExtract('doc_abc123')\nconsole.log(reExtracted.status) // 'processing'\nconsole.log(reExtracted.message) // 'Re-extraction started'\n\n// Delete a document and all associated extractions (irreversible)\nconst deleted = await talonic.documents.delete('doc_abc123')\nconsole.log(deleted.deleted) // true"
|
|
46780
|
+
},
|
|
46781
|
+
{
|
|
46782
|
+
type: "paragraph",
|
|
46783
|
+
text: "The **get()** method returns a `Document` object with full metadata including `triage` classification data when available. The triage block contains `sensitivity` (public, internal, restricted), `department`, `jurisdiction` (ISO country code), `pii_detected`, `pii_categories`, `regulated_data`, and `confidentiality_marking`. The `processing_log` array shows each pipeline step with status, duration, and detail. These fields are populated progressively as the document moves through the processing pipeline."
|
|
46784
|
+
},
|
|
46785
|
+
{
|
|
46786
|
+
type: "callout",
|
|
46787
|
+
text: "Deleting a document also removes all associated extractions. If you need to preserve extraction history, fetch the data with **extractions.getData()** before deleting."
|
|
46788
|
+
}
|
|
46162
46789
|
],
|
|
46163
46790
|
related: [
|
|
46164
|
-
{
|
|
46165
|
-
|
|
46791
|
+
{
|
|
46792
|
+
label: "Extract",
|
|
46793
|
+
slug: "sdk-extract"
|
|
46794
|
+
},
|
|
46795
|
+
{
|
|
46796
|
+
label: "Extractions",
|
|
46797
|
+
slug: "sdk-extractions"
|
|
46798
|
+
}
|
|
46166
46799
|
],
|
|
46167
|
-
faq: [
|
|
46168
|
-
|
|
46800
|
+
faq: [
|
|
46801
|
+
{
|
|
46802
|
+
question: "How do I list documents with the Talonic SDK?",
|
|
46803
|
+
answer: "Call talonic.documents.list() with optional parameters like limit, cursor, status, source_id, after, before, and search. Results are paginated using cursor-based navigation."
|
|
46804
|
+
},
|
|
46805
|
+
{
|
|
46806
|
+
question: "What does getMarkdown() return?",
|
|
46807
|
+
answer: "It returns the raw OCR markdown output for a document, which is the text the extraction engine uses as input. Useful for debugging or building custom processing pipelines."
|
|
46808
|
+
},
|
|
46809
|
+
{
|
|
46810
|
+
question: "Does deleting a document remove its extractions?",
|
|
46811
|
+
answer: "Yes. Deleting a document removes all associated extraction results. Retrieve any data you need before calling delete()."
|
|
46812
|
+
},
|
|
46813
|
+
{
|
|
46814
|
+
question: "How do I filter documents by extracted field values?",
|
|
46815
|
+
answer: "Use talonic.documents.filter() with an array of conditions. Each condition specifies a field name or fieldId, an operator (eq, gt, contains, between, etc.), and a value. You can combine multiple conditions, add sort order, and paginate with page and limit parameters."
|
|
46816
|
+
},
|
|
46817
|
+
{
|
|
46818
|
+
question: "What is the triage field on documents?",
|
|
46819
|
+
answer: "The triage block contains automatic classification output including sensitivity tier, department, jurisdiction, PII detection, regulated data flags, and confidentiality markings. It is populated by the Talonic classification pipeline after document ingestion and may be null for newly uploaded documents."
|
|
46820
|
+
}
|
|
46821
|
+
],
|
|
46822
|
+
mentions: [
|
|
46823
|
+
"documents",
|
|
46824
|
+
"list",
|
|
46825
|
+
"get",
|
|
46826
|
+
"delete",
|
|
46827
|
+
"markdown"
|
|
46828
|
+
]
|
|
46169
46829
|
},
|
|
46170
46830
|
{
|
|
46171
46831
|
slug: "sdk-extractions",
|
|
46172
46832
|
parentSlug: "sdk-resources",
|
|
46173
46833
|
title: "Extractions",
|
|
46174
|
-
seoTitle: "
|
|
46175
|
-
description: "Query extraction results,
|
|
46834
|
+
seoTitle: "Extractions Resource \u2014 Talonic Node SDK API Reference",
|
|
46835
|
+
description: "Query extraction results with talonic.extractions: list runs, fetch structured data as JSON or CSV, and patch field values with audited human corrections.",
|
|
46176
46836
|
content: [
|
|
46177
|
-
{
|
|
46837
|
+
{
|
|
46838
|
+
type: "paragraph",
|
|
46839
|
+
text: "The **extractions** resource gives you access to the structured data produced by each extraction run. Every **extract()** call creates an extraction record that you can query, export, and correct after the fact."
|
|
46840
|
+
},
|
|
46841
|
+
{
|
|
46842
|
+
type: "code",
|
|
46843
|
+
language: "typescript",
|
|
46844
|
+
title: "List and retrieve extractions",
|
|
46845
|
+
code: "// List extractions for a specific document\nconst extractions = await talonic.extractions.list({\n document_id: 'doc_abc123',\n status: 'complete',\n limit: 10,\n})\n\nfor (const ext of extractions.data) {\n console.log(`${ext.id}: confidence ${ext.confidence_overall}, created ${ext.created_at}`)\n}\n\n// Get full extraction with per-field confidence\nconst extraction = await talonic.extractions.get('ext_xyz789')\nconsole.log(extraction.data) // { vendor_name: 'Acme', total: 1500, ... }\nconsole.log(extraction.confidence?.overall) // 0.94\nconsole.log(extraction.confidence?.fields) // { vendor_name: 0.99, total: 0.91, ... }\nconsole.log(extraction.metadata?.processing_time_ms) // 1820"
|
|
46846
|
+
},
|
|
46847
|
+
{
|
|
46848
|
+
type: "paragraph",
|
|
46849
|
+
text: "The `list()` method accepts `ListExtractionsParams` with optional filters for `document_id`, `schema_id`, and `status` (`'complete'`, `'processing'`, `'failed'`). Pagination uses cursor-based navigation with `cursor` and `limit` parameters. The legacy `page` and `per_page` parameters are accepted for compatibility. Each extraction in the list response includes a compact `confidence_overall` number, while the individual `get()` response includes the full `confidence` object with per-field scores."
|
|
46850
|
+
},
|
|
46851
|
+
{
|
|
46852
|
+
type: "paragraph",
|
|
46853
|
+
text: "Use **getData()** to retrieve extraction results as JSON (default) or CSV. The JSON format returns typed objects matching your schema definition, while CSV is convenient for spreadsheet workflows or bulk data exports. The method uses TypeScript overloads: calling with `{ format: 'json' }` or no options returns `WithRateLimit<Record<string, unknown>>`, while `{ format: 'csv' }` returns a plain `string`."
|
|
46854
|
+
},
|
|
46855
|
+
{
|
|
46856
|
+
type: "code",
|
|
46857
|
+
language: "typescript",
|
|
46858
|
+
title: "Export extraction data",
|
|
46859
|
+
code: `// Get structured data as JSON (default)
|
|
46860
|
+
const jsonData = await talonic.extractions.getData('ext_xyz789')
|
|
46861
|
+
console.log(jsonData) // { vendor_name: 'Acme', line_items: [...], total: 1500 }
|
|
46862
|
+
|
|
46863
|
+
// Get structured data as CSV for spreadsheet workflows
|
|
46864
|
+
const csvData = await talonic.extractions.getData('ext_xyz789', { format: 'csv' })
|
|
46865
|
+
console.log(csvData)
|
|
46866
|
+
// "vendor_name,total,due_date\\nAcme Corp,1500,2025-03-15"
|
|
46867
|
+
|
|
46868
|
+
// Write CSV to file
|
|
46869
|
+
import { writeFile } from 'node:fs/promises'
|
|
46870
|
+
await writeFile('./export.csv', csvData)`
|
|
46871
|
+
},
|
|
46872
|
+
{
|
|
46873
|
+
type: "paragraph",
|
|
46874
|
+
text: "The **patch()** method submits field-level corrections back to the extraction. Corrections improve future extraction accuracy for similar documents by feeding the correction loop, so submitting them is worth the effort even if you fix the value downstream. Each correction specifies the `field` name, the corrected `value`, and an optional `reason` string explaining the change. The `propagate` parameter controls scope: `'this_document_only'` (default) applies the correction to this extraction only, while `'all_similar'` propagates it to similar extractions across your workspace."
|
|
46875
|
+
},
|
|
46876
|
+
{
|
|
46877
|
+
type: "code",
|
|
46878
|
+
language: "typescript",
|
|
46879
|
+
title: "Submit corrections",
|
|
46880
|
+
code: "// Submit field-level corrections to improve future accuracy\nawait talonic.extractions.patch('ext_xyz789', {\n corrections: [\n {\n field: 'vendor_name',\n value: 'Acme Corporation',\n reason: 'Full legal name required',\n },\n {\n field: 'total_amount',\n value: 14250.00,\n reason: 'OCR misread decimal separator',\n },\n ],\n propagate: 'all_similar', // apply to similar documents too\n})"
|
|
46881
|
+
},
|
|
46882
|
+
{
|
|
46883
|
+
type: "paragraph",
|
|
46884
|
+
text: "The `Extraction` interface includes metadata about the extraction run. The `metadata` block provides `pages` (number of pages processed), `language` (detected language code), `document_type` (detected document category), and `processing_time_ms`. The `links` object contains URLs for the extraction resource, related endpoints, and the dashboard view. Use these links to build navigation between the SDK and the Talonic web dashboard."
|
|
46885
|
+
},
|
|
46886
|
+
{
|
|
46887
|
+
type: "callout",
|
|
46888
|
+
text: "A single document can have multiple extractions if it was re-extracted with different schemas. Use **list({ document_id })** to see all extraction runs for a given document."
|
|
46889
|
+
}
|
|
46890
|
+
],
|
|
46891
|
+
related: [
|
|
46892
|
+
{
|
|
46893
|
+
label: "Extract",
|
|
46894
|
+
slug: "sdk-extract"
|
|
46895
|
+
},
|
|
46896
|
+
{
|
|
46897
|
+
label: "Documents",
|
|
46898
|
+
slug: "sdk-documents"
|
|
46899
|
+
}
|
|
46900
|
+
],
|
|
46901
|
+
faq: [
|
|
46902
|
+
{
|
|
46903
|
+
question: "How do I get extraction data as CSV?",
|
|
46904
|
+
answer: 'Call talonic.extractions.getData(id, { format: "csv" }) to receive the structured data as a CSV string. The return type is a plain string rather than a WithRateLimit wrapper.'
|
|
46905
|
+
},
|
|
46906
|
+
{
|
|
46907
|
+
question: "What does the patch() method do?",
|
|
46908
|
+
answer: "It submits field-level corrections to an extraction result. Each correction specifies a field name, corrected value, and optional reason. Corrections are fed back into the extraction engine to improve accuracy for similar documents in future runs. Use the propagate parameter to control whether corrections apply to this document only or all similar documents."
|
|
46909
|
+
},
|
|
46910
|
+
{
|
|
46911
|
+
question: "Can a document have multiple extractions?",
|
|
46912
|
+
answer: "Yes. Re-extracting a document with a different schema creates a new extraction record. Use extractions.list({ document_id }) to retrieve all runs for one document."
|
|
46913
|
+
},
|
|
46914
|
+
{
|
|
46915
|
+
question: "What is the difference between get() and getData()?",
|
|
46916
|
+
answer: "The get() method returns the full Extraction object including metadata, confidence scores, status, timestamps, and links alongside the extracted data. The getData() method returns just the extracted field values as a plain JSON object or CSV string, without the surrounding metadata. Use get() for inspection and debugging, getData() for data export and downstream processing."
|
|
46917
|
+
},
|
|
46918
|
+
{
|
|
46919
|
+
question: "How do I filter extractions by status?",
|
|
46920
|
+
answer: "Pass the status parameter to extractions.list() with one of 'complete', 'processing', or 'failed'. You can combine this with document_id and schema_id filters to narrow results further. Pagination is cursor-based using cursor and limit parameters."
|
|
46921
|
+
}
|
|
46922
|
+
],
|
|
46923
|
+
mentions: [
|
|
46924
|
+
"extractions",
|
|
46925
|
+
"getData",
|
|
46926
|
+
"corrections",
|
|
46927
|
+
"CSV",
|
|
46928
|
+
"JSON"
|
|
46929
|
+
]
|
|
46930
|
+
},
|
|
46931
|
+
{
|
|
46932
|
+
slug: "sdk-schemas",
|
|
46933
|
+
parentSlug: "sdk-resources",
|
|
46934
|
+
title: "Schemas",
|
|
46935
|
+
seoTitle: "Schemas Resource \u2014 Talonic Node.js SDK API Reference",
|
|
46936
|
+
description: "Create, list, update, and delete reusable JSON Schema extraction definitions with talonic.schemas for consistent structured output across all documents.",
|
|
46937
|
+
content: [
|
|
46938
|
+
{
|
|
46939
|
+
type: "paragraph",
|
|
46940
|
+
text: "The **schemas** resource manages reusable extraction definitions. Instead of passing an inline `schema` on every **extract()** call, create a named schema once and reference it by `schema_id` across all your extractions."
|
|
46941
|
+
},
|
|
46942
|
+
{
|
|
46943
|
+
type: "code",
|
|
46944
|
+
language: "typescript",
|
|
46945
|
+
title: "Create and use a saved schema",
|
|
46946
|
+
code: "// Create a reusable schema for invoice extraction\nconst schema = await talonic.schemas.create({\n name: 'Invoice Schema v2',\n description: 'Standard invoice fields for AP automation',\n definition: {\n type: 'object',\n properties: {\n vendor_name: { type: 'string', description: 'Legal entity name of the vendor' },\n invoice_number: { type: 'string' },\n invoice_date: { type: 'string', format: 'date' },\n due_date: { type: 'string', format: 'date' },\n total_amount: { type: 'number' },\n currency: { type: 'string' },\n line_items: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n description: { type: 'string' },\n quantity: { type: 'number' },\n unit_price: { type: 'number' },\n },\n },\n },\n },\n },\n})\n\nconsole.log(schema.id) // 'sch_abc123'\nconsole.log(schema.short_id) // 'SCH-3A4D79D2'\nconsole.log(schema.version) // 1\n\n// Use the saved schema for extraction\nconst result = await talonic.extract({\n file_path: './invoice.pdf',\n schema_id: schema.id,\n})"
|
|
46947
|
+
},
|
|
46948
|
+
{
|
|
46949
|
+
type: "paragraph",
|
|
46950
|
+
text: "The `create()` method accepts a `CreateSchemaParams` object with `name` (required), `definition` (required, JSON Schema object), and an optional `description`. The returned `Schema` object includes `id` (canonical UUID), `short_id` (human-readable identifier like `'SCH-3A4D79D2'` visible in the dashboard), `version` (starts at 1, bumps on each update), `field_count`, `extraction_count`, and `links` with URLs for the schema, its extractions, and the dashboard view. Both `id` and `short_id` are accepted as lookup keys on `get()`, `update()`, and `delete()`."
|
|
46951
|
+
},
|
|
46952
|
+
{
|
|
46953
|
+
type: "paragraph",
|
|
46954
|
+
text: 'Schema definitions follow JSON Schema format with `type: "object"` and `properties`. Each property specifies a field name and type that the extraction engine will resolve. Updating a schema does not retroactively change existing extractions, but all future **extract()** calls using that `schema_id` will pick up the new definition. The `version` field is bumped automatically on each update so you can track which version a given extraction used.'
|
|
46955
|
+
},
|
|
46956
|
+
{
|
|
46957
|
+
type: "code",
|
|
46958
|
+
language: "typescript",
|
|
46959
|
+
title: "List, update, and delete schemas",
|
|
46960
|
+
code: "// List all schemas in the workspace\nconst schemas = await talonic.schemas.list()\nfor (const s of schemas.data) {\n console.log(`${s.name} (v${s.version}): ${s.field_count} fields, ${s.extraction_count} extractions`)\n}\n\n// Update a schema definition (bumps version, does not change existing extractions)\nconst updated = await talonic.schemas.update('sch_abc123', {\n name: 'Invoice Schema v3',\n definition: {\n type: 'object',\n properties: {\n vendor_name: { type: 'string' },\n invoice_number: { type: 'string' },\n total_amount: { type: 'number' },\n tax_amount: { type: 'number' }, // new field\n payment_terms: { type: 'string' }, // new field\n },\n },\n})\nconsole.log(updated.version) // 2\n\n// Delete a schema (existing extractions are retained)\nconst deleted = await talonic.schemas.delete('sch_abc123')\nconsole.log(deleted.deleted) // true"
|
|
46961
|
+
},
|
|
46962
|
+
{
|
|
46963
|
+
type: "paragraph",
|
|
46964
|
+
text: "Saved schemas are workspace-scoped, so every team member with API access can reference the same `schema_id`. This makes schemas the right tool for standardising extraction output across a pipeline or team. The `update()` method uses HTTP PUT and replaces the entire schema definition. Pass all fields you want to keep, not just the changes. The `delete()` method removes the schema but retains all existing extractions that used it, so historical data is preserved."
|
|
46965
|
+
},
|
|
46966
|
+
{
|
|
46967
|
+
type: "code",
|
|
46968
|
+
language: "typescript",
|
|
46969
|
+
title: "Retrieve a schema by ID",
|
|
46970
|
+
code: "// Get a schema by canonical UUID or short_id\nconst schema = await talonic.schemas.get('sch_abc123')\n// or: await talonic.schemas.get('SCH-3A4D79D2')\n\nconsole.log(schema.name) // 'Invoice Schema v2'\nconsole.log(schema.definition) // { type: 'object', properties: { ... } }\nconsole.log(schema.created_at) // '2025-06-01T10:30:00.000Z'\nconsole.log(schema.updated_at) // '2025-06-15T14:22:00.000Z'\nconsole.log(schema.links) // { self: '...', extractions: '...', dashboard: '...' }"
|
|
46971
|
+
},
|
|
46972
|
+
{
|
|
46973
|
+
type: "callout",
|
|
46974
|
+
variant: "warning",
|
|
46975
|
+
text: 'Use full JSON Schema format (`type: "object"` with `properties`) rather than the flat key-type shorthand. The server-side normaliser for the shorthand format is not fully supported yet.'
|
|
46976
|
+
}
|
|
46178
46977
|
],
|
|
46179
46978
|
related: [
|
|
46180
|
-
{
|
|
46181
|
-
|
|
46182
|
-
|
|
46183
|
-
|
|
46184
|
-
|
|
46185
|
-
|
|
46186
|
-
|
|
46187
|
-
|
|
46188
|
-
parentSlug: "sdk-resources",
|
|
46189
|
-
title: "Schemas",
|
|
46190
|
-
seoTitle: "SDK Schemas Resource \u2014 Talonic Docs",
|
|
46191
|
-
description: "Create, list, get, update, and delete reusable extraction schemas via the Talonic Node SDK.",
|
|
46192
|
-
content: [
|
|
46193
|
-
{ type: "code", language: "typescript", title: "Schemas API", code: "// List all schemas\nawait talonic.schemas.list()\n\n// Get a schema\nawait talonic.schemas.get(id)\n\n// Create a new schema\nawait talonic.schemas.create({ name, definition })\n\n// Update a schema\nawait talonic.schemas.update(id, { ... })\n\n// Delete a schema\nawait talonic.schemas.delete(id)" }
|
|
46979
|
+
{
|
|
46980
|
+
label: "Extract",
|
|
46981
|
+
slug: "sdk-extract"
|
|
46982
|
+
},
|
|
46983
|
+
{
|
|
46984
|
+
label: "Jobs",
|
|
46985
|
+
slug: "sdk-jobs"
|
|
46986
|
+
}
|
|
46194
46987
|
],
|
|
46195
|
-
|
|
46196
|
-
{
|
|
46197
|
-
|
|
46988
|
+
faq: [
|
|
46989
|
+
{
|
|
46990
|
+
question: "How do I create a reusable schema?",
|
|
46991
|
+
answer: "Call talonic.schemas.create({ name, definition }) with a JSON Schema definition. The returned object includes id and short_id. Use either as schema_id in future extract calls."
|
|
46992
|
+
},
|
|
46993
|
+
{
|
|
46994
|
+
question: "Are schemas shared across team members?",
|
|
46995
|
+
answer: "Yes. Schemas are workspace-scoped. Anyone with API access to the workspace can reference the same schema_id in their extract calls."
|
|
46996
|
+
},
|
|
46997
|
+
{
|
|
46998
|
+
question: "Does updating a schema change existing extractions?",
|
|
46999
|
+
answer: "No. Updating a schema bumps the version number and only affects future extract calls that reference that schema_id. Existing extraction results remain unchanged and retain their original schema version."
|
|
47000
|
+
},
|
|
47001
|
+
{
|
|
47002
|
+
question: "What happens to extractions when I delete a schema?",
|
|
47003
|
+
answer: "Existing extractions are retained when you delete a schema. The extraction data remains accessible via the extractions resource. Only the schema definition itself is removed, so you can no longer use that schema_id for new extractions."
|
|
47004
|
+
},
|
|
47005
|
+
{
|
|
47006
|
+
question: "Can I look up a schema by its short_id?",
|
|
47007
|
+
answer: "Yes. Both the canonical UUID (id) and the human-readable short_id (e.g. 'SCH-3A4D79D2') are accepted as lookup keys on get(), update(), and delete(). The short_id is displayed in the Talonic dashboard for easy reference."
|
|
47008
|
+
}
|
|
46198
47009
|
],
|
|
46199
|
-
|
|
46200
|
-
|
|
47010
|
+
mentions: [
|
|
47011
|
+
"schemas",
|
|
47012
|
+
"JSON Schema",
|
|
47013
|
+
"create",
|
|
47014
|
+
"update"
|
|
47015
|
+
]
|
|
46201
47016
|
},
|
|
46202
47017
|
{
|
|
46203
47018
|
slug: "sdk-jobs",
|
|
46204
47019
|
parentSlug: "sdk-resources",
|
|
46205
47020
|
title: "Jobs",
|
|
46206
|
-
seoTitle: "
|
|
46207
|
-
description: "
|
|
47021
|
+
seoTitle: "Batch Jobs Resource \u2014 Talonic Node SDK API Reference",
|
|
47022
|
+
description: "Run asynchronous batch extraction with talonic.jobs: create jobs from document sets, poll live progress, retrieve structured results, and cancel safely.",
|
|
46208
47023
|
content: [
|
|
46209
|
-
{
|
|
47024
|
+
{
|
|
47025
|
+
type: "paragraph",
|
|
47026
|
+
text: "The **jobs** resource handles asynchronous batch extraction across multiple documents. Create a job with a `schema_id` and an array of `document_ids`, then poll for completion or fetch results when the job finishes."
|
|
47027
|
+
},
|
|
47028
|
+
{
|
|
47029
|
+
type: "code",
|
|
47030
|
+
language: "typescript",
|
|
47031
|
+
title: "Create and monitor a batch job",
|
|
47032
|
+
code: "// Create a batch extraction job\nconst job = await talonic.jobs.create({\n schema_id: 'sch_abc123',\n document_ids: ['doc_001', 'doc_002', 'doc_003', 'doc_004', 'doc_005'],\n name: 'Q4 Invoice Batch',\n})\n\nconsole.log(job.id) // 'job_xyz789'\nconsole.log(job.status) // 'queued'\n\n// Poll for completion\nlet current = await talonic.jobs.get(job.id)\nwhile (current.status === 'queued' || current.status === 'processing') {\n console.log(`Progress: ${current.completed_documents}/${current.total_documents} (${current.current_phase})`)\n await new Promise(r => setTimeout(r, 5000))\n current = await talonic.jobs.get(job.id)\n}\n\nconsole.log(`Job ${current.status}: ${current.completed_documents} completed, ${current.failed_documents} failed`)"
|
|
47033
|
+
},
|
|
47034
|
+
{
|
|
47035
|
+
type: "paragraph",
|
|
47036
|
+
text: "The `create()` method accepts `CreateJobParams` with `schema_id` (required), optional `document_ids` (array of document UUIDs to process), and optional `name` (human-readable label). When `document_ids` is omitted, the job processes all unprocessed documents in the workspace. The returned `Job` object includes `id`, `status`, `progress`, `total_documents`, `completed_documents`, `failed_documents`, `current_phase`, `estimated_completion`, and `links` with URLs for the job and its results."
|
|
47037
|
+
},
|
|
47038
|
+
{
|
|
47039
|
+
type: "paragraph",
|
|
47040
|
+
text: "Jobs run server-side and process documents in parallel. Use **get()** to poll the job status (`'queued'`, `'processing'`, `'completed'`, `'failed'`, `'cancelled'`) and **getResults()** to retrieve the extraction output once complete. For long-running batches, poll on a reasonable interval such as every 5 seconds. The `grid_stats` block on the job object provides `total_cells`, `filled`, `empty`, and `fill_rate` for monitoring extraction quality across the batch."
|
|
47041
|
+
},
|
|
47042
|
+
{
|
|
47043
|
+
type: "code",
|
|
47044
|
+
language: "typescript",
|
|
47045
|
+
title: "Retrieve batch results",
|
|
47046
|
+
code: "// Get structured results from a completed job\nconst results = await talonic.jobs.getResults('job_xyz789')\n\nfor (const row of results.data) {\n console.log(`${row.document_filename}: ${JSON.stringify(row.values)}`)\n}\n// invoice_001.pdf: { vendor_name: 'Acme', total: 1500, ... }\n// invoice_002.pdf: { vendor_name: 'Globex', total: 3200, ... }\n\n// Export to CSV or send to your database\nconst rows = results.data.map(r => ({\n filename: r.document_filename,\n document_id: r.document_id,\n ...r.values,\n}))"
|
|
47047
|
+
},
|
|
47048
|
+
{
|
|
47049
|
+
type: "paragraph",
|
|
47050
|
+
text: "Use **cancel()** to abort a job that is still in progress. Cancelled jobs stop processing remaining documents but any extractions already completed are preserved and accessible via **getResults()**. The `cancelled_at` timestamp is set on the job object when cancellation takes effect."
|
|
47051
|
+
},
|
|
47052
|
+
{
|
|
47053
|
+
type: "code",
|
|
47054
|
+
language: "typescript",
|
|
47055
|
+
title: "List and cancel jobs",
|
|
47056
|
+
code: "// List jobs filtered by status\nconst runningJobs = await talonic.jobs.list({ status: 'processing', limit: 10 })\nfor (const j of runningJobs.data) {\n console.log(`${j.id}: ${j.completed_documents}/${j.total_documents} (est. ${j.estimated_completion})`)\n}\n\n// Cancel a job \u2014 partial results are retained\nconst cancelled = await talonic.jobs.cancel('job_xyz789')\nconsole.log(cancelled.status) // 'cancelled'\nconsole.log(cancelled.cancelled_at) // '2025-06-15T14:30:00.000Z'\n\n// Retrieve whatever completed before cancellation\nconst partial = await talonic.jobs.getResults('job_xyz789')\nconsole.log(`Retrieved ${partial.data.length} results before cancellation`)"
|
|
47057
|
+
},
|
|
47058
|
+
{
|
|
47059
|
+
type: "paragraph",
|
|
47060
|
+
text: "The `list()` method accepts `ListJobsParams` with optional `status` filter, cursor-based pagination (`cursor` and `limit`), and `order` for sorting. The `JobResults` response contains a `data` array where each entry has `document_id`, `document_filename`, and `values` (the extracted field data). This flat structure makes it straightforward to aggregate results across documents for reporting or database insertion."
|
|
47061
|
+
},
|
|
47062
|
+
{
|
|
47063
|
+
type: "callout",
|
|
47064
|
+
text: "Jobs require a saved `schema_id` rather than an inline schema. Create your schema with **schemas.create()** first, then pass the returned ID to **jobs.create()**."
|
|
47065
|
+
}
|
|
46210
47066
|
],
|
|
46211
47067
|
related: [
|
|
46212
|
-
{
|
|
46213
|
-
|
|
47068
|
+
{
|
|
47069
|
+
label: "Schemas",
|
|
47070
|
+
slug: "sdk-schemas"
|
|
47071
|
+
},
|
|
47072
|
+
{
|
|
47073
|
+
label: "Extract",
|
|
47074
|
+
slug: "sdk-extract"
|
|
47075
|
+
},
|
|
47076
|
+
{
|
|
47077
|
+
label: "Extractions",
|
|
47078
|
+
slug: "sdk-extractions"
|
|
47079
|
+
}
|
|
46214
47080
|
],
|
|
46215
|
-
faq: [
|
|
46216
|
-
|
|
47081
|
+
faq: [
|
|
47082
|
+
{
|
|
47083
|
+
question: "How do I run batch extraction with the Talonic SDK?",
|
|
47084
|
+
answer: "Call talonic.jobs.create({ schema_id, document_ids }) to start an async batch job, then poll with talonic.jobs.get(id) or retrieve results with talonic.jobs.getResults(id). Omit document_ids to process all unprocessed documents in the workspace."
|
|
47085
|
+
},
|
|
47086
|
+
{
|
|
47087
|
+
question: "Can I use an inline schema with jobs?",
|
|
47088
|
+
answer: "No. Jobs require a saved schema_id. Create your schema first with talonic.schemas.create(), then pass the returned ID to talonic.jobs.create()."
|
|
47089
|
+
},
|
|
47090
|
+
{
|
|
47091
|
+
question: "What happens to completed extractions if I cancel a job?",
|
|
47092
|
+
answer: "Extractions already completed before cancellation are preserved. You can still retrieve them with talonic.jobs.getResults(id). The job status changes to 'cancelled' and the cancelled_at timestamp is set."
|
|
47093
|
+
},
|
|
47094
|
+
{
|
|
47095
|
+
question: "How do I monitor batch job progress?",
|
|
47096
|
+
answer: "Poll talonic.jobs.get(id) on a regular interval (e.g. every 5 seconds). The Job object includes completed_documents, total_documents, failed_documents, current_phase, progress, estimated_completion, and grid_stats with fill_rate for quality monitoring."
|
|
47097
|
+
},
|
|
47098
|
+
{
|
|
47099
|
+
question: "What job statuses are available for filtering?",
|
|
47100
|
+
answer: "Jobs can be in one of five statuses: 'queued' (waiting to start), 'processing' (actively extracting), 'completed' (all documents processed), 'failed' (terminal error), or 'cancelled' (manually stopped). Use the status parameter on list() to filter."
|
|
47101
|
+
}
|
|
47102
|
+
],
|
|
47103
|
+
mentions: [
|
|
47104
|
+
"jobs",
|
|
47105
|
+
"batch",
|
|
47106
|
+
"async"
|
|
47107
|
+
]
|
|
46217
47108
|
},
|
|
46218
47109
|
{
|
|
46219
47110
|
slug: "sdk-cli-usage",
|
|
46220
47111
|
parentSlug: "sdk-cli",
|
|
46221
47112
|
title: "Usage",
|
|
46222
|
-
seoTitle: "Talonic CLI
|
|
46223
|
-
description: "Use the talonic CLI
|
|
47113
|
+
seoTitle: "Talonic CLI \u2014 Terminal Document Extraction for Node.js",
|
|
47114
|
+
description: "Use the bundled talonic CLI to extract documents, list schemas and documents, and script its JSON output from the terminal with only an API key in env.",
|
|
46224
47115
|
content: [
|
|
46225
|
-
{
|
|
46226
|
-
|
|
46227
|
-
talonic documents
|
|
47116
|
+
{
|
|
47117
|
+
type: "paragraph",
|
|
47118
|
+
text: "The package ships with a `talonic` binary for terminal-based workflows. It focuses on the operations you reach for most often outside of code: running an extraction against a local file, listing your saved schemas, and inspecting the documents in your workspace. Every command is a thin wrapper over the same SDK client, so authentication, retries, and error mapping behave exactly as they do in TypeScript."
|
|
47119
|
+
},
|
|
47120
|
+
{
|
|
47121
|
+
type: "code",
|
|
47122
|
+
language: "bash",
|
|
47123
|
+
title: "Basic usage",
|
|
47124
|
+
code: `# Extract structured data from a file with an inline schema
|
|
46228
47125
|
talonic extract ./invoice.pdf \\
|
|
46229
|
-
--schema='{"vendor_name":"string","total_amount":"number"}'
|
|
46230
|
-
|
|
47126
|
+
--schema='{"type":"object","properties":{"vendor_name":{"type":"string"},"total_amount":{"type":"number"}}}'
|
|
47127
|
+
|
|
47128
|
+
# Extract with a saved schema
|
|
47129
|
+
talonic extract ./contract.pdf --schema-id=sch_abc123
|
|
47130
|
+
|
|
47131
|
+
# List schemas in your workspace
|
|
47132
|
+
talonic schemas list
|
|
47133
|
+
|
|
47134
|
+
# List documents with paging and a status filter
|
|
47135
|
+
talonic documents list --per-page=20 --status=completed
|
|
47136
|
+
|
|
47137
|
+
# Show help and version
|
|
47138
|
+
talonic --help
|
|
47139
|
+
talonic --version`
|
|
47140
|
+
},
|
|
47141
|
+
{
|
|
47142
|
+
type: "paragraph",
|
|
47143
|
+
text: "The CLI reads `TALONIC_API_KEY` from the environment and exits with an error message if it is missing. Set `TALONIC_BASE_URL` to point at a staging environment or local proxy; it maps directly to the SDK's `baseUrl` option. There is intentionally no `--api-key` flag, so keys never end up in your shell history. All successful output is pretty-printed JSON on stdout, making it straightforward to pipe into `jq`, `grep`, or any other tool that accepts JSON input."
|
|
47144
|
+
},
|
|
47145
|
+
{
|
|
47146
|
+
type: "code",
|
|
47147
|
+
language: "bash",
|
|
47148
|
+
title: "Supported commands",
|
|
47149
|
+
code: "# Schemas\ntalonic schemas list # list all saved schemas\ntalonic schemas get sch_abc123 # get one schema by ID\n\n# Documents\ntalonic documents list # list documents\ntalonic documents list --per-page=10 # page size\ntalonic documents list --status=error # filter: pending | processing | completed | error\ntalonic documents get doc_abc123 # get one document by ID\n\n# Extraction\ntalonic extract <file_path> [options]\n# --schema='<json>' inline schema (full JSON Schema recommended)\n# --schema-id=<id> use a saved schema\n# --instructions='<text>' natural-language extraction guidance\n# --include-markdown include OCR markdown in the response\n\n# Environment\n# TALONIC_API_KEY (required) your tlnc_ API key\n# TALONIC_BASE_URL (optional) override the API base URL"
|
|
47150
|
+
},
|
|
47151
|
+
{
|
|
47152
|
+
type: "paragraph",
|
|
47153
|
+
text: "Command output is the full SDK response serialized with two-space indentation, so list commands return an object with `data` and `pagination` keys \u2014 plus the `rateLimit` and `cost` metadata the SDK attaches to every response. Keep that envelope in mind when scripting: document IDs live at `.data[].id`, not at the top level. Extract output mirrors the `ExtractResult` shape, with the structured fields under `.data`."
|
|
47154
|
+
},
|
|
47155
|
+
{
|
|
47156
|
+
type: "code",
|
|
47157
|
+
language: "bash",
|
|
47158
|
+
title: "Scripting with jq",
|
|
47159
|
+
code: "# Extract all document IDs\ntalonic documents list | jq '.data[].id'\n\n# Filenames of completed documents\ntalonic documents list --status=completed | jq '.data[].filename'\n\n# Run an extraction and keep only the structured fields\ntalonic extract ./invoice.pdf --schema-id=sch_abc123 | jq '.data'\n\n# Check the remaining rate-limit budget on any call\ntalonic schemas list | jq '.rateLimit'\n\n# Save a full extraction result to a file\ntalonic extract ./contract.pdf --schema-id=sch_abc123 > result.json"
|
|
47160
|
+
},
|
|
47161
|
+
{
|
|
47162
|
+
type: "paragraph",
|
|
47163
|
+
text: "Because the CLI constructs a standard SDK client, transient failures (429 rate limits, 5xx responses, network errors, timeouts) are retried automatically with exponential backoff before anything is reported. When a command does fail, the error goes to stderr as plain-text lines \u2014 `Error: <message>` followed by indented `code:`, `status:`, and `request-id:` lines when available \u2014 and the process exits with status 1. Stdout stays reserved for clean JSON, so redirects and pipes never mix data with diagnostics."
|
|
47164
|
+
},
|
|
47165
|
+
{
|
|
47166
|
+
type: "paragraph",
|
|
47167
|
+
text: "The CLI is deliberately smaller than the SDK: operations like schema creation, extraction listing, batch jobs, corrections, and credit queries are SDK-only today. For anything beyond extract, schema lookup, and document lookup, write a short script against `@talonic/node` instead \u2014 the Quick Start covers the same flows in a few lines of TypeScript. `talonic --help` always prints the current, authoritative command list for the version you have installed."
|
|
47168
|
+
},
|
|
47169
|
+
{
|
|
47170
|
+
type: "callout",
|
|
47171
|
+
text: "Set `TALONIC_API_KEY` in your shell profile or `.env` file to avoid passing it on every invocation. The CLI does not support an `--api-key` flag, which prevents accidental key exposure in shell history."
|
|
47172
|
+
}
|
|
46231
47173
|
],
|
|
46232
47174
|
related: [
|
|
46233
|
-
{
|
|
46234
|
-
|
|
47175
|
+
{
|
|
47176
|
+
label: "Install",
|
|
47177
|
+
slug: "sdk-installation"
|
|
47178
|
+
},
|
|
47179
|
+
{
|
|
47180
|
+
label: "Extract",
|
|
47181
|
+
slug: "sdk-extract"
|
|
47182
|
+
},
|
|
47183
|
+
{
|
|
47184
|
+
label: "Quick Start",
|
|
47185
|
+
slug: "sdk-quickstart"
|
|
47186
|
+
}
|
|
46235
47187
|
],
|
|
46236
47188
|
faq: [
|
|
46237
|
-
{
|
|
47189
|
+
{
|
|
47190
|
+
question: "Does the Talonic SDK include a CLI?",
|
|
47191
|
+
answer: "Yes. The talonic binary ships with @talonic/node and supports extraction (talonic extract), schema listing and lookup (talonic schemas list/get), and document listing and lookup (talonic documents list/get). Install via npm install @talonic/node and run it with npx talonic, or install globally."
|
|
47192
|
+
},
|
|
47193
|
+
{
|
|
47194
|
+
question: "How do I set the API key for the CLI?",
|
|
47195
|
+
answer: "Export TALONIC_API_KEY in your shell environment; the CLI reads it automatically and exits with an error if it is missing. There is no --api-key flag, which prevents accidental key exposure in shell history. TALONIC_BASE_URL optionally overrides the API base URL."
|
|
47196
|
+
},
|
|
47197
|
+
{
|
|
47198
|
+
question: "Can I pipe CLI output to other tools?",
|
|
47199
|
+
answer: "Yes. Successful output is pretty-printed JSON on stdout, so you can pipe it into jq or any JSON-aware tool. List commands wrap results in a data array (use .data[].id in jq), and errors go to stderr as plain text, so stdout always contains clean parseable JSON."
|
|
47200
|
+
},
|
|
47201
|
+
{
|
|
47202
|
+
question: "Does the CLI retry failed requests?",
|
|
47203
|
+
answer: "Yes. The CLI builds a standard SDK client under the hood, so 429s, 5xx responses, network errors, and timeouts are retried automatically with exponential backoff and jitter before an error is reported. There is no separate retry configuration for the CLI."
|
|
47204
|
+
},
|
|
47205
|
+
{
|
|
47206
|
+
question: "Can I manage jobs, extractions, or credits from the CLI?",
|
|
47207
|
+
answer: "Not yet. The CLI currently covers extract, schemas list/get, and documents list/get. Batch jobs, extraction queries, corrections, schema creation, and credit balance checks are available through the SDK \u2014 a few lines of TypeScript with @talonic/node cover each of those flows."
|
|
47208
|
+
},
|
|
47209
|
+
{
|
|
47210
|
+
question: "What format should the --schema flag use?",
|
|
47211
|
+
answer: 'Pass a JSON string. Full JSON Schema with type "object" and a properties map is recommended, matching the SDK guidance \u2014 the flat key-type shorthand is not yet reliably normalised server-side. Quote the value in single quotes so your shell passes the JSON through unmodified.'
|
|
47212
|
+
}
|
|
46238
47213
|
],
|
|
46239
|
-
mentions: [
|
|
47214
|
+
mentions: [
|
|
47215
|
+
"CLI",
|
|
47216
|
+
"terminal",
|
|
47217
|
+
"talonic binary",
|
|
47218
|
+
"jq"
|
|
47219
|
+
]
|
|
46240
47220
|
},
|
|
46241
47221
|
{
|
|
46242
47222
|
slug: "sdk-error-classes",
|
|
46243
47223
|
parentSlug: "sdk-errors",
|
|
46244
47224
|
title: "Error Classes",
|
|
46245
|
-
seoTitle: "
|
|
46246
|
-
description: "
|
|
46247
|
-
content: [
|
|
46248
|
-
{
|
|
46249
|
-
|
|
46250
|
-
|
|
46251
|
-
|
|
46252
|
-
|
|
46253
|
-
|
|
46254
|
-
|
|
46255
|
-
|
|
46256
|
-
|
|
46257
|
-
|
|
46258
|
-
{
|
|
47225
|
+
seoTitle: "Error Classes \u2014 Talonic Node SDK Typed Error Reference",
|
|
47226
|
+
description: "Every Talonic SDK failure is a typed TalonicError subclass carrying status, code, retryable, and requestId, mapped from HTTP statuses and transport faults.",
|
|
47227
|
+
content: [
|
|
47228
|
+
{
|
|
47229
|
+
type: "paragraph",
|
|
47230
|
+
text: "Every failure is a `TalonicError` subclass with `status`, `code`, `retryable`, and `requestId` properties. The class hierarchy maps HTTP status codes to specific error types so you can handle each failure category independently."
|
|
47231
|
+
},
|
|
47232
|
+
{
|
|
47233
|
+
type: "code",
|
|
47234
|
+
language: "typescript",
|
|
47235
|
+
title: "Available error classes",
|
|
47236
|
+
code: "import {\n TalonicError, // base class \u2014 catches all SDK errors\n TalonicAuthError, // 401, 403 \u2014 invalid key or insufficient permissions\n TalonicNotFoundError, // 404 \u2014 resource does not exist\n TalonicValidationError, // 400, 409, 413, 422 \u2014 bad input, conflict, file too large\n TalonicRateLimitError, // 429 \u2014 rate limited (after retries exhausted)\n TalonicServerError, // 500, 502, 503, 504 \u2014 server error (after retries exhausted)\n TalonicNetworkError, // DNS / TCP failures \u2014 status: 0, code: 'network_error'\n TalonicTimeoutError, // request exceeded configured timeout \u2014 status: 0, code: 'timeout'\n} from '@talonic/node'"
|
|
47237
|
+
},
|
|
47238
|
+
{
|
|
47239
|
+
type: "paragraph",
|
|
47240
|
+
text: "Each error class maps to a specific failure category. **TalonicAuthError** covers authentication and permission failures (401, 403). **TalonicValidationError** covers request rejections like bad input, conflicts, oversized files, or unprocessable entities (400, 409, 413, 422). **TalonicRateLimitError** and **TalonicServerError** are only thrown after all retries are exhausted."
|
|
47241
|
+
},
|
|
47242
|
+
{
|
|
47243
|
+
type: "code",
|
|
47244
|
+
language: "typescript",
|
|
47245
|
+
title: "Error class properties",
|
|
47246
|
+
code: "// Every TalonicError subclass carries these properties:\ntry {\n await talonic.extract({ file_path: './doc.pdf', schema_id: 'sch_invalid' })\n} catch (err) {\n if (err instanceof TalonicError) {\n err.code // 'invalid_schema' \u2014 machine-readable error code\n err.status // 422 \u2014 HTTP status (0 for network/timeout)\n err.message // 'Schema sch_invalid not found' \u2014 human-readable\n err.retryable // false \u2014 was this error retried?\n err.requestId // 'req_abc123' \u2014 server trace ID (undefined for transport errors)\n err.name // 'TalonicValidationError' \u2014 class name\n }\n}"
|
|
47247
|
+
},
|
|
47248
|
+
{
|
|
47249
|
+
type: "paragraph",
|
|
47250
|
+
text: '**TalonicNetworkError** and **TalonicTimeoutError** represent transport-level failures that never reached the server. Both carry `status: 0` and are retried automatically. The `code` property is set to `"network_error"` or `"timeout"` respectively, and `retryable` is always `true`. `TalonicNetworkError` preserves the original error as `cause` for debugging DNS failures, TCP resets, and unreachable hosts. `TalonicTimeoutError` includes a `timeoutMs` property with the configured timeout value that was exceeded.'
|
|
47251
|
+
},
|
|
47252
|
+
{
|
|
47253
|
+
type: "code",
|
|
47254
|
+
language: "typescript",
|
|
47255
|
+
title: "Transport-level error details",
|
|
47256
|
+
code: "import { TalonicNetworkError, TalonicTimeoutError, TalonicRateLimitError } from '@talonic/node'\n\ntry {\n await talonic.extract({ file_path: './doc.pdf', schema_id: 'sch_abc123' })\n} catch (err) {\n if (err instanceof TalonicTimeoutError) {\n console.error(`Request timed out after ${err.timeoutMs}ms`)\n // err.status === 0, err.code === 'timeout', err.retryable === true\n }\n\n if (err instanceof TalonicNetworkError) {\n console.error(`Network failure: ${err.message}`)\n console.error(`Original error: ${err.cause}`) // underlying DNS/TCP error\n // err.status === 0, err.code === 'network_error', err.retryable === true\n }\n\n if (err instanceof TalonicRateLimitError) {\n console.error(`Rate limited. Limit: ${err.rateLimit.limit}, remaining: ${err.rateLimit.remaining}`)\n console.error(`Resets at: ${err.rateLimit.resetAt.toISOString()}`)\n // err.rateLimit provides { limit, remaining, resetAt } from response headers\n }\n}"
|
|
47257
|
+
},
|
|
47258
|
+
{
|
|
47259
|
+
type: "paragraph",
|
|
47260
|
+
text: "All error classes extend the base `TalonicError`, so a single `catch` with `instanceof TalonicError` captures every SDK failure. Use more specific subclasses when you need to branch on failure mode, such as showing a different message for auth errors versus validation errors. The `TalonicRateLimitError` is unique in carrying a `rateLimit` property with `limit`, `remaining`, and `resetAt` (Date) from the response headers, useful for scheduling manual retries after the SDK's own retries are exhausted."
|
|
47261
|
+
},
|
|
47262
|
+
{
|
|
47263
|
+
type: "paragraph",
|
|
47264
|
+
text: "The SDK also throws client-side `TalonicError` instances (not subclasses) for parameter validation failures before any network request is made. These carry `status: 0`, `retryable: false`, and codes like `missing_file_source`, `multiple_file_sources`, `multiple_schemas`, or `missing_field_reference`. They indicate programming errors in how the SDK is called rather than server-side failures."
|
|
47265
|
+
},
|
|
47266
|
+
{
|
|
47267
|
+
type: "callout",
|
|
47268
|
+
text: "Every error includes a `requestId` property (when available) that maps to the server-side request log. Include it in support tickets for fast debugging."
|
|
47269
|
+
}
|
|
46259
47270
|
],
|
|
46260
47271
|
related: [
|
|
46261
|
-
{
|
|
46262
|
-
|
|
47272
|
+
{
|
|
47273
|
+
label: "Retries & Backoff",
|
|
47274
|
+
slug: "sdk-retries"
|
|
47275
|
+
},
|
|
47276
|
+
{
|
|
47277
|
+
label: "Configuration",
|
|
47278
|
+
slug: "sdk-configuration"
|
|
47279
|
+
}
|
|
46263
47280
|
],
|
|
46264
47281
|
faq: [
|
|
46265
|
-
{
|
|
47282
|
+
{
|
|
47283
|
+
question: "What error types does the Talonic SDK throw?",
|
|
47284
|
+
answer: "The SDK throws typed subclasses of TalonicError: TalonicAuthError (401/403), TalonicNotFoundError (404), TalonicValidationError (400/409/413/422), TalonicRateLimitError (429), TalonicServerError (5xx), TalonicNetworkError, and TalonicTimeoutError. Client-side validation errors use the base TalonicError class."
|
|
47285
|
+
},
|
|
47286
|
+
{
|
|
47287
|
+
question: "What is the requestId property on errors?",
|
|
47288
|
+
answer: "It is a server-assigned identifier for the request that failed. Include it in support tickets or logs for fast debugging. It may be undefined for transport-level errors (network, timeout) that never reached the server, and for client-side validation errors."
|
|
47289
|
+
},
|
|
47290
|
+
{
|
|
47291
|
+
question: "Are TalonicNetworkError and TalonicTimeoutError retried automatically?",
|
|
47292
|
+
answer: "Yes. Both are marked retryable: true and the SDK retries them up to maxRetries times with exponential backoff. They are only thrown after all retry attempts are exhausted."
|
|
47293
|
+
},
|
|
47294
|
+
{
|
|
47295
|
+
question: "What client-side validation errors does the SDK throw?",
|
|
47296
|
+
answer: "The SDK throws TalonicError (base class) with status 0 and retryable false for parameter validation failures: missing_file_source (no file provided to extract), multiple_file_sources (more than one file source), multiple_schemas (both schema and schema_id provided), and missing_field_reference (filter condition without field or fieldId)."
|
|
47297
|
+
},
|
|
47298
|
+
{
|
|
47299
|
+
question: "How does TalonicRateLimitError differ from other error classes?",
|
|
47300
|
+
answer: "TalonicRateLimitError uniquely carries a rateLimit property with limit (max requests per window), remaining (requests left), and resetAt (Date when the window resets). This data comes from the X-RateLimit-* response headers and is useful for scheduling manual retries or implementing backpressure in your application."
|
|
47301
|
+
}
|
|
46266
47302
|
],
|
|
46267
|
-
mentions: [
|
|
47303
|
+
mentions: [
|
|
47304
|
+
"TalonicError",
|
|
47305
|
+
"error handling",
|
|
47306
|
+
"status codes"
|
|
47307
|
+
]
|
|
46268
47308
|
},
|
|
46269
47309
|
{
|
|
46270
47310
|
slug: "sdk-retries",
|
|
46271
47311
|
parentSlug: "sdk-errors",
|
|
46272
47312
|
title: "Retries",
|
|
46273
|
-
seoTitle: "
|
|
46274
|
-
description: "
|
|
47313
|
+
seoTitle: "Retries and Backoff \u2014 Talonic Node SDK Reliability Guide",
|
|
47314
|
+
description: "How the Talonic SDK retries 429s, 5xx responses, network errors, and timeouts with exponential backoff, jitter, and X-RateLimit-Reset-aware wait times.",
|
|
46275
47315
|
content: [
|
|
46276
|
-
{
|
|
46277
|
-
|
|
46278
|
-
|
|
47316
|
+
{
|
|
47317
|
+
type: "paragraph",
|
|
47318
|
+
text: "The SDK retries automatically on `429` (respecting `X-RateLimit-Reset`), `500`, `502`, `503`, `504`, network errors, and timeouts. Backoff is exponential with jitter, capped at 16s."
|
|
47319
|
+
},
|
|
47320
|
+
{
|
|
47321
|
+
type: "paragraph",
|
|
47322
|
+
text: "The API may set `retryable: false` on a specific error; the SDK respects that and does not retry."
|
|
47323
|
+
},
|
|
47324
|
+
{
|
|
47325
|
+
type: "paragraph",
|
|
47326
|
+
text: "The backoff schedule starts at 1 second for the first retry, doubling on each subsequent attempt (1s, 2s, 4s, ...) up to a maximum of 16 seconds. A random jitter of up to 250ms is added to each wait to prevent thundering-herd problems when multiple clients retry simultaneously. The formula is `min(1000 * 2^attempt, 16000) + random(0, 250)` milliseconds."
|
|
47327
|
+
},
|
|
47328
|
+
{
|
|
47329
|
+
type: "code",
|
|
47330
|
+
language: "typescript",
|
|
47331
|
+
title: "Retry behavior in practice",
|
|
47332
|
+
code: "import { Talonic, TalonicServerError, TalonicRateLimitError } from '@talonic/node'\n\n// Default: 3 retries with exponential backoff\n// Attempt 0: immediate request\n// Attempt 1: wait ~1.0-1.25s, then retry\n// Attempt 2: wait ~2.0-2.25s, then retry\n// Attempt 3: wait ~4.0-4.25s, then retry\n// If all fail, throws the last error\n\nconst talonic = new Talonic({\n apiKey: process.env.TALONIC_API_KEY!,\n maxRetries: 3, // default\n})\n\ntry {\n await talonic.extract({ file_path: './doc.pdf', schema_id: 'sch_abc123' })\n} catch (err) {\n if (err instanceof TalonicServerError) {\n // Thrown only after all 3 retries exhausted\n console.error(`Server error after retries: ${err.code} (request ${err.requestId})`)\n }\n if (err instanceof TalonicRateLimitError) {\n // Thrown after retries exhausted; check when the rate limit resets\n console.error(`Rate limited. Resets at: ${err.rateLimit.resetAt}`)\n }\n}"
|
|
47333
|
+
},
|
|
47334
|
+
{
|
|
47335
|
+
type: "paragraph",
|
|
47336
|
+
text: "For `429` rate-limit responses specifically, the SDK reads the `X-RateLimit-Reset` header and waits until the reset timestamp (plus a 100ms buffer) rather than using exponential backoff. If the reset window exceeds 60 seconds, the SDK falls back to standard backoff instead of blocking indefinitely. This means rate-limit retries are usually faster than exponential backoff because the SDK waits exactly the right amount of time rather than guessing."
|
|
47337
|
+
},
|
|
47338
|
+
{
|
|
47339
|
+
type: "code",
|
|
47340
|
+
language: "typescript",
|
|
47341
|
+
title: "Disable retries for development",
|
|
47342
|
+
code: "// In development, disable retries for immediate feedback\nconst talonic = new Talonic({\n apiKey: process.env.TALONIC_API_KEY!,\n maxRetries: 0, // no retries \u2014 throw on first failure\n})\n\n// Errors are thrown immediately without any wait\ntry {\n await talonic.documents.list()\n} catch (err) {\n // err.retryable tells you if this WOULD have been retried\n if (err instanceof TalonicError && err.retryable) {\n console.log('This error would be retried in production (maxRetries > 0)')\n }\n}"
|
|
47343
|
+
},
|
|
47344
|
+
{
|
|
47345
|
+
type: "paragraph",
|
|
47346
|
+
text: "Non-retryable errors are never retried regardless of `maxRetries`. Authentication errors (401, 403), validation errors (400, 409, 413, 422), and not-found errors (404) are thrown immediately on the first attempt. The API can also mark specific errors as non-retryable by setting `retryable: false` in the error response body, which the SDK respects even for status codes that would normally be retried."
|
|
47347
|
+
},
|
|
47348
|
+
{
|
|
47349
|
+
type: "code",
|
|
47350
|
+
language: "typescript",
|
|
47351
|
+
title: "Custom retry logic on top of SDK retries",
|
|
47352
|
+
code: "import { Talonic, TalonicRateLimitError, TalonicError } from '@talonic/node'\n\n// For critical pipelines, add your own retry layer on top\nasync function extractWithFallback(talonic: Talonic, params: Parameters<Talonic['extract']>[0]) {\n try {\n return await talonic.extract(params)\n } catch (err) {\n if (err instanceof TalonicRateLimitError) {\n // SDK retries are exhausted \u2014 wait for the rate limit reset and try once more\n const waitMs = err.rateLimit.resetAt.getTime() - Date.now()\n if (waitMs > 0 && waitMs < 120_000) {\n console.log(`Rate limited. Waiting ${Math.ceil(waitMs / 1000)}s for reset...`)\n await new Promise(r => setTimeout(r, waitMs + 100))\n return await talonic.extract(params)\n }\n }\n throw err\n }\n}"
|
|
47353
|
+
},
|
|
47354
|
+
{
|
|
47355
|
+
type: "paragraph",
|
|
47356
|
+
text: "The transport layer handles `TalonicTimeoutError` and `TalonicNetworkError` as retryable by default. Timeout errors are raised when a request exceeds the configured `timeout` milliseconds (default 60s). Network errors cover DNS failures, TCP resets, and unreachable hosts. Both carry `status: 0` because no HTTP response was received. After all retries are exhausted, the last error is thrown with `retryable: true` still set, so your application code can decide whether to queue the request for later processing."
|
|
47357
|
+
},
|
|
47358
|
+
{
|
|
47359
|
+
type: "callout",
|
|
47360
|
+
text: "Rate limit retries respect the `X-RateLimit-Reset` header from the API, so the SDK waits the exact right amount of time before retrying a 429."
|
|
47361
|
+
}
|
|
46279
47362
|
],
|
|
46280
47363
|
related: [
|
|
46281
|
-
{
|
|
46282
|
-
|
|
46283
|
-
|
|
47364
|
+
{
|
|
47365
|
+
label: "Configuration",
|
|
47366
|
+
slug: "sdk-configuration"
|
|
47367
|
+
},
|
|
47368
|
+
{
|
|
47369
|
+
label: "Error Classes",
|
|
47370
|
+
slug: "sdk-error-classes"
|
|
47371
|
+
}
|
|
46284
47372
|
],
|
|
46285
47373
|
faq: [
|
|
46286
|
-
{
|
|
47374
|
+
{
|
|
47375
|
+
question: "Does the Talonic SDK retry failed requests?",
|
|
47376
|
+
answer: "Yes. It retries on 429, 500, 502, 503, 504, network errors, and timeouts with exponential backoff and jitter, up to maxRetries attempts (default 3). Non-retryable errors like 401, 403, 400, and 404 are thrown immediately."
|
|
47377
|
+
},
|
|
47378
|
+
{
|
|
47379
|
+
question: "What is the maximum backoff time between retries?",
|
|
47380
|
+
answer: "The exponential backoff caps at 16 seconds. For 429 rate-limit errors, the SDK instead waits until the server-provided reset timestamp (plus 100ms buffer), up to a maximum of 60 seconds. If the reset window exceeds 60 seconds, standard backoff is used instead."
|
|
47381
|
+
},
|
|
47382
|
+
{
|
|
47383
|
+
question: "Can the API override the SDK's retry behavior?",
|
|
47384
|
+
answer: "Yes. If the API returns retryable: false on an error response, the SDK will not retry that request regardless of the status code or maxRetries setting."
|
|
47385
|
+
},
|
|
47386
|
+
{
|
|
47387
|
+
question: "What is the exact backoff formula?",
|
|
47388
|
+
answer: "The wait time is min(1000 * 2^attempt, 16000) + random(0, 250) milliseconds. So: ~1s for the first retry, ~2s for the second, ~4s for the third, capping at ~16s. The random jitter of up to 250ms prevents thundering-herd problems when multiple clients retry simultaneously."
|
|
47389
|
+
},
|
|
47390
|
+
{
|
|
47391
|
+
question: "Are timeout and network errors retried?",
|
|
47392
|
+
answer: "Yes. Both TalonicTimeoutError and TalonicNetworkError are marked retryable: true and are retried up to maxRetries times. They carry status: 0 because no HTTP response was received. They are only thrown to your code after all retry attempts are exhausted."
|
|
47393
|
+
}
|
|
46287
47394
|
],
|
|
46288
|
-
mentions: [
|
|
47395
|
+
mentions: [
|
|
47396
|
+
"retry",
|
|
47397
|
+
"backoff",
|
|
47398
|
+
"rate limit",
|
|
47399
|
+
"429"
|
|
47400
|
+
]
|
|
46289
47401
|
}
|
|
46290
47402
|
];
|
|
46291
47403
|
|