Skip to main content

OneDrive Watchers

A OneDrive watcher keeps a personal or work OneDrive folder synchronized with a Synth Project. It uses Microsoft Graph access, stable item identities, and durable publication checkpoints. Configure the same watcher through the Watchers UI or CaSC.

The connector supports Microsoft public-cloud personal and work/school drives. SharePoint libraries, shared-with-me items, shortcuts, packages, and sovereign clouds are outside this scope. Personal and business live account acceptance must be completed for your deployment; the automated harness uses fake Microsoft responses and does not prove tenant consent policies.

Choose A Saved Credential​

All three methods use the same regular OneDrive watcher. In Settings → Credentials, choose the method that matches your account:

CredentialWhat to supplyAccount support
OneDrive · Application credentialsTenant UUID, application (client) ID, client secret valueOneDrive for Business; no user sign-in
OneDrive · Refresh tokenOriginal app's client ID, refresh token, and client secret if that app requires onePersonal or work OneDrive with existing authorization
OneDrive · Browser sign-inClient ID, client secret, tenant; then connect once in the watcher formPersonal or work OneDrive

For application credentials, register a Microsoft Entra application in the work/school tenant. Grant Microsoft Graph application permission Files.Read.All and have a tenant administrator grant consent. Use the directory's tenant UUID, not common, consumers, or organizations. Enter the OneDrive owner’s email or user ID in the watcher. Preview resolves an email to the stable Microsoft user ID saved in user_id; CaSC requires that user ID. Preview resolves that user’s business drive. If there is more than one, also provide its Drive ID. Synth verifies the drive belongs to the selected user before preview or sync, using Microsoft’s application-enabled list-drives API. Microsoft personal accounts do not support this app-only method.

For a refresh token, use the same app that issued the authorization, with existing delegated Files.Read and offline_access consent. Use consumers for a personal account, a work tenant UUID, or common where appropriate. A public app needs no client secret. Save the credential and preview directly; there is no additional browser operation. Synth renews access and persists rotated refresh tokens under a shared lock. Microsoft can revoke or expire authorization; then replace the token using the credential editor. This is not a never-expiring key.

For browser sign-in:

  1. Register an Entra application for the intended account types, with delegated Files.Read, a client secret, and a Web redirect URI: https://your-synth.example/api/watchers/onedrive/callback.
  2. Set SYNTH_PUBLIC_URL to that Synth HTTPS origin. Local development can use localhost HTTP with an exactly matching registered redirect URI.
  3. Save a OneDrive · Browser sign-in credential with the client ID, secret, and tenant (common, consumers, organizations, or a tenant UUID).
  4. Select it in Watchers → New watcher → OneDrive, choose Connect account, and finish Microsoft's authorization. MSAL requests the identity/offline scopes needed for subsequent renewal.

Connection tokens stay in the organization credential store, protected by file permissions and a lock shared by web and worker processes. They are excluded from watcher YAML, previews, and public credential metadata. Use encrypted storage and secret backups appropriate to your deployment; the credential store itself does not supply encryption at rest.

Browser reconnection preserves the account identity. Delegated preview and startup verify the account’s own drive against the configured drive ID. To use another Microsoft account, create another credential and watcher. Deleting the credential disconnects future checks without deleting published knowledge.

Configure In The UI​

Choose a folder item ID, or leave root to watch the drive root. Preview folder resolves drive and folder IDs and shows a supported-file count and sample paths. Application credentials require the OneDrive owner. It performs no downloads, ingestion, or checkpoint writes. Preview enumerates the drive to establish folder ancestry, so max_scope_items bounds the drive inventory, not just selected files.

Set the watcher name, check interval, extensions, file rules, removal policy, and processing limits. Turn automatic processing off for a controlled first sync. Save, then use the regular Refresh, Sync, Auto-sync, and More actions.

  • Refresh compares provider state without ingesting or advancing the cursor.
  • Full refresh forces a complete read-only comparison.
  • Sync processes changes and publishes them before committing its checkpoint.
  • Reconcile requests a complete inventory on the next sync.
  • Retry resumes a blocked batch using retained work where available.

