Skip to main content

Collection Rules & Documents

Fill a collection automatically with rules for a source, a document type or a case, and add or remove documents by hand, from code, with the same rules as the app.

Rules keep a collection up to date without anyone sorting documents. A rule names a source (source_connection), a document type (document_type) or a case (case), and every document of it belongs to the collection, including documents that arrive later. rule_value is the id of that source, document type or case; Talonic checks that it exists in your workspace.

For documents no rule covers, add them by hand with POST /v1/collections/{id}/documents. Every id must be a document the key's person can see. For an account, a document that already belongs to another account is refused with 409, since a document has at most one account. DELETE /v1/collections/{id}/documents/{documentId} takes a hand-added document out; if a rule still covers it, the answer says so with still_matched_by_rule: true and the document stays in the collection through that rule.

The lists need the read scope (or documents:read), and any member may call them; the document list shows only documents the key's person can see. Adding and removing rules and documents need documents:write, and the key's person must be an Admin of the workspace, as in the web app; anyone else gets 403 insufficient_role.

GET/v1/collections/{id}/rules
POST/v1/collections/{id}/rules

Body parameters

rule_type*stringsource_connection, document_type or case.
rule_value*stringThe id of the source, document type or case, up to 200 characters.

Add every document of a source

curl -X POST https://api.talonic.com/v1/collections/$COLLECTION_ID/rules \
  -H "Authorization: Bearer $TALONIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rule_type": "source_connection", "rule_value": "5a4b3c2d-1e0f-4a9b-8c7d-6e5f4a3b2c1d"}'
DELETE/v1/collections/{id}/rules/{ruleId}
GET/v1/collections/{id}/documents
POST/v1/collections/{id}/documents
DELETE/v1/collections/{id}/documents/{documentId}

Frequently asked questions

Do rules include documents that arrive later?+
Yes. A rule describes which documents belong, so a new document of that source, type or case is in the collection as soon as it arrives.
I removed a document but it is still in the collection. Why?+
A rule still includes it. The answer carries still_matched_by_rule: true. Remove or narrow the rule if the document should leave the collection.
Why does adding a document to an account answer 409?+
The document already belongs to another account, and a document has at most one account. Take it out of the other account first.