> ## 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 Chunk

> Update a chunk's fields. The update re-triggers indexing for that chunk.



## OpenAPI

````yaml /en/api-reference/openapi_service.json post /datasets/{dataset_id}/documents/{document_id}/segments/{segment_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}/documents/{document_id}/segments/{segment_id}:
    post:
      tags:
        - Chunks
      summary: Update Chunk
      description: Update a chunk's fields. The update re-triggers indexing for that chunk.
      operationId: updateSegment
      parameters:
        - description: >-
            Knowledge base ID. Obtain it from [List Knowledge
            Bases](/en/api-reference/knowledge-bases/list-knowledge-bases).
          in: path
          name: dataset_id
          required: true
          schema:
            format: uuid
            type: string
        - description: >-
            Document ID. Obtain it from [List
            Documents](/en/api-reference/documents/list-documents).
          in: path
          name: document_id
          required: true
          schema:
            format: uuid
            type: string
        - description: >-
            Chunk ID. Obtain it from [List
            Chunks](/en/api-reference/chunks/list-chunks).
          in: path
          name: segment_id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                segment:
                  description: Chunk data to update.
                  properties:
                    answer:
                      description: Answer text for Q&A-mode (`qa_model`) documents.
                      type: string
                    attachment_ids:
                      description: Attachment file IDs.
                      items:
                        type: string
                      type: array
                    content:
                      description: Chunk text content.
                      type: string
                    enabled:
                      description: Whether the chunk is enabled.
                      type: boolean
                    keywords:
                      description: Keywords for the chunk.
                      items:
                        type: string
                      type: array
                    regenerate_child_chunks:
                      default: false
                      description: Whether to regenerate child chunks.
                      type: boolean
                    summary:
                      description: Summary content for summary index.
                      nullable: true
                      type: string
                  type: object
              required:
                - segment
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                success:
                  summary: Response Example
                  value:
                    data:
                      answer: ''
                      attachments: []
                      child_chunks: []
                      completed_at: 1741267200
                      content: Dify is an open-source LLM app development platform.
                      created_at: 1741267200
                      created_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                      disabled_at: null
                      disabled_by: null
                      document_id: a8e0e5b5-78c6-4130-a5ce-25feb0e0b4ac
                      enabled: true
                      error: null
                      hit_count: 0
                      id: f3d1c7be-9f3a-40d8-8eb8-3a1ef9c3f2c1
                      index_node_hash: abc123def456
                      index_node_id: a1b2c3d4-e5f6-7890-abcd-000000000001
                      indexing_at: 1741267200
                      keywords:
                        - dify
                        - platform
                        - llm
                      position: 1
                      sign_content: ''
                      status: completed
                      stopped_at: null
                      summary: null
                      tokens: 12
                      updated_at: 1741267200
                      updated_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                      word_count: 9
                    doc_form: text_model
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/Segment'
                  doc_form:
                    description: Document chunking mode used by this document.
                    type: string
                type: object
          description: Chunk updated successfully.
        '400':
          content:
            application/json:
              examples:
                invalid_param_state:
                  summary: invalid_param (state)
                  value:
                    code: invalid_param
                    message: Segment is indexing, please try again later
                    status: 400
                provider_not_initialize:
                  summary: provider_not_initialize
                  value:
                    code: provider_not_initialize
                    message: >-
                      No Embedding Model available. Please configure a valid
                      provider in the Settings -> Model Provider.
                    status: 400
          description: >-
            - `provider_not_initialize` : The knowledge base uses high-quality
            indexing but its embedding model is missing or misconfigured.

            - `invalid_param` : The chunk is indexing or disabled and cannot be
            updated, or index configuration is invalid.
        '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 (vector space)
                  value:
                    code: forbidden
                    message: >-
                      The capacity of the vector space has reached the limit of
                      your subscription.
                    status: 403
                forbidden_3:
                  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` : Dataset api access is not enabled.

            - `forbidden` : The capacity of the vector space has reached the
            limit of your subscription.

            - `forbidden` : Sorry, you have reached the knowledge base request
            rate limit of your subscription.
        '404':
          content:
            application/json:
              examples:
                not_found_1:
                  summary: not_found
                  value:
                    code: not_found
                    message: Dataset not found.
                    status: 404
                not_found_2:
                  summary: not_found
                  value:
                    code: not_found
                    message: Document not found.
                    status: 404
                not_found_3:
                  summary: not_found
                  value:
                    code: not_found
                    message: Segment not found.
                    status: 404
          description: |-
            - `not_found` : Dataset not found.
            - `not_found` : Document not found.
            - `not_found` : Segment not found.
        '503':
          content:
            application/json:
              examples:
                service_unavailable:
                  summary: service_unavailable
                  value:
                    code: service_unavailable
                    message: >-
                      Unable to verify vector space usage right now. Please try
                      again later.
                    status: 503
          description: >-
            `service_unavailable` : Vector space usage could not be verified.
            Returned on the Dify Cloud Sandbox plan only; retry the request
            later.
components:
  schemas:
    Segment:
      properties:
        answer:
          description: Answer content, used in Q&A mode documents.
          type: string
        attachments:
          description: Files attached to this chunk.
          items:
            properties:
              extension:
                description: File extension.
                type: string
              id:
                description: Attachment file identifier.
                type: string
              mime_type:
                description: MIME type of the file.
                type: string
              name:
                description: Original file name.
                type: string
              size:
                description: File size in bytes.
                type: integer
              source_url:
                description: URL to access the attachment.
                type: string
            type: object
          type: array
        child_chunks:
          description: >-
            Child chunks belonging to this chunk. Only present for hierarchical
            mode documents.
          items:
            $ref: '#/components/schemas/ChildChunk'
          type: array
        completed_at:
          description: Timestamp when indexing completed. `null` if not yet completed.
          nullable: true
          type: number
        content:
          description: Text content of the chunk.
          type: string
        created_at:
          description: Creation timestamp (Unix epoch in seconds).
          type: number
        created_by:
          description: ID of the user who created the chunk.
          type: string
        disabled_at:
          description: Timestamp when the chunk was disabled. `null` if enabled.
          nullable: true
          type: number
        disabled_by:
          description: ID of the user who disabled the chunk. `null` if enabled.
          nullable: true
          type: string
        document_id:
          description: ID of the document this chunk belongs to.
          type: string
        enabled:
          description: Whether the chunk is enabled for retrieval.
          type: boolean
        error:
          description: Error message if indexing failed. `null` when no error.
          nullable: true
          type: string
        hit_count:
          description: Number of times this chunk has been matched in retrieval queries.
          type: integer
        id:
          description: Unique identifier of the chunk.
          type: string
        index_node_hash:
          description: Hash of the indexed content, used to detect changes.
          type: string
        index_node_id:
          description: ID of the index node in the vector store.
          type: string
        indexing_at:
          description: Timestamp when indexing started. `null` if not yet started.
          nullable: true
          type: number
        keywords:
          description: Keywords associated with this chunk for keyword-based retrieval.
          items:
            type: string
          type: array
        position:
          description: Position of the chunk within the document.
          type: integer
        sign_content:
          description: Signed content hash for integrity verification.
          type: string
        status:
          description: >-
            Current indexing status of the chunk, e.g. `completed`, `indexing`,
            `error`.
          type: string
        stopped_at:
          description: Timestamp when indexing was stopped. `null` if not stopped.
          nullable: true
          type: number
        summary:
          description: >-
            AI-generated summary of the chunk content. `null` if summary
            indexing is not enabled.
          nullable: true
          type: string
        tokens:
          description: Token count of the chunk content.
          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 chunk.
          type: string
        word_count:
          description: Word count of the chunk content.
          type: integer
      type: object
    ChildChunk:
      properties:
        content:
          description: Text content of the child chunk.
          type: string
        created_at:
          description: Creation timestamp (Unix epoch in seconds).
          type: number
        id:
          description: Unique identifier of the child chunk.
          type: string
        position:
          description: Position of the child chunk within the parent chunk.
          type: integer
        segment_id:
          description: ID of the parent chunk this child chunk belongs to.
          type: string
        type:
          description: >-
            How the child chunk was created. Child chunks created or updated
            through the API are always `customized`. System-generated child
            chunks are `automatic`.
          type: string
        updated_at:
          description: Last update timestamp (Unix epoch in seconds).
          type: number
        word_count:
          description: Word count of the child chunk content.
          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

````