Skip to main content

Trigger Package Run

Trigger a matching package run via API: score extracted rows keyed by document type against a package config and get the aggregated verdict synchronously.

Trigger a package run. You supply the extracted rows grouped by document type and the package config to score them against. The engine feeds each document type's rows through that type's matching config, then aggregates the per-type results into a single package verdict. Execution is inline and synchronous, so the returned run is already terminal.

The input_documents field is a map keyed by document type. Each value is an array of input rows for that type, and each row carries the document_id it came from, the extraction_row_id, and the values to score against reference data. The keys must line up with the document_types in the referenced package config.

The run status aggregates the document-type results. passed means the package satisfied its pass criteria. failed means a hard miss: a required type absent, unmatched, or below the min_confidence floor, or a supplied expected type that did not match. review means the package needs a human look without failing — an expected type was missing from the input, or a review-grade match occurred where the criteria allow it. error means execution itself failed; the run row is still persisted with its error message. Each entry in document_results reports its own status, confidence, and whether the document was found.

Two per-type details matter when reading document_results. The entry's status reflects the best row of that type (with several invoices, one good match carries the slot), while confidence is the average best-candidate confidence across the type's rows, rounded to three decimals — so a slot can read "matched" with a modest confidence when weaker siblings drag the average down. And matching_run_id is always null: package execution scores the rows inline rather than minting standalone /v1/matching runs, so the per-type audit trail lives entirely in this run's document_results.

A package run is synchronous. There is no job to poll: the run returned by this endpoint already carries its final status and document_results.
POST/v1/matching/packages/runs

Body parameters

package_config_id*stringUUID of the package config to run. Must belong to your organization.
input_documents*objectExtracted rows keyed by document_type. Each value is an array of input rows.
input_documents[type][].document_id*stringUUID of the source document.
input_documents[type][].extraction_row_id*stringThe extraction row id for this document.
input_documents[type][].values*objectExtracted field values to score against reference data.

Response

Response fields

idstringPackage run UUID.
package_config_idstringUUID of the config this run scored against.
statusstringAggregated verdict: passed, failed, review, error (running while in flight).
document_resultsarrayOne result per document-type slot.
document_results[].document_typestringThe document type scored.
document_results[].matching_config_idstringThe matching config used.
document_results[].matching_run_idnullAlways null: package execution scores rows inline and mints no standalone /v1/matching run. The field is reserved.
document_results[].presencestringrequired, expected, or optional.
document_results[].document_foundbooleanWhether a document of this type was supplied.
document_results[].statusstringmatched, review, no_match, or skipped (skipped = optional type with no document). Reflects the best row of the type.
document_results[].confidencenumber | nullAverage best-candidate confidence across the type's rows (0–1, 3 decimals), or null when no document was supplied.
document_results[].errorstringPresent when the slot could not be scored, e.g. "Matching config not found".
input_documentsobjectThe document ids supplied per type.
errorstring | nullError detail when status is error, otherwise null.
created_atstringISO 8601 creation timestamp.
completed_atstring | nullISO 8601 completion timestamp.
linksobjectRelated resource URLs (self, config).

curl

curl -X POST https://api.talonic.com/v1/matching/packages/runs \
  -H "Authorization: Bearer tlnc_your_api_key" \
  -H "Content-Type: application/json" \
  -d @package-run.json

Request body (package-run.json)

{
  "package_config_id": "4f2a9c1e-8b3d-47e6-9a05-c7d1e2f3a4b5",
  "input_documents": {
    "invoice": [
      {
        "document_id": "b8b00d51-eecc-49b3-affc-89fee95b9518",
        "extraction_row_id": "row_1",
        "values": { "booking_reference": "ABC1234567", "total": 4250.0 }
      }
    ],
    "delivery_note": [
      {
        "document_id": "c9a11e62-fdd0-4a21-b00d-9a0e81f6c2d3",
        "extraction_row_id": "row_1",
        "values": { "booking_reference": "ABC1234567", "carrier": "Acme Freight" }
      }
    ]
  }
}

Response

{
  "id": "8d7e6f50-4c3b-42a1-b0e9-d8c7b6a59483",
  "package_config_id": "4f2a9c1e-8b3d-47e6-9a05-c7d1e2f3a4b5",
  "status": "passed",
  "document_results": [
    {
      "document_type": "invoice",
      "matching_config_id": "1a2b3c4d-5e6f-4781-92a3-b4c5d6e7f809",
      "matching_run_id": null,
      "presence": "required",
      "document_found": true,
      "status": "matched",
      "confidence": 0.934
    },
    {
      "document_type": "delivery_note",
      "matching_config_id": "2b3c4d5e-6f70-4192-a3b4-c5d6e7f8091a",
      "matching_run_id": null,
      "presence": "expected",
      "document_found": true,
      "status": "matched",
      "confidence": 0.881
    }
  ],
  "input_documents": {
    "invoice": ["b8b00d51-eecc-49b3-affc-89fee95b9518"],
    "delivery_note": ["c9a11e62-fdd0-4a21-b00d-9a0e81f6c2d3"]
  },
  "error": null,
  "created_at": "2024-09-14T10:40:00.000Z",
  "completed_at": "2024-09-14T10:40:03.000Z",
  "links": {
    "self": "/v1/matching/packages/runs/8d7e6f50-4c3b-42a1-b0e9-d8c7b6a59483",
    "config": "/v1/matching/packages/configs/4f2a9c1e-8b3d-47e6-9a05-c7d1e2f3a4b5"
  }
}

Read the package verdict from status, then drill into document_results to see which type drove it. A no_match on a required type fails the package, a review on an expected type routes to review when the config allows it, and a skipped entry means no document of that type was supplied for an optional slot. A slot whose per-type matching config no longer exists reports no_match with error: "Matching config not found" instead of failing the whole call, so a stale slot degrades that type rather than erroring the run.

Errors

Error responses

400bad_requestInvalid body: missing package_config_id, malformed input_documents, or an input row failing structural validation.
401unauthorizedMissing or invalid API key.
404not_foundNo package config with this ID exists for your organization.
429rate_limitedToo many requests. Retry after the period indicated in the Retry-After header.

Frequently asked questions

Is a package run synchronous?+
Yes. Execution is inline, so the returned run already carries its final status and document_results. There is nothing to poll.
How are the input_documents keys matched to the config?+
The keys are document types and must line up with the document_type values in the referenced package config. Rows under a key are scored by that type's matching config.
What does a review status mean?+
The package needs a human look without failing outright. Two paths lead there: an expected document type was missing from the input entirely, or a supplied document matched at review grade where the criteria tolerate it (allow_review_on_expected for expected types). Check each document_results entry's status to see which type flagged it.
How do I read a run again later?+
Through the list endpoint: GET /v1/matching/packages/runs?package_config_id=<id> (optionally with a status filter) returns the same full run shape. Since execution is synchronous, most integrations act on the trigger response directly and use the list only for history and audit.