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:

  1. 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 with permission_denied, a grant of another workspace with import_grant_invalid. The provider must list sources in integrations.catalog.get; each source names its scope_fields, scan and option_fields.
  2. 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 as scope_labels so the source can show them.
  3. Check that the Space grant (integrations.grants.list) allows both the list and the import operation of that source (import_grant_missing_operations otherwise); recursive or folder-mirroring sources need a grant without a fixed folder constraint.
  4. imports.sources.preview samples the start point with the intended policy and reports how many files would be imported or skipped; show that to the user before creating.
  5. Pick the target folder with documents.folders_list (omit target_folder_id for the Space root), optionally a schedule (rule or cron, at most every 15 minutes, check it with workflows.schedule.preview; omit it for a source that only runs on demand) and a policy.

Policy

FieldDefaultEffect
recurse, max_depthtrue, 3 (1 to 10)Walk subfolders down to that depth.
mirror_folderstrueRecreate 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_bytesnoneSkip larger files; at most 10,000,000.
on_changeskipA changed file: skip keeps the first import, replace updates the document in place, import_as_new adds a numbered copy.
unpack_archivesfalseImport 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.

En esta página