Collections
What a Collection does
A Collection groups several flows (and, optionally, Splitters) behind one entry point. When a document arrives, Tavnit looks at its first page, compares what it sees against the names and descriptions of the destinations in the Collection, and forwards the document to the one that matches, so you can hand out a single address for documents you cannot sort in advance.
The routing decision is made from the document itself: headers, titles, logos, layout, and identifying text such as company names and form numbers. It is a classification step, not an extraction step. Once a destination is chosen, the document is processed by that flow exactly as if you had sent it there directly.
Collection or direct flow?
Send documents straight to a flow when you already know what they are. Use a Collection when the sender is one channel but the contents vary, and deciding which flow applies would otherwise be somebody's manual job.
| Situation | Send to |
|---|---|
| One supplier, one document type, always the same layout | The flow directly |
| A vendor portal that emits invoices, POs and receipts | A Collection |
| A shared inbox where anything might arrive | A Collection |
| An API caller that already knows the document type | The flow directly |
| A PDF that bundles several documents together | A Splitter, or a Collection containing one |
Where the caller knows the type, tell the flow.
Create a Collection
A Collection is a name, a list of destinations, and a default behavior. The work is in the destinations: routing quality depends almost entirely on how well each flow describes what it handles.
- 1Open Collections and click Create Collection. Name it after where the documents come from (Acme supplier portal, not Collection 2) and optionally add a description.
- 2Under Flows, tick every active flow that should be a possible destination. At least one is needed.
- 3Under Splitters, optionally tick any Splitter that should receive files bundling several documents.
- 4Under Default Behavior, choose what happens when the AI can't determine the right flow: Cancel the run, or Send to a default flow picked from the Collection's flows.
- 5Optionally turn on the Email Trigger. The inbox address is generated once the Collection is created.
- 6Send documents in (with Run, by email or through the API), then check Recent Runs and sharpen any description that produced a wrong decision.
Everything can be changed later from the Collection's detail page, where the left rail holds Flows, Splitters, Recent Runs, Email Trigger, Fallback Flow (the Default Behavior setting) and Collection ID. The switch in the top bar makes the Collection active or inactive; inactive Collections reject new runs. Admins and Owners can create Collections; the creator, Admins and Owners can edit and delete them.
Writing flow names and descriptions that route well
The name and description of each destination are the only things the router compares the document against. A flow called Flow 3 with no description cannot be routed to reliably, no matter how distinctive the document is.
| Instead of | Write |
|---|---|
| Invoices | Acme Corp supplier invoices — blue letterhead, “TAX INVOICE” in the header, line items with part numbers |
| Shipping | Bill of lading from ocean carriers — container numbers, port of loading and discharge |
| Other docs | Delivery notes — no prices, signature block at the bottom |
- Describe what is visible on page one, since that is what the router sees. For a spreadsheet, that is the top of its first visible sheet.
- Name the issuer when several flows handle the same document type for different suppliers.
- Say what a document type is not, when two of your flows are easily confused.
- Avoid two flows whose descriptions overlap: the router is instructed to abstain when the match is ambiguous rather than guess.
What happens to each document
Every document creates a Collection run that moves through a small set of states. Routing is decided once, from the first page, and the decision is recorded with a written reason.
| Status | Meaning |
|---|---|
| Queued | The document is stored and waiting to be routed. |
| Routing | The first page is being classified. |
| Routed | A destination was chosen. The Collection run links to the flow run (or the Splitter's split) it created. |
| Cancelled | No destination matched and the Default Behavior is Cancel the run, so nothing was processed. You can also cancel a run yourself while it is still routing. |
| Failed | The document could not be routed at all: an unsupported or unreadable file, or a Collection with no active destinations. |

When the router cannot find a clear match it does not guess: it abstains. With Send to a default flow, the document goes to that flow (marked Default in the Collection's flow list) and the reason records that it fell back. With Cancel the run, the run ends as Cancelled with the reason “No clear match and no default flow configured”, and the document is not processed. Pick a default flow unless you genuinely want unknown documents dropped.
Routing does not produce a confidence score. Each decision is recorded as a written reason citing what the router saw on the page.
Routing to a Splitter
A Collection's destinations are not limited to flows. You can add a Splitter as a destination, so a file that bundles several documents is split apart first and each part is routed onward, rather than being extracted as though it were one document.
- Splitter destinations are described to the router as splitters, so it only picks one when the file clearly bundles multiple documents.
- A single document is always sent to a flow, never to a splitter.
- Each part produced by the splitter continues through the pipeline on its own.
A Splitter can feed a Collection and a Collection can feed a Splitter, which could form a cycle. A Splitter that already sends documents to this Collection appears greyed out in the Splitters list and cannot be added, and at run time a segment produced by a Splitter is never routed back into that same Splitter, so a mis-set configuration cannot spin documents in a circle.
Sending documents to a Collection
A Collection accepts documents three ways: upload in the app, its own email address, or the API. The routing behaviour is identical whichever you use, and each run records which source it came from.
| File type | How it is routed |
|---|---|
| From an image of the first page. | |
| PNG, JPG, JPEG | From the image itself. |
| XLSX, XLS, CSV | From the first visible sheet, rendered as a page. A flow then extracts from that sheet; a Splitter handles one document per visible sheet. |
Upload in the app. Click Run in the Collection's top bar (it is disabled while the Collection is inactive). The New Collection Run dialog accepts several files at once, and each file becomes its own Collection run.
Email. Open Email Trigger, turn it on and copy the Inbox Address. Each attachment becomes its own Collection run. Two optional settings sit under the address:
- Allowed Senders: only these addresses can trigger a run. Leave it empty to accept email from any sender.
- Process Email Body: route the message itself, not only its attachments. Choose Only when nothing is attached (a cover note next to an attached document is skipped, so one email never starts two runs) or Always (the body is processed alongside every attachment, each in its own run). The body is converted to a PDF first, so it appears in review like any other document; images in the message are not read.
The address is distinct from any flow address. See email integration for the address shapes and what happens to attachments that cannot be processed.
Collections over the API
Copy the ID from the Collection ID panel and send documents with your API key. The call returns as soon as the file is stored, before routing.
| Endpoint | What it does |
|---|---|
POST /api/collections/<collection_id>/process | Submits one document (multipart file, or file_base64 with filename). Returns HTTP 202 with a collection_run_id. An inactive Collection or one with no active destinations is rejected. |
GET /api/collection-runs/<collection_run_id>/source-file | Retrieves the document you submitted, available immediately: no need to wait for routing or to know which flow or Splitter it went to. Returns JSON with a short-lived signed url, or the file itself with ?download=true. |
See the API page for authentication, full request and response shapes, and how to follow the resulting flow run.
Reviewing routing decisions
Recent Runs is where you check and tune routing. It updates live, can be filtered by status, and lists each document with its time, source, the sender for email runs, and the flow or Splitter it was sent to.
- Click a routed run to open the flow run (or the split) it created, with its extracted data.
- Click a run that did not reach a destination to open the Collection Run dialog: status, document, source, the written routing reason and any error message. A run that is still pending or routing can be cancelled from there with Cancel Run.
- A run that fell back to the default flow shows that flow as its destination; its reason starts with “No clear match. Using default flow.”
When routing goes wrong the fix is nearly always in the destination descriptions, not in the document. Two flows that both say “invoices” will keep producing ambiguous decisions until one of them says what makes it different.
Troubleshooting
| Problem | What to check |
|---|---|
| Documents end up Cancelled | The router found no clear match and the Default Behavior is Cancel the run. Sharpen the flow descriptions, or choose Send to a default flow. |
| Too many documents go to the default flow | Two or more destinations describe the same thing, or none describes what is on page one. Open a few of these runs and compare with the descriptions. |
| Run is disabled | The Collection is inactive. Turn it back on with the switch in the top bar. |
| An emailed document never shows up | Check that the Email Trigger is on, that the sender is in Allowed Senders (if the list is not empty), and that the file type is supported. |
| A Splitter cannot be added | It already sends documents to this Collection; adding it would create a loop. |
