How to add a child chunk to a parent chunk via API? #8209

Closed
opened 2026-02-21 18:24:30 -05:00 by yindo · 5 comments
Owner

Originally created by @JoeNEGG on GitHub (Feb 12, 2025).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

Dify version

0.15.3

Question

How to add a child chunk to a parent chunk via API? The UI provides this functionality, but I couldn't find the corresponding API.

For example, like this:
HTTP POST /v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks

Originally created by @JoeNEGG on GitHub (Feb 12, 2025). ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Provide a description of requested docs changes ### Dify version 0.15.3 ### Question How to add a child chunk to a parent chunk via API? The UI provides this functionality, but I couldn't find the corresponding API. For example, like this: HTTP POST **/v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks**
yindo added the 🙋‍♂️ question label 2026-02-21 18:24:30 -05:00
yindo closed this issue 2026-02-21 18:24:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 12, 2025):

Hey @JoeNEGG! 👋 I'm here to help you with any bugs, questions, or contributions. I'll assist you while waiting for a human maintainer.

To add a child chunk to a parent chunk via the API, you can use an HTTP POST request to the endpoint /v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks. Here's how you can structure your request:

POST /v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks HTTP/1.1
Host: your-api-host.com
Content-Type: application/json
Authorization: Bearer your_access_token

{
    "content": "Your child chunk content here"
}

Make sure to replace {dataset_id}, {document_id}, {segment_id}, your-api-host.com, and your_access_token with the appropriate values for your use case. The "content" field in the JSON body is required and should contain the content of the child chunk you want to add [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other | Bug Report

@dosubot[bot] commented on GitHub (Feb 12, 2025): <!-- Greeting --> Hey @JoeNEGG! 👋 I'm here to help you with any bugs, questions, or contributions. I'll assist you while waiting for a human maintainer. <!-- Answer --> To add a child chunk to a parent chunk via the API, you can use an HTTP POST request to the endpoint **/v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks**. Here's how you can structure your request: ```http POST /v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks HTTP/1.1 Host: your-api-host.com Content-Type: application/json Authorization: Bearer your_access_token { "content": "Your child chunk content here" } ``` Make sure to replace `{dataset_id}`, `{document_id}`, `{segment_id}`, `your-api-host.com`, and `your_access_token` with the appropriate values for your use case. The "content" field in the JSON body is required and should contain the content of the child chunk you want to add <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/controllers/console/datasets/datasets_segments.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/cd2fda6f-b65d-4e4a-8d91-fb324f7083fe?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/cd2fda6f-b65d-4e4a-8d91-fb324f7083fe?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/cd2fda6f-b65d-4e4a-8d91-fb324f7083fe?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/cd2fda6f-b65d-4e4a-8d91-fb324f7083fe?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cd2fda6f-b65d-4e4a-8d91-fb324f7083fe?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/cd2fda6f-b65d-4e4a-8d91-fb324f7083fe?feedback_type=other) | [Bug Report](https://app.dosu.dev/response-feedback/cd2fda6f-b65d-4e4a-8d91-fb324f7083fe?feedback_type=bug_report)</sup>
Author
Owner

@JoeNEGG commented on GitHub (Feb 12, 2025):

I tried using this URL /v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks, but I got a 404 error.
<!doctype html>

<html lang=en>

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

However, the Dify UI uses the endpoint HTTP POST /console/api/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks, which works. However, the endpoint used by the UI uses a different auth token, which is not compatible with the API.

@JoeNEGG commented on GitHub (Feb 12, 2025): I tried using this URL **/v1/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks**, but I got a 404 error. <!doctype html> <html lang=en> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p> However, the Dify UI uses the endpoint HTTP POST **/console/api/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks**, which works. However, the endpoint used by the UI uses a different auth token, which is not compatible with the API.
Author
Owner

@crazywoola commented on GitHub (Feb 12, 2025):

This is not yet available. child_chunks . For questions, please use discussion instead.

@crazywoola commented on GitHub (Feb 12, 2025): This is not yet available. `child_chunks `. For questions, please use discussion instead.
Author
Owner

@JoeNEGG commented on GitHub (Feb 12, 2025):

May I ask if there are any plans to provide this API?

@JoeNEGG commented on GitHub (Feb 12, 2025): May I ask if there are any plans to provide this API?
Author
Owner

@crazywoola commented on GitHub (Feb 12, 2025):

May I ask if there are any plans to provide this API?

Well, actually you can implement this feature if you have some spare time. We have several other topics needs to be done before releasing v1.0.0.

@crazywoola commented on GitHub (Feb 12, 2025): > May I ask if there are any plans to provide this API? Well, actually you can implement this feature if you have some spare time. We have several other topics needs to be done before releasing v1.0.0.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8209