---
title: "Update Document by Text"
method: POST
path: "/datasets/{dataset_id}/documents/{document_id}/update-by-text"
tags: ["Documents"]
---

# Update Document by Text

`POST /datasets/{dataset_id}/documents/{document_id}/update-by-text`

Updates a document's text content, name, or processing configuration. Re-indexes the document when its text changes.

## Path parameters

- `dataset_id` string, uuid, required
- `document_id` string, uuid, required

## Request body

- object
  - `name` string — Document name. Required when `text` is provided.
  - `text` string — Document text content.
  - `process_rule` object — Processing rules for chunking.
    - `mode` 'automatic' | 'custom' | 'hierarchical', required — `automatic` uses built-in rules, `custom` allows manual configuration, `hierarchical` enables parent-child chunk structure (use with `doc_form: hierarchical_model`).
    - `rules` object
      - `pre_processing_rules` object[]
        - `id` 'remove_stopwords' | 'remove_extra_spaces' | 'remove_urls_emails' — Rule identifier.
        - `enabled` boolean — Whether this preprocessing rule is enabled.
      - `segmentation` object
        - `separator` string — Custom separator for splitting text.
        - `max_tokens` integer — Maximum token count per chunk.
        - `chunk_overlap` integer — Token overlap between chunks.
  - `doc_form` 'text_model' | 'hierarchical_model' | 'qa_model' — `text_model` for standard text chunking, `hierarchical_model` for parent-child chunk structure, `qa_model` for question-answer pair extraction.
  - `doc_language` string — Language of the document for processing optimization.
  - `retrieval_model` RetrievalModel
    - `search_method` 'keyword_search' | 'semantic_search' | 'full_text_search' | 'hybrid_search', required — Search method used for retrieval.
    - `reranking_enable` boolean, required — Whether reranking is enabled.
    - `reranking_model` object — Reranking model configuration.
      - `reranking_provider_name` string — 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`.
      - `reranking_model_name` string — Name of the reranking model.
    - `reranking_mode` 'reranking_model' | 'weighted_score', nullable — Reranking mode. Required when `reranking_enable` is `true`.
    - `top_k` integer, required — Maximum number of results to return.
    - `score_threshold_enabled` boolean, required — Whether score threshold filtering is enabled.
    - `score_threshold` number, nullable — Minimum similarity score for results. Only effective when `score_threshold_enabled` is `true`.
    - `weights` object, nullable — Weight configuration for hybrid search.
      - `weight_type` 'semantic_first' | 'keyword_first' | 'customized' — Strategy for balancing semantic and keyword search weights.
      - `vector_setting` object — Semantic search weight settings.
        - `vector_weight` number — Weight assigned to semantic (vector) search results.
        - `embedding_provider_name` string — Provider of the embedding model used for vector search.
        - `embedding_model_name` string — Name of the embedding model used for vector search.
      - `keyword_setting` object — Keyword search weight settings.
        - `keyword_weight` number — Weight assigned to keyword search results.
    - `metadata_filtering_conditions` object, nullable — Restrict retrieval to chunks whose document metadata matches the given conditions. Conditions are evaluated server-side against document metadata fields.
      - `logical_operator` 'and' | 'or', nullable — How to combine multiple conditions.
      - `conditions` object[], nullable — List of metadata conditions to evaluate.
        - `name` string, required — Metadata field name to compare against.
        - `comparison_operator` 'contains' | 'not contains' | 'start with' | 'end with' | 'is' | 'is not' | 'empty' | 'not empty' | 'in' | 'not in' | '=' | '≠' | '>' | '<' | '≥' | '≤' | 'before' | 'after', required — 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`
        - `value` union — 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`.
          - string
          - string[]
          - number

## Response `200`

Document updated successfully.

- object
  - `document` Document
    - `id` string — Unique identifier of the document.
    - `position` integer — Display position of the document in the list.
    - `data_source_type` string — How the document was created. `upload_file` for file uploads, `notion_import` for Notion imports.
    - `data_source_info` object — Raw data source information, varies by `data_source_type`.
    - `data_source_detail_dict` object — Detailed data source information including file details.
    - `dataset_process_rule_id` string — ID of the processing rule applied to this document.
    - `name` string — Document name.
    - `created_from` string — Origin of the document. `api` for API creation, `web` for UI creation.
    - `created_by` string — ID of the user who created the document.
    - `created_at` number — Creation timestamp (Unix epoch in seconds).
    - `tokens` integer — Total number of tokens in the document.
    - `indexing_status` string — Current indexing status. `waiting` for queued, `parsing` while extracting content, `cleaning` while removing noise, `splitting` while chunking, `indexing` while building vectors, `completed` when ready, `error` if failed, `paused` if manually paused.
    - `error` string, nullable — Error message if indexing failed. `null` when no error.
    - `enabled` boolean — Whether the document is enabled for retrieval.
    - `disabled_at` number, nullable — Timestamp when the document was disabled. `null` if enabled.
    - `disabled_by` string, nullable — ID of the user who disabled the document. `null` if enabled.
    - `archived` boolean — Whether the document is archived.
    - `display_status` string — User-facing display status derived from `indexing_status` and `enabled` state.
    - `word_count` integer — Total word count of the document.
    - `hit_count` integer — Number of times the document has been matched in retrieval queries.
    - `doc_form` string — Document chunking mode. `text_model` for standard text chunking, `hierarchical_model` for parent-child structure, `qa_model` for QA pair extraction.
    - `doc_metadata` object[] — Metadata values assigned to this document.
      - `id` string — Metadata field identifier.
      - `name` string — Metadata field name.
      - `type` string — Metadata field value type.
      - `value` string — Metadata value for this document.
    - `summary_index_status` string, nullable — Status of the summary index for this document. `null` if summary indexing is not configured.
    - `need_summary` boolean — Whether a summary needs to be generated for this document.
  - `batch` string — Batch ID for tracking indexing progress.

## Other responses

- `400` — - `provider_not_initialize` : No model provider credentials are configured for the workspace. - `invalid_param` : `name` is required when `text` is provided, or `doc_form` is invalid. - `invalid_param` : The document is not available for update (only available documents can be updated).
- `403` — - `forbidden` : Knowledge base 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` — - `not_found` : Knowledge base not found. - `not_found` : Document not found.

---

[API](https://skmtc.net/langgenius/apis/dify-service-api.md) · [All operations](https://skmtc.net/langgenius/apis/dify-service-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/langgenius/dify-service-api/versions/361dc12484f4/schema)
