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.
/v1/collections/{id}/rules/v1/collections/{id}/rulesBody parameters
source_connection, document_type or case.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"}'/v1/collections/{id}/rules/{ruleId}/v1/collections/{id}/documents/v1/collections/{id}/documents/v1/collections/{id}/documents/{documentId}