> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-fix-template-upload-size-guidance.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Knowledge Base

> Updates a knowledge base. Only the fields included in the request body are changed.



## OpenAPI

````yaml /en/api-reference/openapi_service.json patch /datasets/{dataset_id}
openapi: 3.0.1
info:
  description: >-
    REST API for Dify applications and knowledge bases. Application endpoints
    authenticate with an app API key; knowledge endpoints authenticate with a
    dataset API key.
  title: Dify Service API
  version: 1.0.0
servers:
  - description: >-
      Base URL of the Dify Service API. For self-hosted deployments, replace it
      with your own API base URL.
    url: https://{api_base_url}
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: Host and path of the API base URL, without the `https://` prefix.
security:
  - ApiKeyAuth: []
tags:
  - description: Operations related to chat messages and interactions.
    name: Chat Messages
  - description: File upload and preview operations.
    name: Files
  - description: Operations related to end user information.
    name: End Users
  - description: User feedback operations.
    name: Feedback
  - description: Operations related to managing conversations.
    name: Conversations
  - description: Text-to-Speech and Speech-to-Text operations.
    name: Audio
  - description: Operations to retrieve application settings and information.
    name: Applications
  - description: Operations related to managing annotations for direct replies.
    name: Annotations
  - description: Endpoints for resuming paused workflows that require human input.
    name: Human Input
  - description: Operations for executing and managing workflows.
    name: Workflow Runs
  - description: Operations related to text generation and completion.
    name: Completion Messages
  - description: >-
      Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
    name: Knowledge Bases
  - description: >-
      Operations for creating, updating, and managing documents within a
      knowledge base.
    name: Documents
  - description: Operations for managing document chunks and child chunks.
    name: Chunks
  - description: >-
      Operations for managing knowledge base metadata fields and document
      metadata values.
    name: Metadata
  - description: Operations for managing knowledge base tags and tag bindings.
    name: Tags
  - description: Operations for retrieving available models.
    name: Models
  - description: >-
      Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
    name: Knowledge Pipeline
paths:
  /datasets/{dataset_id}:
    patch:
      tags:
        - Knowledge Bases
      summary: Update Knowledge Base
      description: >-
        Updates a knowledge base. Only the fields included in the request body
        are changed.
      operationId: updateDataset
      parameters:
        - description: >-
            Knowledge base ID, from [List Knowledge
            Bases](/en/api-reference/knowledge-bases/list-knowledge-bases).
          in: path
          name: dataset_id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                description:
                  description: Description of the knowledge base.
                  maxLength: 400
                  type: string
                embedding_model:
                  description: >-
                    Embedding model name. Use the `model` field from [Get
                    Available
                    Models](/en/api-reference/models/get-available-models) with
                    `model_type=text-embedding`.
                  type: string
                embedding_model_provider:
                  description: >-
                    Embedding model provider identifier, formatted as
                    `organization/plugin_name/provider_name` (e.g.
                    `langgenius/openai/openai`). A bare name like `openai`
                    expands to `langgenius/<name>/<name>` and works only for
                    langgenius-published plugins.


                    Get valid values from the `provider` field of [Get Available
                    Models](/en/api-reference/models/get-available-models) with
                    `model_type=text-embedding`.
                  type: string
                external_knowledge_api_id:
                  description: ID of the external knowledge API connection.
                  type: string
                external_knowledge_id:
                  description: ID of the external knowledge base.
                  type: string
                external_retrieval_model:
                  description: Retrieval settings for external knowledge bases.
                  properties:
                    score_threshold:
                      description: >-
                        Minimum similarity score threshold for filtering
                        results.
                      type: number
                    score_threshold_enabled:
                      description: Whether score threshold filtering is enabled.
                      type: boolean
                    top_k:
                      description: Maximum number of results to return.
                      type: integer
                  type: object
                indexing_technique:
                  description: >-
                    `high_quality` uses embedding models for precise search;
                    `economy` uses keyword-based indexing.
                  enum:
                    - high_quality
                    - economy
                  nullable: true
                  type: string
                name:
                  description: Name of the knowledge base.
                  maxLength: 40
                  minLength: 1
                  type: string
                partial_member_list:
                  description: >-
                    List of team members with access when `permission` is
                    `partial_members`.
                  items:
                    properties:
                      user_id:
                        description: ID of the team member to grant access.
                        type: string
                    type: object
                  type: array
                permission:
                  description: >-
                    Controls who can access this knowledge base. `only_me`
                    restricts to the creator, `all_team_members` grants access
                    to the entire workspace, `partial_members` grants access to
                    specified members.
                  enum:
                    - only_me
                    - all_team_members
                    - partial_members
                  type: string
                retrieval_model:
                  $ref: '#/components/schemas/RetrievalModel'
                  description: >-
                    Retrieval model configuration. Controls how chunks are
                    searched and ranked when querying this knowledge base.
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                success:
                  summary: Response Example
                  value:
                    app_count: 0
                    author_name: admin
                    built_in_field_enabled: true
                    chunk_structure: null
                    created_at: 1741267200
                    created_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                    data_source_type: null
                    description: Technical documentation for the product API
                    doc_form: text_model
                    doc_metadata: []
                    document_count: 0
                    embedding_available: true
                    embedding_model: text-embedding-3-small
                    embedding_model_provider: langgenius/openai/openai
                    enable_api: true
                    external_knowledge_info: null
                    external_retrieval_model: null
                    icon_info: null
                    id: c42e2a6e-40b3-4330-96f8-f1e4d768e8c9
                    indexing_technique: high_quality
                    is_multimodal: false
                    is_published: false
                    maintainer: admin
                    name: Product Documentation
                    partial_member_list: []
                    permission: only_me
                    pipeline_id: null
                    provider: vendor
                    retrieval_model_dict:
                      reranking_enable: false
                      reranking_mode: null
                      reranking_model:
                        reranking_model_name: ''
                        reranking_provider_name: ''
                      score_threshold: null
                      score_threshold_enabled: false
                      search_method: semantic_search
                      top_k: 3
                      weights: null
                    runtime_mode: null
                    summary_index_setting: null
                    tags: []
                    total_available_documents: 0
                    total_documents: 0
                    updated_at: 1741267200
                    updated_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                    word_count: 0
              schema:
                $ref: '#/components/schemas/Dataset'
          description: Knowledge base updated successfully.
        '400':
          content:
            application/json:
              examples:
                invalid_param:
                  summary: invalid_param
                  value:
                    code: invalid_param
                    message: >-
                      No Embedding Model available. Please configure a valid
                      provider in the Settings -> Model Provider.
                    status: 400
          description: >-
            `invalid_param` : The embedding or reranking model you specified is
            not configured or available.
        '403':
          content:
            application/json:
              examples:
                forbidden_1:
                  summary: forbidden (api access)
                  value:
                    code: forbidden
                    message: Dataset api access is not enabled.
                    status: 403
                forbidden_2:
                  summary: forbidden (rate limit)
                  value:
                    code: forbidden
                    message: >-
                      Sorry, you have reached the knowledge base request rate
                      limit of your subscription.
                    status: 403
          description: >-
            - `forbidden` : API access is not enabled for this knowledge base.

            - `forbidden` : Your subscription's knowledge base request rate
            limit has been reached.
        '404':
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    code: not_found
                    message: Dataset not found.
                    status: 404
          description: '`not_found` : No knowledge base matches `dataset_id`.'