auto_sync controls automatic processing. auto_start controls startup after a server restart. A stopped watcher can still be refreshed or synced manually. Stopping OneDrive waits for active ingestion to finish before releasing its operation lock. If the Stop request times out, check the run status before retrying; a cancelled request does not cancel the underlying extraction thread.

Configure With CaSC​

Add a watcher to the Project's .synth/config.yaml:

watchers:
onedrive-documents:
type: onedrive
credential: microsoft-reader
interval: 300
auto_start: true
auto_sync: false
config:
drive_id: YOUR_DRIVE_ID
# Required only for application credentials:
# user_id: MICROSOFT_USER_OBJECT_ID
folder_id: root
file_extensions: [.pdf, .docx, .md, .txt, .xlsx, .xls, .csv]
files:
rules:
- name: Documents
include: ['**/*']
exclude: ['private/**', '**/drafts/**']
removal_policy: tombstone
reconcile_interval: 86400
max_scope_items: 100000
max_batch_items: 500
max_file_bytes: 52428800
max_batch_bytes: 268435456
max_sheet_rows: 100000
max_sheet_columns: 512
max_parts: 1000
part_chars: 16000

These are the UI defaults, except automatic processing is off and two example path exclusions are set. The minimum check interval is 60 seconds. Use a saved Microsoft credential; no access tokens or inline secrets belong in watcher configuration. Unknown fields, invalid limits, unsupported extensions, and missing references are rejected. An invalid CaSC watcher entry does not prevent valid entries from loading.

File rules match paths relative to the selected folder, case-insensitively. Each rule needs include globs or include_regex expressions; exclude and exclude_regex narrow that rule. The first rule whose include matches decides the result, including its exclusions. Unmatched files are excluded, and extension filters always apply. Omit files to include every supported file. The UI accepts one pattern per line and preserves rule order through edits.

Preview uses exactly the same rules as sync. Excluding a previously synced file withdraws its source support using the configured removal policy on the next sync. Review the preview before changing an existing scope.

Saved credentials can also be provisioned through the existing CaSC import. For unattended OneDrive for Business access:

credentials:
microsoft-reader:
type: onedrive_app
name: Microsoft reader
data:
tenant: {env: MICROSOFT_TENANT_ID}
client_id: {env: MICROSOFT_CLIENT_ID}
client_secret: {env: MICROSOFT_CLIENT_SECRET}

For existing personal or work authorization:

credentials:
microsoft-reader:
type: onedrive_refresh_token
name: Microsoft reader
data:
tenant: consumers
client_id: {env: MICROSOFT_CLIENT_ID}
refresh_token: {env: MICROSOFT_REFRESH_TOKEN}
# Omit for public apps; otherwise use the original app's secret.
client_secret: {env: MICROSOFT_CLIENT_SECRET}

For browser sign-in, use type: onedrive_oauth with client ID, secret, and tenant, then connect from the UI. Existing onedrive_oauth configurations remain valid.

The watcher references only the credential ID. Never put tokens in watcher YAML or commit them. Back up the durable organization credential directory securely: it contains the latest renewed authorization. CaSC reimport for the same client and tenant preserves rotated refresh tokens or the newer MSAL cache, rather than reinstalling an old seed. Rotate an imported refresh token through the credential editor, or provision a new credential ID. Client-secret changes invalidate cached access for the two unattended methods. Credential types cannot change in place.

Drive and folder scope are immutable once state exists. Create a separate watcher to track a different scope. Mutable processing settings can be edited after the active batch finishes.

Resolve a blocked batch before changing exclusions​

If an input cannot be processed (for example, a scanned PDF without embedded text), ordinary Retry uses the same staged bytes. Changing exclusions does not rewrite an open batch.

