Imports
Automatic document imports from integrations.
Raw Markdown for agents: imports.md. MCP: read_docs("imports").
Import sources keep a Space folder in sync with an external location (a OneDrive or SharePoint folder, a Google Drive folder, a mailbox) without an agent: the platform lists the location, imports new files as documents, keeps a backlog of what is still pending and records every decision.
Use imports.sources.create when the user wants documents to arrive automatically
and repeatedly. Use a single provider import operation (for example
integrations.gdrive.files.import) when the user wants one file now.
Before creating a source:
- Find the connection with
integrations.connections.list. Only its owner creates, changes and runs a source on it. A personal connection also serves an organization Space: create the source in that organization with a grant of that organization; the source belongs to the Space's organization, which pays plan feature and credits. A Space of another workspace fails withpermission_denied, a grant of another workspace withimport_grant_invalid. The provider must listsourcesinintegrations.catalog.get; each source names itsscope_fields,scanandoption_fields. - Browse the location with the provider's list operation (
drives.list,files.list) to find the scope ids the source needs (scope_fields). Pass the human names of the chosen ids asscope_labelsso the source can show them. - Check that the Space grant (
integrations.grants.list) allows both the list and the import operation of that source (import_grant_missing_operationsotherwise); recursive or folder-mirroring sources need a grant without a fixed folder constraint. imports.sources.previewsamples the start point with the intended policy and reports how many files would be imported or skipped; show that to the user before creating.- Pick the target folder with
documents.folders_list(omittarget_folder_idfor the Space root), optionally a schedule (ruleorcron, at most every 15 minutes, check it withworkflows.schedule.preview; omit it for a source that only runs on demand) and apolicy.
Policy
| Field | Default | Effect |
|---|---|---|
recurse, max_depth | true, 3 (1 to 10) | Walk subfolders down to that depth. |
mirror_folders | true | Recreate the source's folders under the target; only for sources that walk folders. |
include_mime_patterns, exclude_mime_patterns | [] | Glob patterns on the MIME type (application/pdf, image/*), up to 20 each. With includes, only matching files are imported. |
exclude_name_patterns | [] | Glob patterns on the file name (*.tmp), up to 20. |
max_item_bytes | none | Skip larger files; at most 10,000,000. |
on_change | skip | A changed file: skip keeps the first import, replace updates the document in place, import_as_new adds a numbered copy. |
unpack_archives | false | Import ZIP files, then unpack their entries next to the archive under the same policy; MIME filters never skip the archive itself. The archive is deleted once every entry was imported or skipped. |
options | {} | Booleans named in the source's option_fields; omitted ones are false, other names fail with import_scope_invalid. |
Filters act on file name, MIME type and size only; there is no filter by sender, subject or folder name.
Mail sources (attachments of imap, gmail and microsoft365) list mail by
received time from start_after (a date, required, not in the future; scanning starts
at 00:00 UTC that day) and declare two options:
include_inline: also import inline attachments (for example images in a signature).include_message: also import each mail itself as a Markdown document (headers and text body), for example{"policy": {"options": {"include_message": true}}}.
imports.sources.update with changed options or an earlier start_after scans the
mailbox again from start_after; a later start_after keeps what was scanned.
Runs
A run scans the location and then drains the whole backlog under the provider's rate
limit; imports.runs.start runs a source now, imports.sources.get shows the backlog
(items, progress, scan.complete) and the active run with its wait_reason.
imports.items.list shows what was imported, skipped or failed; imports.items.retry_many
queues failed or policy-skipped items again (by id or for the whole source) and can start
a run. imports.sources.pause and imports.sources.resume control a source. A paused
source shows pause_reason_code (for example grant_invalid or credits_exhausted);
fix the cause, then resume.