Skip to main content
POST

Authorizations

Authorization
string
header
required

Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).

Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).

Headers

Idempotency-Key
string
required

Repeating the same key and request from the same API key returns the original run in its current state. Use a new key for each import you start. Reusing the key on this source and kind with different items returns 409. Use printable ASCII characters without leading or trailing whitespace.

Required string length: 8 - 255

Path Parameters

knowledge_base_id
string<uuid>
required

Knowledge base ID: the last segment of the Service API endpoint shown in the knowledge base's API Access dialog (…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.

source_id
string<uuid>
required

Source ID. From List Sources.

Body

application/json

The normalized request must fit within 4,194,304 UTF-8 bytes. See Request Size Limits.

items
object[]
required

Pages to import, from List Source Pages.

Required array length: 1 - 200 elements
kind
enum<string>
required

For a source whose metadata.providerKind is online-document.

Available options:
online-document-import

Response

The run, with kind as sent, state: queued, and progress_total set to the number of items.

canceled_at
string | null

When the run was canceled. null unless state is canceled.

checkpoint
string

Last step the run reached: queued, provider-read, preview-staged, selection-frozen, materialized, cleanup-staging, or source-committed. Retry Source Run starts the run over whatever its checkpoint.

completed_at
string | null

When the run ended (completed, zero_results, failed, or canceled), ISO 8601. null while it runs.

created_at
string

Creation time, ISO 8601.

cursor
string | null

Provider cursor the run resumes from. null when the run has not paged.

execution_attempts
integer

Times a worker has picked up the run, including after Retry Source Run, which does not reset it.

failure
object | null

Error details when state is failed. stage is the run's checkpoint at the failure, and traceId is the run ID. null otherwise.

id
string
kind
string

What the run does:

Dify also starts previews and imports when a source is added or edited there.

knowledge_space_id
string

Internal ID of the knowledge base. Not the knowledge base ID in the path.

last_error_code
string | null

failure.code when state is failed. null otherwise.

max_execution_attempts
integer

Limit on execution_attempts. Once it is reached, Retry Source Run answers 409.

progress_completed
integer

Items finished, including unchanged items a sync checked.

progress_failed
integer

Always 0 for source runs: a failing item fails the whole run.

progress_skipped
integer

Always 0 for source runs.

progress_total
integer | null

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.

source_id
string | null

Source the run belongs to.

state
string

Progress of the run.

Live states:

  • queued: waiting for a worker
  • crawling: a crawl preview is fetching pages
  • preview_ready: a crawl preview is waiting for Import Selected Pages or Cancel Source Run
  • importing: importing and indexing items
  • syncing: refreshing the source's documents

Terminal states:

  • completed: every item was imported or refreshed, indexed, and made active
  • zero_results: a crawl preview found no pages
  • failed: see failure
  • canceled

After failed or canceled, Retry Source Run runs it again, and Sync Source starts a new sync.

updated_at
string

Last change, ISO 8601.