Turn Auto-sync off, wait for active work to finish, and use the OneDrive recovery API with an authenticated Project editor credential. It also works when the watcher is stopped:

  1. GET /api/watchers/onedrive/{watcher_id}/batch returns the current batch, checkpoint generation, preview_digest, retained receipt count and any blockers. Continue only when can_replan is true.

  2. POST /api/watchers/onedrive/{watcher_id}/resolve-batch with that exact preview:

    {
    "batch_id": "odb_<32 hexadecimal characters>",
    "expected_checkpoint": 2,
    "preview_digest": "<digest from the preview>",
    "reason": "Exclude inputs that cannot be processed"
    }
  3. Update the watcher's exclusions through its normal configuration API/UI and its CaSC configuration, then Sync. Re-enable Auto-sync after acceptance.

Resolution marks the old batch abandoned with an audit receipt. It does not advance or reset the cursor, change committed file tracking, delete knowledge, or remove staged files and extraction receipts. It does not start ingestion. Already committed unchanged files remain tracked. Partial unpublished work is retained as recovery material, but a replacement batch may repeat uncommitted work; retention is not a claim that those sources were successfully published.

The operation refuses active jobs, ongoing publication, and complete protected result sets that should finish normal publication recovery. A stale preview returns HTTP 409; preview again instead of changing the database. Repeating a successful request returns its original receipt without affecting a newer batch. There is no automatic per-source skip or OCR fallback in this recovery action.

Content And Continuity​

ContentIngestion units
PDF, DOCX, Markdown, TXTOriginal bytes, one source per file
CSVDeterministic Markdown row groups
XLSX, XLSDeterministic Markdown row groups per sheet
Other formats, packages, shortcutsExcluded; targets are not followed

Spreadsheet units use sheet and part positions. Formula text is preserved for XLSX; XLS uses the workbook's stored cell values. Formulas and macros are never executed. Row, column, part, ZIP expansion, file, and batch limits bound processing. A workbook must fit within a batch; increase its explicit limits if necessary. Unsupported extensions are excluded by the configured filter. Failed conversion blocks progress instead of silently marking the file ingested.

Identity uses cloud, drive, immutable item ID, and unit key, rather than path. Renames and moves within scope update metadata without extraction. Unchanged provider versions require no download; changed versions with identical rendered bytes require no extraction. Changed content updates the same source lineage.

The watcher drains delta pages before planning, periodically reconciles a full inventory, and falls back to a full inventory after cursor expiry. Confirmed deletions, moves out of scope, and removed workbook parts are withdrawn through the shared source-removal safety path before unrelated ingestion proceeds. That withdrawal remains effective if another file fails to download or ingest; the cursor still waits for the complete batch. Ambiguous absence or lost access retains prior knowledge. Shared pages retain other sources' support, with any required rebuilding handled by the background quality queue.

Completed ingestion and Project read publication precede cursor advancement. Interrupted batches reuse staged bytes and sealed results. Publication retries do not repeat successful extraction. Multiple batches can drain a large change set while preserving the original cursor until every selected change is handled. Use durable shared Project and credential volumes for separate workers.

The normal Project/provider budget admission applies. This connector does not add a separate weekly watcher budget; assess any existing deployment budget policy before replacing a custom integration.

Existing Ingestion And Rollout​

A new watcher normally inventories and ingests its selected scope. It does not automatically recognize files previously ingested by a custom uploader. Adopting existing knowledge is a separate deployment migration: verify remote item/content identity, bind existing source and page lineage, seed durable unit state, and rehearse on a backup before enabling one producer. A filename match, legacy “queued” record, or token=latest does not prove successful ingestion. There is no adopter watcher type or adoption mode in the UI.

For failures, inspect the watcher status and last error, restore connectivity or fix the limit, then Retry. Keep the existing .synth/watcher_data directory and credential volume across restarts. Never clear them as a retry strategy.

Run deterministic connector and integration checks with:

bash harness/scripts/harness_docker.sh --harness onedrive-watcher --runs 1 --require-report

Microsoft references: client credentials, refresh tokens, list-drives application permissions, and drive item access permissions.