Sync Source
Starts a sync of a source now and returns the run. Poll Get Source Run with its id until state is completed, failed, or canceled.
What a sync does depends on the source type:
-
web: re-crawls the pages in the source’s page list and re-indexes those that changed. A source with no page list yet re-crawls the whole site and imports the pages it finds.Documents whose page no longer comes back are deleted, unless the source’s
metadata.remoteDeletionPolicyisretain. -
connector: refreshes the items the source imported. -
uploadandobject-storage: the run completes without changes.
A disabled source can be synced this way: disabled stops only scheduled syncs.
A source runs one sync, preview, or import at a time. Wait for its active run to end before starting another, and cancel a crawl preview you won’t import.
For how to start and follow a sync, see Sync and Schedule Sources.
Authorization
Path parameters
…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.Headers
Length: 8–255
Responses
kind: sync and state: queued.null unless state is canceled.queued, provider-read, preview-staged, selection-frozen, materialized, cleanup-staging, or source-committed. Retry Source Run starts the run over whatever its checkpoint.completed, zero_results, failed, or canceled), ISO 8601. null while it runs.null when the run has not paged.state is failed. stage is the run's checkpoint at the failure, and traceId is the run ID. null otherwise.What the run does:
sync: started by Sync Source, Update Source, a schedule, or Dify.crawl-preview: started by Preview Website Crawl. It keeps this kind while Import Selected Pages imports from it.crawl-import: started by Import Website Pages.online-document-import,online-drive-import: started by Import Source Items.
Dify also starts previews and imports when a source is added or edited there.
failure.code when state is failed. null otherwise.0 for source runs: a failing item fails the whole run.0 for source runs.Items the run expects to process: the pages or items an import requested, the pages a crawl preview has staged so far, or the source's items once a sync has listed them. null until known.
While an Import Website Pages run crawls its URLs, progress_completed and progress_total both count the pages crawled so far. Once every URL is crawled, they restart at 0 of the number of URLs.
Progress of the run.
Live states:
queued: waiting for a workercrawling: a crawl preview is fetching pagespreview_ready: a crawl preview is waiting for Import Selected Pages or Cancel Source Runimporting: importing and indexing itemssyncing: refreshing the source's documents
Terminal states:
completed: every item was imported or refreshed, indexed, and made activezero_results: a crawl preview found no pagesfailed: seefailurecanceled
After failed or canceled, Retry Source Run runs it again, and Sync Source starts a new sync.