[API] Add metadata parameter support to /create-by-text and /create-by-file endpoints #14413

Closed
opened 2026-02-21 19:17:07 -05:00 by yindo · 2 comments
Owner

Originally created by @estebanrestoyagicap on GitHub (Jun 4, 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 this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

I want to be able to create documents with API requests and add metadata to each document when created using these routes:

  • /datasets/{dataset_id}/document/create-by-text
  • /datasets/{dataset_id}/document/create-by-file

This functionality was previously available using the metadata_type parameter. I need to know how to include metadata fields when creating documents through these API endpoints, so I can associate additional information (like source, author, category, tags, etc.) with each document in the knowledge base.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @estebanrestoyagicap on GitHub (Jun 4, 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 this 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. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. I want to be able to create documents with API requests and add metadata to each document when created using these routes: - `/datasets/{dataset_id}/document/create-by-text` - `/datasets/{dataset_id}/document/create-by-file` This functionality was previously available using the `metadata_type` parameter. I need to know how to include metadata fields when creating documents through these API endpoints, so I can associate additional information (like source, author, category, tags, etc.) with each document in the knowledge base. ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 19:17:07 -05:00
yindo closed this issue 2026-02-21 19:17:07 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 4, 2025):

Hi @estebanrestoyagicap! I'm Dosu and I’m helping the dify team.

Currently, the /create-by-text and /create-by-file API endpoints do not support passing metadata or metadata_type parameters directly when creating documents. The implementation of these endpoints only accepts parameters like name, text, process_rule, doc_form, doc_language, and indexing_technique, but not metadata fields such as source, author, category, or tags (source).

For the /create-by-file endpoint, there is a workaround discussed in this GitHub issue: you can include a data field in your multipart/form-data request body, which allows you to pass some configuration as a JSON string. However, this is currently limited to fields like indexing_technique and process_rule, not arbitrary metadata.

If you need to associate metadata with documents (such as source, author, category, or tags), you will need to use a separate metadata update API after the document is created. The expected JSON structure for updating metadata is described in this issue: you should send an operation_data array with document_id and metadata_list fields, where each metadata entry includes id, value, and name.

At this time, there is no direct way to include custom metadata at document creation via these endpoints. If you need further details on updating metadata after creation, let me know.

To reply, just mention my name @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 4, 2025): <!-- Greeting --> Hi @estebanrestoyagicap! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> Currently, the /create-by-text and /create-by-file API endpoints do not support passing metadata or metadata_type parameters directly when creating documents. The implementation of these endpoints only accepts parameters like name, text, process_rule, doc_form, doc_language, and indexing_technique, but not metadata fields such as source, author, category, or tags ([source](https://github.com/langgenius/dify/blob/d22c351221522ed095d02636ac0f7f5aa1286524/api/controllers/service_api/dataset/document.py)). For the /create-by-file endpoint, there is a workaround discussed in [this GitHub issue](https://github.com/langgenius/dify/issues/20307): you can include a data field in your multipart/form-data request body, which allows you to pass some configuration as a JSON string. However, this is currently limited to fields like indexing_technique and process_rule, not arbitrary metadata. If you need to associate metadata with documents (such as source, author, category, or tags), you will need to use a separate metadata update API after the document is created. The expected JSON structure for updating metadata is described in [this issue](https://github.com/langgenius/dify/issues/18015): you should send an operation_data array with document_id and metadata_list fields, where each metadata entry includes id, value, and name. At this time, there is no direct way to include custom metadata at document creation via these endpoints. If you need further details on updating metadata after creation, let me know. <!-- Dosu Comment Footer --> *To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/975a2db8-4f11-4183-a6dc-16e055bef78a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/975a2db8-4f11-4183-a6dc-16e055bef78a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/975a2db8-4f11-4183-a6dc-16e055bef78a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/975a2db8-4f11-4183-a6dc-16e055bef78a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/975a2db8-4f11-4183-a6dc-16e055bef78a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/975a2db8-4f11-4183-a6dc-16e055bef78a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/975a2db8-4f11-4183-a6dc-16e055bef78a?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/20649)
Author
Owner

@rgvcorley commented on GitHub (Sep 24, 2025):

Isn't metadata pretty important, why wouldn't we be able to add or modify it via the API?

@rgvcorley commented on GitHub (Sep 24, 2025): Isn't metadata pretty important, why wouldn't we be able to add or modify it via the API?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#14413