components:
  schemas:
    RetrievalModel:
      properties:
        metadata_filtering_conditions:
          description: >-
            Restrict retrieval to chunks whose document metadata matches the
            given conditions. Conditions are evaluated server-side against
            document metadata fields.
          nullable: true
          properties:
            conditions:
              description: List of metadata conditions to evaluate.
              items:
                properties:
                  comparison_operator:
                    description: >-
                      Comparison to apply, by metadata type:


                      - String or array metadata: `contains`, `not contains`,
                      `start with`, `end with`, `is`, `is not`, `empty`, `not
                      empty`, `in`, `not in`

                      - Numeric metadata: `=`, `≠`, `>`, `<`, `≥`, `≤`

                      - Time metadata: `before`, `after`
                    enum:
                      - contains
                      - not contains
                      - start with
                      - end with
                      - is
                      - is not
                      - empty
                      - not empty
                      - in
                      - not in
                      - '='
                      - ≠
                      - '>'
                      - <
                      - ≥
                      - ≤
                      - before
                      - after
                    type: string
                  name:
                    description: Metadata field name to compare against.
                    type: string
                  value:
                    description: >-
                      Value to compare against. Type depends on
                      `comparison_operator`: string for most string operators,
                      array of strings for `in` and `not in`, number for numeric
                      operators, and omitted for `empty` and `not empty`.
                    nullable: true
                    oneOf:
                      - type: string
                      - items:
                          type: string
                        type: array
                      - type: number
                required:
                  - name
                  - comparison_operator
                type: object
              nullable: true
              type: array
            logical_operator:
              default: and
              description: How to combine multiple conditions.
              enum:
                - and
                - or
              nullable: true
              type: string
          type: object
        reranking_enable:
          description: Whether reranking is enabled.
          type: boolean
        reranking_mode:
          description: Reranking mode. Required when `reranking_enable` is `true`.
          enum:
            - reranking_model
            - weighted_score
          nullable: true
          type: string
        reranking_model:
          description: Reranking model configuration.
          properties:
            reranking_model_name:
              description: Name of the reranking model.
              type: string
            reranking_provider_name:
              description: >-
                Reranking model provider identifier, formatted as
                `organization/plugin_name/provider_name` (e.g.
                `langgenius/cohere/cohere`). A bare name like `cohere` expands
                to `langgenius/<name>/<name>` and works only for
                langgenius-published plugins.


                Get valid values from the `provider` field of [Get Available
                Models](/en/api-reference/models/get-available-models) with
                `model_type=rerank`.
              type: string
          type: object
        score_threshold:
          description: >-
            Minimum similarity score for results. Only effective when
            `score_threshold_enabled` is `true`.
          nullable: true
          type: number
        score_threshold_enabled:
          description: Whether score threshold filtering is enabled.
          type: boolean
        search_method:
          description: Search method used for retrieval.
          enum:
            - keyword_search
            - semantic_search
            - full_text_search
            - hybrid_search
          type: string
        top_k:
          description: Maximum number of results to return.
          type: integer
        weights:
          description: Weight configuration for hybrid search.
          nullable: true
          properties:
            keyword_setting:
              description: Keyword search weight settings.
              properties:
                keyword_weight:
                  description: Weight assigned to keyword search results.
                  type: number
              type: object
            vector_setting:
              description: Semantic search weight settings.
              properties:
                embedding_model_name:
                  description: Name of the embedding model used for vector search.
                  type: string
                embedding_provider_name:
                  description: Provider of the embedding model used for vector search.
                  type: string
                vector_weight:
                  description: Weight assigned to semantic (vector) search results.
                  type: number
              type: object
            weight_type:
              description: Strategy for balancing semantic and keyword search weights.
              enum:
                - semantic_first
                - keyword_first
                - customized
              type: string
          type: object
      required:
        - search_method
        - reranking_enable
        - top_k
        - score_threshold_enabled
      type: object
    Dataset:
      properties:
        app_count:
          description: Number of applications currently using this knowledge base.
          type: integer
        author_name:
          description: Display name of the creator.
          type: string
        built_in_field_enabled:
          description: >-
            Whether built-in metadata fields (e.g., `document_name`, `uploader`)
            are enabled.
          type: boolean
        chunk_structure:
          description: Chunk structure configuration.
          nullable: true
          type: string
        created_at:
          description: Creation timestamp (Unix epoch in seconds).
          type: number
        created_by:
          description: ID of the user who created the knowledge base.
          type: string
        data_source_type:
          description: Data source type of the documents, `null` if not yet configured.
          type: string
        description:
          description: >-
            Optional text describing the purpose or contents of the knowledge
            base.
          type: string
        doc_form:
          description: >-
            Document chunking mode. `text_model` for standard text chunking,
            `hierarchical_model` for parent-child structure, `qa_model` for QA
            pair extraction.
          type: string
        doc_metadata:
          description: Metadata field definitions for the knowledge base.
          items:
            properties:
              id:
                description: Metadata field identifier.
                type: string
              name:
                description: Metadata field name.
                type: string
              type:
                description: Metadata field value type.
                type: string
            type: object
          type: array
        document_count:
          description: Total number of documents in the knowledge base.
          type: integer
        embedding_available:
          description: Whether the configured embedding model is currently available.
          type: boolean
        embedding_model:
          description: Name of the embedding model used for indexing.
          type: string
        embedding_model_provider:
          description: >-
            Embedding model provider identifier, formatted as
            `organization/plugin_name/provider_name` (e.g.
            `langgenius/openai/openai`). Legacy knowledge bases may return the
            bare short form (e.g. `openai`).
          type: string
        enable_api:
          description: Whether API access is enabled for this knowledge base.
          type: boolean
        external_knowledge_info:
          description: >-
            Connection details for external knowledge bases. Present when
            `provider` is `external`.
          nullable: true
          properties:
            external_knowledge_api_endpoint:
              description: Endpoint URL of the external knowledge API.
              type: string
            external_knowledge_api_id:
              description: ID of the external knowledge API connection.
              type: string
            external_knowledge_api_name:
              description: Display name of the external knowledge API.
              type: string
            external_knowledge_id:
              description: ID of the external knowledge base.
              type: string
          type: object
        external_retrieval_model:
          description: >-
            Retrieval settings for external knowledge bases. `null` for internal
            knowledge bases.
          nullable: true
          properties:
            score_threshold:
              description: Minimum similarity score threshold.
              type: number
            score_threshold_enabled:
              description: Whether score threshold filtering is enabled.
              type: boolean
            top_k:
              description: >-
                Maximum number of results to return from the external knowledge
                base.
              type: integer
          type: object
        icon_info:
          description: Icon display configuration for the knowledge base.
          nullable: true
          properties:
            icon:
              description: Icon identifier or emoji.
              type: string
            icon_background:
              description: Background color for the icon.
              type: string
            icon_type:
              description: Type of icon.
              type: string
            icon_url:
              description: URL of a custom icon image.
              type: string
          type: object
        id:
          description: Unique identifier of the knowledge base.
          type: string
        indexing_technique:
          description: >-
            `high_quality` uses embedding models for precise search; `economy`
            uses keyword-based indexing.
          type: string
        is_multimodal:
          description: Whether multimodal content processing is enabled.
          type: boolean
        is_published:
          description: Whether the knowledge base is published.
          type: boolean
        maintainer:
          description: Display name of the knowledge base maintainer. `null` if not set.
          nullable: true
          type: string
        name:
          description: Display name of the knowledge base. Unique within the workspace.
          type: string
        partial_member_list:
          description: >-
            Account IDs of members granted access when `permission` is
            `partial_members`. Always present on the update response; on the
            detail response, present only when `permission` is
            `partial_members`.
          items:
            type: string
          nullable: true
          type: array
        permission:
          description: >-
            Controls who can access this knowledge base. Possible values:
            `only_me`, `all_team_members`, `partial_members`.
          type: string
        pipeline_id:
          description: Pipeline ID, if a custom processing pipeline is configured.
          nullable: true
          type: string
        provider:
          description: >-
            Provider type. `vendor` for internally managed, `external` for
            external knowledge base connections.
          type: string
        retrieval_model_dict:
          description: Retrieval configuration for the knowledge base.
          properties:
            reranking_enable:
              description: Whether reranking is enabled.
              type: boolean
            reranking_mode:
              description: >-
                Reranking mode. `reranking_model` for model-based reranking,
                `weighted_score` for score-based weighting. `null` if reranking
                is disabled.
              nullable: true
              type: string
            reranking_model:
              description: Reranking model configuration.
              properties:
                reranking_model_name:
                  description: Name of the reranking model.
                  type: string
                reranking_provider_name:
                  description: >-
                    Reranking model provider identifier, formatted as
                    `organization/plugin_name/provider_name` (e.g.
                    `langgenius/cohere/cohere`). Legacy knowledge bases may
                    return the bare short form (e.g. `cohere`).
                  type: string
              type: object
            score_threshold:
              description: >-
                Minimum similarity score for results. Only effective when
                `score_threshold_enabled` is `true`.
              type: number
            score_threshold_enabled:
              description: Whether score threshold filtering is enabled.
              type: boolean
            search_method:
              description: >-
                Search method used for retrieval. `keyword_search` for keyword
                matching, `semantic_search` for embedding-based similarity,
                `full_text_search` for full-text indexing, `hybrid_search` for a
                combination of semantic and keyword approaches.
              type: string
            top_k:
              description: Maximum number of results to return.
              type: integer
            weights:
              description: Weight configuration for hybrid search.
              nullable: true
              properties:
                keyword_setting:
                  description: Keyword search weight settings.
                  properties:
                    keyword_weight:
                      description: Weight assigned to keyword search results.
                      type: number
                  type: object
                vector_setting:
                  description: Semantic search weight settings.
                  properties:
                    embedding_model_name:
                      description: Name of the embedding model used for vector search.
                      type: string
                    embedding_provider_name:
                      description: Provider of the embedding model used for vector search.
                      type: string
                    vector_weight:
                      description: Weight assigned to semantic (vector) search results.
                      type: number
                  type: object
                weight_type:
                  description: Strategy for balancing semantic and keyword search weights.
                  type: string
              type: object
          type: object
        runtime_mode:
          description: Runtime processing mode.
          nullable: true
          type: string
        summary_index_setting:
          description: Summary index configuration.
          nullable: true
          properties:
            enable:
              description: Whether summary indexing is enabled.
              type: boolean
            model_name:
              description: Name of the model used for generating summaries.
              type: string
            model_provider_name:
              description: Provider of the summary generation model.
              type: string
            summary_prompt:
              description: Prompt template used for summary generation.
              type: string
          type: object
        tags:
          description: Tags associated with this knowledge base.
          items:
            properties:
              id:
                description: Tag identifier.
                type: string
              name:
                description: Tag name.
                type: string
              type:
                description: Tag type. Always `knowledge` for knowledge base tags.
                type: string
            type: object
          type: array
        total_available_documents:
          description: Number of documents that are enabled and available.
          type: integer
        total_documents:
          description: Total number of documents.
          type: integer
        updated_at:
          description: Last update timestamp (Unix epoch in seconds).
          type: number
        updated_by:
          description: ID of the user who last updated the knowledge base.
          type: string
        word_count:
          description: Total word count across all documents.
          type: integer
      type: object
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: API_KEY
      description: >-
        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](/en/api-reference/guides/get-started)).


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

````