Skip to main content

Cleaning and Key Rules

Work the cleaning list of contracts that look wrong, dismiss reviewed issues, merge contracts, reconcile renumbered ones and teach key rules.

Documents arrive under the keys the document store gives them, and a contract is sometimes split: a renumbered contract lives under two keys, a letter carries no number at all, one number covers several sites. The cleaning routes show where the documents disagree and give a person the tools to resolve it. Each route acts on contract keys, and the keys a person sets are hand-set, so they are kept when documents are read again.

The Cleaning Worklist

GET /v1/contracts/issues returns, per contract, the issues the documents show, each naming the documents it is about. Contracts with the most issues come first, and only contracts with at least one open issue appear. The issue codes are several_base_contracts, printed_number_differs, several_counterparties, several_sites, ended_by_message, unread_documents, no_dates, unverified_terms, no_own_party and direction_conflict.

GET/v1/contracts/issues

Response: Contracts with open issues

{
  "data": [
    {
      "contract_id": "6f1c2a9e-1d4b-4a7e-9c33-2b8a5e0d7f11",
      "contract_key": "1043020-WLV",
      "title": "Waermelieferungsvertrag",
      "status": "active",
      "issues": [
        {
          "code": "ended_by_message",
          "detail": "an email or message is read as the termination; confirm it or leave it out",
          "document_ids": ["5e91a7d3-4c20-4b8f-9d16-3a7c0e2b8f54"]
        }
      ]
    }
  ]
}

POST /v1/contracts/{id}/issues/{code}/dismiss records that a reviewed issue is right as it stands, for example a genuine termination e-mail or a customer number printed on the contract. The note (3 to 2000 characters) says why. The dismissal is keyed on the contract, the code and the documents concerned, so an issue stays hidden until the documents concerned change: a further document that raises the same code flags it again. A code for which the contract has no open issue returns 404.

POST/v1/contracts/{id}/issues/{code}/dismiss

Body fields

note*string3 to 2000 characters. Why the issue is right as it stands.

Merge and Reconcile

POST /v1/contracts/{id}/merge re-keys every document of the contract to into_key, which is created when no contract has it yet, and deletes the emptied contract. The merge is recorded as a key rule, so later documents filed under the old key go to the target key, and an open decision on the old contract carries over to the target when the target has none. The response is 201 with moved (the number of documents) and the resulting contract.

POST/v1/contracts/{id}/merge

Body fields

into_key*string1 to 64 characters. The key to merge into.
notestringUp to 2000 characters.

POST /v1/contracts/reconcile does the merging automatically where the evidence is clear. It merges a renumbered contract into the key it continues under when that contract exists, and it attaches a document that has no contract number anywhere (and is not a base contract) to the one contract whose base contract names the same counterparty, and the same site when the document names one. Documents a person filed by hand never move. With dry_run: true it reports the planned merge and attach moves and makes none.

POST/v1/contracts/reconcile

Body fields (optional)

dry_runbooleanReport the merges and attachments without making them.

Response fields

dry_runbooleanEchoes the request.
merged, attachedintegerThe number of contract merges and document attachments.
merge[]arraycontract_id, from_key and into_key per merge.
attach[]arrayrow_id, document_id, from_key, into_key and why per attachment.

cURL: Preview the reconcile

curl -X POST "https://api.talonic.com/v1/contracts/reconcile" \
  -H "Authorization: Bearer $TALONIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dry_run": true}'

Key Rules

A key rule files the documents of one contract key (optionally only at one site) under another key. GET /v1/contracts/key-rules lists the rules, ordered by from_key and then site; withdrawn rules are listed with active: false. POST /v1/contracts/key-rules adds a rule or replaces and re-activates the rule for the same from_key and site. DELETE /v1/contracts/key-rules/{ruleId} sets a rule inactive. In every case, documents already filed stay where they are until they are re-read or re-keyed.

GET/v1/contracts/key-rules
POST/v1/contracts/key-rules

Body fields

from_key*string1 to 64 characters. The key the document store files the documents under.
to_key*string1 to 120 characters. The key they go to.
sitestringUp to 200 characters. Only documents at this site; all documents of from_key when omitted.
notestringUp to 2000 characters.
DELETE/v1/contracts/key-rules/{ruleId}

cURL: Teach a key rule for one site

curl -X POST "https://api.talonic.com/v1/contracts/key-rules" \
  -H "Authorization: Bearer $TALONIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from_key": "4243", "to_key": "1042430", "site": "Musterstadt Nord", "note": "Renumbered in 2024"}'
A merge and a key rule change which contract a document belongs to, so run POST /v1/contracts/reconcile with dry_run first when the change touches many contracts, and use the issues list afterwards to confirm that the issues you meant to resolve are gone.

Frequently asked questions

When does a dismissed issue come back?+
When the documents concerned change. A dismissal is keyed on the contract, the issue code and the documents concerned, so a further document raising the same code flags the issue again, while the same documents keep it hidden.
What happens to documents already filed when I add a key rule?+
They stay where they are. A rule applies to documents filed later; documents already filed move only when they are re-read or re-keyed. A merge moves the documents of the contract immediately.
Which documents does reconcile never move?+
Documents a person filed by hand. Reconcile merges a renumbered contract into the key it continues under and attaches unnumbered documents that are not base contracts to the contract whose base contract names the same counterparty and site.
Can I undo a merge?+
A merge is recorded as a key rule, which can be withdrawn with DELETE /v1/contracts/key-rules/{ruleId}, but the documents that were moved stay under the target key. Re-key them individually with PUT /v1/contracts/{id}/documents/{rowId}.