import_contract_from_folder
Read ONE contract bundle and register it — rental contracts AND every other kind (service, maintenance, lease = leasing, insurance, supply/energy, license/software, loan, purchase, cooperation, employment, nda, other): the AI first decides the type (contract_type), rentals get the rental fields (landlord/tenant, property, rent), all others the general fields (client/contractor, subject, fee + period, notice); every party is listed separately with role and structured address, plus contact persons (property management, 'represented by'). OUR ROLE is computed from the parties against the tenant's own-company list (set_contract_scan_rules.own_companies; our_names adds to it). PARTIES (link_parties, default true): each counterparty is matched to an existing organisation (company) or person (contact) by normalised name, PLZ/city on ties, or created (note 'Angelegt beim Vertragsimport'); our own company becomes our_account_id; the main counterparty is written to account_id/contact_id ONLY if the contract has none yet (manual links stay); all parties with role go to the contract's party list. RE-EXTRACT: importing the same bundle again (same main-contract path) UPDATES the contract — use it to re-read contracts imported before 31.10.2026 with the old rental-only schema; manual account/contact links and custom fields you set stay. ASYNC (Ticket 8138bb37): this STARTS the run and returns IMMEDIATELY with { operation_id, state: "running" } — it does NOT wait for the ~1-minute extraction, so it never hits the request timeout. Poll get_contract_import({operation_id}) for per-file progress and, when done, the result (created/updated contract_id, or a per-file failure reason). The files (contract + amendments + annexes; digital PDFs, scans, Word, images) are read by the AI (default gpt-6-luna) and the key facts extracted — parties, property, term, notice periods, rent, deposit, index/stepped rent, special clauses — each with its source file, page and confidence, amendments applied in order (today's state). Writes the contract register (agreement with facts, deadlines, attached documents); a second run on the same bundle updates instead of duplicating. SIZE (Ticket 5317508f): files with role 'version' (other drafts) are only LINKED, not sent to the AI; digital PDFs go as text, big scans as a page excerpt; the total file input per AI call stays under 45 MB — what does not fit (lowest priority first) is left out and listed in zu_pruefen instead of failing. A stalled run (worker lost, no heartbeat for 5 min) is resumed by the next get_contract_import or scan_contract_folder from the last prepared file (max 3 resumes). reference = path of the main contract; area from set_contract_scan_rules.area_rules/default_area into custom field 'blatt'; a daily cap (max_imports_per_day) is enforced. STORAGE MODE (Ticket T3): modus 'referenz' (DEFAULT) stores only a LINK to the original file on the bridge (bridge://… + source_meta) and copies NO bytes into the document store — so an on-prem folder on \server\share makes no GB-scale duplicates; filename/size/MIME are kept as metadata and the file is fetched on demand via resolve_contract_file before viewing/analysis. modus 'kopie' copies the bytes into CallPilotAI (needed for a purely-cloud tenant with no persistent bridge, since a link only resolves while the bridge is online); 'verknuepfen' true/false is an alias (true=referenz). Required: scan_id + bundle_key (from scan_contract_folder) OR bridge + folder + files [{path, role}]. Optional: our_names (how we appear in contracts, e.g. ["Muster GmbH"] — decides landlord/tenant; default: the tenant name), model, modus ('referenz'|'kopie', default 'referenz'), verknuepfen (bool alias).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "import_contract_from_folder"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | No | Files of the bundle with their role, instead of scan_id + bundle_key | |
| model | No | AI model for the extraction (default gpt-6-luna) | |
| modus | No | referenz = store only a link to the file (default), kopie = copy the bytes | |
| bridge | No | Bridge slug, when passing files directly instead of scan_id | |
| folder | No | Allowed folder of the bridge the files are in | |
| scan_id | No | ID of the scan | |
| our_names | No | How we appear in contracts; added to the own-company list | |
| bundle_key | No | Key of the bundle from scan_contract_folder (with scan_id) | |
| verknuepfen | No | Alias for modus: true = referenz, false = kopie | |
| link_parties | No | Match or create organisations/persons for the parties (default true) |