# Dify Docs: English Cloud Developer Resources API > Dify is an open-source platform for building AI applications. It provides a comprehensive set of tools and features to help you build, deploy, and manage your AI applications. ## API ### Guides - [Get Started with the Dify API](https://docs.dify.ai/en/api-reference/guides/get-started.md): Get an API key, make your first call, and find the endpoints for your app type - [Consume Streaming Responses](https://docs.dify.ai/en/api-reference/guides/streaming.md): Choose a response mode, parse the SSE stream, dispatch events, and recover when a connection drops - [Human Input API Integration Flow](https://docs.dify.ai/en/api-reference/guides/human-input-flow.md): End-to-end sequence for handling a paused Human Input form via the API - [End User Identity](https://docs.dify.ai/en/api-reference/guides/end-user-identity.md): What the user field identifies, what it scopes, and why it must stay consistent across calls - [Handle Errors and Rate Limits](https://docs.dify.ai/en/api-reference/guides/errors.md): The error envelope, what each status class means, and which failures are worth retrying #### API Overviews - [Chatflow App API](https://docs.dify.ai/en/api-reference/guides/chatflow.md): API for Chatflow apps, covering chat messages, workflow-level streaming, conversation management, and Human Input pauses - [Workflow App API](https://docs.dify.ai/en/api-reference/guides/workflow.md): API for Workflow apps, covering workflow execution, run control and streaming, Human Input pauses, and run history - [Agent API](https://docs.dify.ai/en/api-reference/guides/agent.md): API for Agent apps, covering streaming chat messages, conversation management, file uploads, and app configuration - [Chat App API](https://docs.dify.ai/en/api-reference/guides/chat.md): API for Chatbot and legacy Agent apps, covering chat messages, conversation management, file uploads, voice, and annotations - [Completion App API](https://docs.dify.ai/en/api-reference/guides/completion.md): API for Text Generator apps, covering completion messages, file uploads, voice, and feedback ##### Knowledge Base - [Knowledge Base API](https://docs.dify.ai/en/api-reference/guides/knowledge-base-api.md): Create and scope the API keys that both knowledge base APIs take, replace them safely, and find out why a call was refused - [Agent Knowledge Base API](https://docs.dify.ai/en/api-reference/guides/knowledge-base.md): Query an Agent Knowledge Base from your own code, read back what a run retrieved, and keep its documents, sources, and settings maintained - [Classic Knowledge Base API](https://docs.dify.ai/en/api-reference/guides/knowledge.md): API for managing classic knowledge bases, documents, chunks, metadata, tags, and knowledge pipelines ### App APIs #### Chat Messages - [Send Chat Message](https://docs.dify.ai/en/api-reference/chat-messages/send-chat-message.md): **Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps. - [Stop Chat Message Generation](https://docs.dify.ai/en/api-reference/chat-messages/stop-chat-message-generation.md): **Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps. - [Get Next Suggested Questions](https://docs.dify.ai/en/api-reference/chat-messages/get-next-suggested-questions.md): **Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps. #### Completion Messages - [Send Completion Message](https://docs.dify.ai/en/api-reference/completion-messages/send-completion-message.md): **Available for**: Text Generator apps. - [Stop Completion Message Generation](https://docs.dify.ai/en/api-reference/completion-messages/stop-completion-message-generation.md): **Available for**: Text Generator apps. #### Workflow Runs - [Run Workflow](https://docs.dify.ai/en/api-reference/workflow-runs/run-workflow.md): **Available for**: Workflow apps. - [Run Workflow by ID](https://docs.dify.ai/en/api-reference/workflow-runs/run-workflow-by-id.md): **Available for**: Workflow apps. - [Stop Workflow Task](https://docs.dify.ai/en/api-reference/workflow-runs/stop-workflow-task.md): **Available for**: Workflow apps. - [Get Workflow Run Detail](https://docs.dify.ai/en/api-reference/workflow-runs/get-workflow-run-detail.md): **Available for**: Chatflow, Workflow apps. - [List Workflow Logs](https://docs.dify.ai/en/api-reference/workflow-runs/list-workflow-logs.md): **Available for**: Chatflow, Workflow apps. - [Stream Workflow Events](https://docs.dify.ai/en/api-reference/workflow-runs/stream-workflow-events.md): **Available for**: Chatflow, Workflow apps. #### Conversations - [List Conversations](https://docs.dify.ai/en/api-reference/conversations/list-conversations.md): **Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps. - [List Conversation Messages](https://docs.dify.ai/en/api-reference/conversations/list-conversation-messages.md): **Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps. - [List Conversation Variables](https://docs.dify.ai/en/api-reference/conversations/list-conversation-variables.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. - [Rename Conversation](https://docs.dify.ai/en/api-reference/conversations/rename-conversation.md): **Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps. - [Update Conversation Variable](https://docs.dify.ai/en/api-reference/conversations/update-conversation-variable.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. - [Delete Conversation](https://docs.dify.ai/en/api-reference/conversations/delete-conversation.md): **Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps. #### Files - [Upload File](https://docs.dify.ai/en/api-reference/files/upload-file.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. - [Download File](https://docs.dify.ai/en/api-reference/files/download-file.md): **Available for**: Chatflow, Chatbot, Legacy Agent, Text Generator apps. #### Audio - [Convert Audio to Text](https://docs.dify.ai/en/api-reference/audio/convert-audio-to-text.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. - [Convert Text to Audio](https://docs.dify.ai/en/api-reference/audio/convert-text-to-audio.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. #### Applications - [Get App Info](https://docs.dify.ai/en/api-reference/applications/get-app-info.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. - [Get App Parameters](https://docs.dify.ai/en/api-reference/applications/get-app-parameters.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. - [Get App Meta](https://docs.dify.ai/en/api-reference/applications/get-app-meta.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. - [Get App WebApp Settings](https://docs.dify.ai/en/api-reference/applications/get-app-webapp-settings.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. #### Feedback - [Submit Message Feedback](https://docs.dify.ai/en/api-reference/feedback/submit-message-feedback.md): **Available for**: Chatflow, Chatbot, Legacy Agent, Text Generator apps. - [List App Feedbacks](https://docs.dify.ai/en/api-reference/feedback/list-app-feedbacks.md): **Available for**: Chatflow, Chatbot, Legacy Agent, Text Generator apps. #### Annotations - [Create Annotation](https://docs.dify.ai/en/api-reference/annotations/create-annotation.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. - [List Annotations](https://docs.dify.ai/en/api-reference/annotations/list-annotations.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. - [Update Annotation](https://docs.dify.ai/en/api-reference/annotations/update-annotation.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. - [Delete Annotation](https://docs.dify.ai/en/api-reference/annotations/delete-annotation.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. - [Configure Annotation Reply](https://docs.dify.ai/en/api-reference/annotations/configure-annotation-reply.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. - [Get Annotation Reply Job Status](https://docs.dify.ai/en/api-reference/annotations/get-annotation-reply-job-status.md): **Available for**: Chatflow, Chatbot, Legacy Agent apps. #### End Users - [Get End User Info](https://docs.dify.ai/en/api-reference/end-users/get-end-user-info.md): **Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps. #### Human Input - [Get Human Input Form](https://docs.dify.ai/en/api-reference/human-input/get-human-input-form.md): **Available for**: Chatflow, Workflow apps. - [Submit Human Input Form](https://docs.dify.ai/en/api-reference/human-input/submit-human-input-form.md): **Available for**: Chatflow, Workflow apps. ### Knowledge APIs #### Agent Knowledge Base ##### Queries - [Create Query Token](https://docs.dify.ai/en/api-reference/queries/create-query-token.md): Issues a query token for [Run Query](/en/api-reference/queries/run-query) and returns the request body to send with it. See [Query the Knowledge Base](/en/api-reference/guides/knowledge-base#query-the-knowledge-base) for details. - [Run Query](https://docs.dify.ai/en/api-reference/queries/run-query.md): Runs the query that [Create Query Token](/en/api-reference/queries/create-query-token) issued a token for and streams the answer as Server-Sent Events. The credential is the query token, not the knowledge base API key. The token is checked when the request is accepted. ##### Query Records - [List Query Records](https://docs.dify.ai/en/api-reference/query-records/list-query-records.md): Lists the query records of a knowledge base, newest first. Each [Run Query](/en/api-reference/queries/run-query) call saves a record once its stream opens, including a run that then fails, unless the client disconnected or the run failed with `RETRIEVAL_EXECUTION_LEASE_LOST`. - [Get Query Record](https://docs.dify.ai/en/api-reference/query-records/get-query-record.md): Returns one query record in full: the query, the retrieval depth, who ran it, and the pipeline steps in execution order with their metadata. The `query.generate` step's metadata embeds every retrieved chunk, so the response can be large (up to 2 MiB). - [List Query Chunks](https://docs.dify.ai/en/api-reference/query-records/list-query-chunks.md): Lists the chunks a query run retrieved, one entry per chunk, with its primary citation, scores, freshness, and text. - [List Query Conflicts](https://docs.dify.ai/en/api-reference/query-records/list-query-conflicts.md): Lists every conflict recorded on the chunks a query run retrieved, one entry per conflict. - [List Missing Chunks](https://docs.dify.ai/en/api-reference/query-records/list-missing-chunks.md): Lists the chunks a query run expected but could not use, one entry per chunk. An empty `data` with `truncated: false` means the run recorded none. ##### Research Tasks - [List Research Tasks](https://docs.dify.ai/en/api-reference/research-tasks/list-research-tasks.md): Lists the research tasks a knowledge base holds for the calling API key, newest first. - [Create Research Task](https://docs.dify.ai/en/api-reference/research-tasks/create-research-task.md): Creates a research task for a question and returns it with `stage` `queued`. The task then runs in the background. For the plan, create, poll, and read flow, see [Run a Research Task](/en/api-reference/guides/knowledge-base#run-a-research-task). - [Plan Research Task](https://docs.dify.ai/en/api-reference/research-tasks/plan-research-task.md): Estimates a research task without creating it. Returns the resolved retrieval depth and estimates of cost, latency, and work, including whether they fit the proposed budget. - [Get Research Task](https://docs.dify.ai/en/api-reference/research-tasks/get-research-task.md): Returns the current state of a research task: `stage`, cost so far, limits, timestamps, and error details when it failed. - [Cancel Research Task](https://docs.dify.ai/en/api-reference/research-tasks/cancel-research-task.md): Cancels a research task that has not finished and returns it with `stage` `canceled`. - [List Research Task Results](https://docs.dify.ai/en/api-reference/research-tasks/list-research-task-results.md): Lists the results a research task has written so far, in ascending `sequence`. ##### Documents and Chunks - [List Documents](https://docs.dify.ai/en/api-reference/documents-and-chunks/list-documents.md): Lists the documents in a knowledge base, oldest first, with each document's status, custom metadata, active revision, and latest indexing task. - [Get Document](https://docs.dify.ai/en/api-reference/documents-and-chunks/get-document.md): Returns one document: its status, custom metadata, `row_version`, active revision, and latest indexing task. - [Update Document Metadata](https://docs.dify.ai/en/api-reference/documents-and-chunks/update-document-metadata.md): Merges keys into a document's `user_metadata` and returns the updated document. Unlike the other operations on this path, it takes the document ID, not a document file ID. - [Delete Document](https://docs.dify.ai/en/api-reference/documents-and-chunks/delete-document.md): Requests the deletion of a document and returns the deletion job. It removes the document, every revision, and the document files that only this document uses. Once the job completes, the document no longer counts toward the document quota. - [Get Document by File](https://docs.dify.ai/en/api-reference/documents-and-chunks/get-document-by-file.md): Returns the document ID and the revision built from one version of a document file. Use it to turn a citation into its document: query records and research task results cite a document file by `documentAssetId` and `documentVersion`. - [List Document Files](https://docs.dify.ai/en/api-reference/documents-and-chunks/list-document-files.md): Lists the document files stored in a knowledge base. Returns document file IDs, not document IDs. [List Documents](/en/api-reference/documents-and-chunks/list-documents) lists the documents. - [Get Document File](https://docs.dify.ai/en/api-reference/documents-and-chunks/get-document-file.md): Returns one document file: the stored file behind a document, with its `version` and `parser_status`. - [Delete Document File](https://docs.dify.ai/en/api-reference/documents-and-chunks/delete-document-file.md): Requests the deletion of a document file and returns the deletion job. Every revision built on the file stops returning chunks through [List Chunks](/en/api-reference/documents-and-chunks/list-chunks). - [Get Document Outline](https://docs.dify.ai/en/api-reference/documents-and-chunks/get-document-outline.md): Returns the heading tree built for the current version of a document file. - [List Document Revisions](https://docs.dify.ai/en/api-reference/documents-and-chunks/list-document-revisions.md): Lists a document's revisions, newest first. Takes the document ID from [List Documents](/en/api-reference/documents-and-chunks/list-documents), not the document file ID. - [List Chunks](https://docs.dify.ai/en/api-reference/documents-and-chunks/list-chunks.md): Lists the chunks of one revision of a document, ordered by chunk ID rather than by position. Takes the document ID from [List Documents](/en/api-reference/documents-and-chunks/list-documents), not the document file ID, plus the revision number. - [Get Chunk](https://docs.dify.ai/en/api-reference/documents-and-chunks/get-chunk.md): Returns one chunk of one revision of a document. Takes the document ID from [List Documents](/en/api-reference/documents-and-chunks/list-documents), not the document file ID, plus the revision number and the chunk ID. - [Delete Document Files in Batch](https://docs.dify.ai/en/api-reference/documents-and-chunks/delete-document-files-in-batch.md): Requests the deletion of up to 100 document files in one call and reports an outcome for each file. As with [Delete Document File](/en/api-reference/documents-and-chunks/delete-document-file), avoid files of active revisions. - [Re-index Documents](https://docs.dify.ai/en/api-reference/documents-and-chunks/re-index-documents.md): Queues an indexing task to rebuild each selected document's index from its current file. Returns a bulk task ID to follow the tasks together. ##### Indexing Tasks - [Get Indexing Task](https://docs.dify.ai/en/api-reference/indexing-tasks/get-indexing-task.md): Returns the state of one indexing task: the job that turns one version of a document file into an active revision. - [Cancel Indexing Task](https://docs.dify.ai/en/api-reference/indexing-tasks/cancel-indexing-task.md): Requests cancellation of an indexing task and returns the updated task. - [Retry Indexing Task](https://docs.dify.ai/en/api-reference/indexing-tasks/retry-indexing-task.md): Restarts an indexing task whose `run_state` is `failed` or `canceled` under the same task ID and returns the updated task. Poll [Get Indexing Task](/en/api-reference/indexing-tasks/get-indexing-task) with the same ID afterwards. - [Get Bulk Task](https://docs.dify.ai/en/api-reference/indexing-tasks/get-bulk-task.md): Returns the progress of the indexing tasks in a bulk task. In this API a bulk task comes from [Re-index Documents](/en/api-reference/documents-and-chunks/re-index-documents), and only the API key that started it can read it. - [List Document Indexing Tasks](https://docs.dify.ai/en/api-reference/indexing-tasks/list-document-indexing-tasks.md): Lists a document's indexing tasks from uploads and syncs, oldest first, each with its outcome. Failed and canceled tasks are included. - [Get Document Indexing Task](https://docs.dify.ai/en/api-reference/indexing-tasks/get-document-indexing-task.md): Returns one indexing task of a document, with its progress. Poll it until `state` is `succeeded`, `failed`, `canceled`, or `superseded`. - [List Background Tasks](https://docs.dify.ai/en/api-reference/indexing-tasks/list-background-tasks.md): Lists the knowledge base's background work in one feed, or looks up specific tasks by ID: ##### Deletion Jobs - [Get Deletion Job](https://docs.dify.ai/en/api-reference/deletion-jobs/get-deletion-job.md): Returns the progress of a deletion requested with [Delete Document](/en/api-reference/documents-and-chunks/delete-document), [Delete Document File](/en/api-reference/documents-and-chunks/delete-document-file), or [Delete Source](/en/api-reference/sources/delete-source), or of one file in [Delete Doc… - [Get Deletion Batch](https://docs.dify.ai/en/api-reference/deletion-jobs/get-deletion-batch.md): Returns a [Delete Document Files in Batch](/en/api-reference/documents-and-chunks/delete-document-files-in-batch) request with each file's outcome and the current state of each accepted file's deletion job. Only the API key that sent the batch can read it. ##### Sources - [List Source Connections](https://docs.dify.ai/en/api-reference/sources/list-source-connections.md): Lists the connections of this knowledge base, oldest first. Pass a connection's `id` as `connectionId` to [Create Source](/en/api-reference/sources/create-source) to add a source that reads through it. - [Create Source](https://docs.dify.ai/en/api-reference/sources/create-source.md): Adds a source that reads through an existing connection, found with [List Source Connections](/en/api-reference/sources/list-source-connections). Nothing is crawled or imported. - [List Sources](https://docs.dify.ai/en/api-reference/sources/list-sources.md): Lists the sources of a knowledge base in ascending source ID order, with each source's sync schedule, its last completed sync or import, and its current run, or its latest sync when none is running. - [Get Source](https://docs.dify.ai/en/api-reference/sources/get-source.md): Returns one source as stored. - [Update Source](https://docs.dify.ai/en/api-reference/sources/update-source.md): Updates a source's name, status, URI, metadata, or provider parameters, and can start a sync when the configuration changed. - [Delete Source](https://docs.dify.ai/en/api-reference/sources/delete-source.md): Requests deletion of a source and returns the deletion job. - [Test Source Credentials](https://docs.dify.ai/en/api-reference/sources/test-source-credentials.md): Asks the data source provider to validate the source's credentials and reports the result. It changes nothing on the source. - [List Source Pages](https://docs.dify.ai/en/api-reference/sources/list-source-pages.md): Lists the pages an online document source can see at its provider, grouped by provider workspace. - [List Source Files](https://docs.dify.ai/en/api-reference/sources/list-source-files.md): Lists the buckets and files an online drive source can see at its provider. - [Get Sync Policy](https://docs.dify.ai/en/api-reference/sources/get-sync-policy.md): Returns a source's sync schedule and the `revision` that [Update Sync Policy](/en/api-reference/sources/update-sync-policy) needs. - [Update Sync Policy](https://docs.dify.ai/en/api-reference/sources/update-sync-policy.md): Sets a source's sync schedule, replacing the previous one, and returns it. ##### Source Syncs and Imports - [Sync Source](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/sync-source.md): Starts a sync of a source now and returns the run. Poll [Get Source Run](/en/api-reference/source-syncs-and-imports/get-source-run) with its `id` until `state` is `completed`, `failed`, or `canceled`. - [Preview Website Crawl](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/preview-website-crawl.md): Crawls a website source and stages the pages it finds for you to choose from, without importing anything. Returns the run. Poll [Get Source Run](/en/api-reference/source-syncs-and-imports/get-source-run) with its `id` until `state` is `preview_ready`, `zero_results`, `failed`, or `canceled`. - [List Crawl Preview Pages](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/list-crawl-preview-pages.md): Lists the pages a crawl preview found, with the `page_id` to pass to [Import Selected Pages](/en/api-reference/source-syncs-and-imports/import-selected-pages). Page content is not returned. - [Import Selected Pages](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/import-selected-pages.md): Imports pages from a crawl preview into documents and returns the same run, now queued to import. Poll [Get Source Run](/en/api-reference/source-syncs-and-imports/get-source-run) with the same `id` until `state` is `completed`, `failed`, or `canceled`. - [Import Website Pages](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/import-website-pages.md): Imports known URLs into a website source and returns the run. Poll [Get Source Run](/en/api-reference/source-syncs-and-imports/get-source-run) with its `id` until `state` is `completed`, `failed`, or `canceled`. - [Import Source Items](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/import-source-items.md): Imports online document pages or online drive files into a connector source and returns the run. Poll [Get Source Run](/en/api-reference/source-syncs-and-imports/get-source-run) with its `id` until `state` is `completed`, `failed`, or `canceled`. - [List Source Runs](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/list-source-runs.md): Lists the knowledge base's source runs (syncs, crawl previews, and imports), including those started by a schedule or in Dify. Only runs of sources this key can read are listed. - [Get Source Run](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/get-source-run.md): Returns one source run. Use it to follow any run by ID, including crawl previews and imports from them, which [List Sources](/en/api-reference/sources/list-sources) does not show. - [Cancel Source Run](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/cancel-source-run.md): Cancels a source run that has not finished and returns it. - [Retry Source Run](https://docs.dify.ai/en/api-reference/source-syncs-and-imports/retry-source-run.md): Runs a `failed` or `canceled` source run again from the start, under the same run ID, and returns it queued. Progress is reset, so an import fetches every item again and a sync starts over. A crawl preview whose pages were already selected imports them again without crawling. ##### Settings - [Get Knowledge Base Settings](https://docs.dify.ai/en/api-reference/settings/get-knowledge-base-settings.md): Returns the knowledge base's embedding model, retrieval settings, readiness, and the `revision` to send in [Update Knowledge Base Settings](/en/api-reference/settings/update-knowledge-base-settings). - [Update Knowledge Base Settings](https://docs.dify.ai/en/api-reference/settings/update-knowledge-base-settings.md): Changes the knowledge base's embedding model or retrieval settings. For setting models before and after content is indexed, see [Change Models or Retrieval Settings](/en/api-reference/guides/knowledge-base#change-models-or-retrieval-settings). - [Get Settings Migration](https://docs.dify.ai/en/api-reference/settings/get-settings-migration.md): Returns the progress of the migration that [Update Knowledge Base Settings](/en/api-reference/settings/update-knowledge-base-settings) started when it answered `202`. Poll it until `run_state` is `succeeded`, `failed`, or `canceled`. #### Classic Knowledge Base ##### Knowledge Bases - [Create an Empty Knowledge Base](https://docs.dify.ai/en/api-reference/knowledge-bases/create-an-empty-knowledge-base.md): Creates an empty knowledge base. Add documents to it with [Create Document by Text](/en/api-reference/documents/create-document-by-text) or [Create Document by File](/en/api-reference/documents/create-document-by-file). - [List Knowledge Bases](https://docs.dify.ai/en/api-reference/knowledge-bases/list-knowledge-bases.md): Returns a paginated list of the workspace's knowledge bases, whatever their permission settings, optionally filtered by keyword or tags. - [Get Knowledge Base](https://docs.dify.ai/en/api-reference/knowledge-bases/get-knowledge-base.md): Returns detailed information about a knowledge base, including its embedding model, retrieval configuration, and document statistics. - [Update Knowledge Base](https://docs.dify.ai/en/api-reference/knowledge-bases/update-knowledge-base.md): Updates a knowledge base. Only the fields included in the request body are changed. - [Delete Knowledge Base](https://docs.dify.ai/en/api-reference/knowledge-bases/delete-knowledge-base.md): Permanently deletes a knowledge base, all of its documents, and any API key scoped only to it. Keys that also cover other knowledge bases keep working for those. - [Retrieve Chunks from a Knowledge Base / Test Retrieval](https://docs.dify.ai/en/api-reference/knowledge-bases/retrieve-chunks-from-a-knowledge-base-test-retrieval.md): Searches a knowledge base and returns the chunks most relevant to the query, for both production retrieval and test retrieval. ##### Documents - [Create Document by Text](https://docs.dify.ai/en/api-reference/documents/create-document-by-text.md): Creates a document in a knowledge base from raw text. Indexing runs asynchronously; track it with the returned `batch` ID via [Get Document Indexing Status](/en/api-reference/documents/get-document-indexing-status). - [Create Document by File](https://docs.dify.ai/en/api-reference/documents/create-document-by-file.md): Creates a document in a knowledge base from an uploaded file. Common formats such as PDF, TXT, and DOCX are supported. Indexing runs asynchronously; track it with the returned `batch` ID via [Get Document Indexing Status](/en/api-reference/documents/get-document-indexing-status). - [List Documents](https://docs.dify.ai/en/api-reference/documents/list-documents.md): Returns a paginated list of documents in a knowledge base. - [Get Document](https://docs.dify.ai/en/api-reference/documents/get-document.md): Returns detailed information for a single document. - [Delete Document](https://docs.dify.ai/en/api-reference/documents/delete-document.md): Permanently deletes a document and all its chunks from the knowledge base. - [Update Document](https://docs.dify.ai/en/api-reference/documents/update-document.md): Updates a document by uploading a new file, then re-indexes it. This is the canonical endpoint for file-based document updates. Track progress with the returned `batch` ID via [Get Document Indexing Status](/en/api-reference/documents/get-document-indexing-status). - [Download Document](https://docs.dify.ai/en/api-reference/documents/download-document.md): Returns a signed URL for downloading a document's original uploaded file. - [Get Document Indexing Status](https://docs.dify.ai/en/api-reference/documents/get-document-indexing-status.md): Returns indexing progress for every document in a batch: the current stage and chunk completion counts. Poll until each `indexing_status` reaches `completed` or `error`. Status advances through `waiting` → `parsing` → `cleaning` → `splitting` → `indexing` → `completed`. - [Update Document by Text](https://docs.dify.ai/en/api-reference/documents/update-document-by-text.md): Updates a document's text content, name, or processing configuration. Re-indexes the document when its text changes. - [Update Document by File](https://docs.dify.ai/en/api-reference/documents/update-document-by-file.md): Deprecated. Use [Update Document](/en/api-reference/documents/update-document) instead. Updates a document by uploading a new file, then re-indexes it. - [Download Documents as ZIP](https://docs.dify.ai/en/api-reference/documents/download-documents-as-zip.md): Downloads one or more documents as a single ZIP archive. Only documents that were uploaded as files can be included. - [Update Document Status in Batch](https://docs.dify.ai/en/api-reference/documents/update-document-status-in-batch.md): Enables, disables, archives, or unarchives multiple documents in one request. ##### Chunks - [Create Chunks](https://docs.dify.ai/en/api-reference/chunks/create-chunks.md): Create one or more chunks within a document. - [List Chunks](https://docs.dify.ai/en/api-reference/chunks/list-chunks.md): Returns a paginated list of chunks within a document, optionally filtered by keyword or indexing status. - [Get Chunk](https://docs.dify.ai/en/api-reference/chunks/get-chunk.md): Retrieve the full details of a single chunk. - [Update Chunk](https://docs.dify.ai/en/api-reference/chunks/update-chunk.md): Update a chunk's fields. The update re-triggers indexing for that chunk. - [Delete Chunk](https://docs.dify.ai/en/api-reference/chunks/delete-chunk.md): Permanently delete a chunk from the document. - [Create Child Chunk](https://docs.dify.ai/en/api-reference/chunks/create-child-chunk.md): Create a child chunk under a parent chunk. Intended for documents that use the parent-child (`hierarchical_model`) chunking mode. - [List Child Chunks](https://docs.dify.ai/en/api-reference/chunks/list-child-chunks.md): Returns a paginated list of child chunks under a specific parent chunk. - [Update Child Chunk](https://docs.dify.ai/en/api-reference/chunks/update-child-chunk.md): Update the content of an existing child chunk. - [Delete Child Chunk](https://docs.dify.ai/en/api-reference/chunks/delete-child-chunk.md): Permanently delete a child chunk from its parent chunk. ##### Metadata - [Create Metadata Field](https://docs.dify.ai/en/api-reference/metadata/create-metadata-field.md): Create a custom metadata field for annotating documents in the knowledge base with structured information. - [List Metadata Fields](https://docs.dify.ai/en/api-reference/metadata/list-metadata-fields.md): Returns all metadata fields for the knowledge base, both custom and built-in, with the count of documents using each field. - [Update Metadata Field](https://docs.dify.ai/en/api-reference/metadata/update-metadata-field.md): Rename a custom metadata field. - [Delete Metadata Field](https://docs.dify.ai/en/api-reference/metadata/delete-metadata-field.md): Permanently delete a custom metadata field. Documents that used the field lose their values for it. - [Get Built-in Metadata Fields](https://docs.dify.ai/en/api-reference/metadata/get-built-in-metadata-fields.md): Returns the built-in metadata fields provided by the system. - [Update Built-in Metadata Field](https://docs.dify.ai/en/api-reference/metadata/update-built-in-metadata-field.md): Enable or disable built-in metadata fields for the knowledge base. - [Update Document Metadata in Batch](https://docs.dify.ai/en/api-reference/metadata/update-document-metadata-in-batch.md): Update metadata values for multiple documents in a single request. ##### Tags - [Create Knowledge Tag](https://docs.dify.ai/en/api-reference/tags/create-knowledge-tag.md): Create a tag for organizing knowledge bases. - [List Knowledge Tags](https://docs.dify.ai/en/api-reference/tags/list-knowledge-tags.md): Returns all knowledge base tags in the workspace. - [Update Knowledge Tag](https://docs.dify.ai/en/api-reference/tags/update-knowledge-tag.md): Rename a knowledge base tag. - [Delete Knowledge Tag](https://docs.dify.ai/en/api-reference/tags/delete-knowledge-tag.md): Permanently delete a knowledge base tag. Does not delete the knowledge bases that were tagged. - [Create Tag Binding](https://docs.dify.ai/en/api-reference/tags/create-tag-binding.md): Bind one or more tags to a knowledge base. A knowledge base can have multiple tags. - [Delete Tag Binding](https://docs.dify.ai/en/api-reference/tags/delete-tag-binding.md): Remove one or more tags from a knowledge base. - [Get Knowledge Base Tags](https://docs.dify.ai/en/api-reference/tags/get-knowledge-base-tags.md): Returns the tags bound to a knowledge base. ##### Models - [Get Available Models](https://docs.dify.ai/en/api-reference/models/get-available-models.md): Returns the available models of a given type. Use it to find the `text-embedding` and `rerank` models to configure on a knowledge base. ##### Knowledge Pipeline - [Upload Pipeline File](https://docs.dify.ai/en/api-reference/knowledge-pipeline/upload-pipeline-file.md): Uploads a file for use in a knowledge pipeline. Use the returned `id` as the `reference` of a `local_file` item in [Run Pipeline](/en/api-reference/knowledge-pipeline/run-pipeline). - [List Datasource Plugins](https://docs.dify.ai/en/api-reference/knowledge-pipeline/list-datasource-plugins.md): Returns the datasource nodes configured in the knowledge pipeline, each with the plugin it uses and the metadata needed to run it. - [Run Datasource Node](https://docs.dify.ai/en/api-reference/knowledge-pipeline/run-datasource-node.md): Runs a single datasource node in the knowledge pipeline and streams its execution events. - [Run Pipeline](https://docs.dify.ai/en/api-reference/knowledge-pipeline/run-pipeline.md): Runs the full knowledge pipeline over one or more datasources. `response_mode` selects a streaming or blocking response. ## OpenAPI Specs - [openapi_service](/en/api-reference/openapi_service.json)