/datasets/{dataset_id}/document/create-by-fileCreate Document by File
Creates a document in a knowledge base from an uploaded file. Common formats such as PDF, TXT, and DOCX are supported. Indexing runs asynchronously; track it with the returned batch ID via Get Document Indexing Status.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
5 documented failures
filename_not_exists_errorThe specified filename does not exist.
filename_not_exists_error
invalid_paramExternal datasets are not supported.
invalid_param (external)
no_file_uploadedPlease upload your file.
no_file_uploaded
provider_not_initializeNo valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials.
provider_not_initialize
too_many_filesOnly one file is allowed.
too_many_files
One documented failure
forbiddenDataset api access is not enabled.
forbidden (api access)
One documented failure
not_foundDataset not found.
not_found
One documented failure
file_too_largeFile size exceeded.
file_too_large
One documented failure
service_unavailableUnable to verify vector space usage right now. Please try again later.
service_unavailable
A 400 is returned: - no_file_uploaded : No file was provided in the request.
too_many_files: Only one file is allowed per request.filename_not_exists_error: The uploaded file has no filename.provider_not_initialize: The workspace has no default embedding model, or the default one has no credentials configured.invalid_param: The knowledge base is external,indexing_techniqueis required, orprocess_ruleis missing. A 403 is returned: -forbidden: Knowledge base API access is not enabled.forbidden: The capacity of the vector space has reached the limit of your subscription.forbidden: The number of documents has reached the limit of your subscription.forbidden: Sorry, you have reached the knowledge base request rate limit of your subscription.forbidden: The API key is scoped to specific knowledge bases, and this knowledge base is not one of them. A 404 is returned:not_found: Knowledge base not found. A 413 is returned:file_too_large: The uploaded file exceeds the maximum size. A 503 is returned:service_unavailable: Vector space usage could not be verified. Returned on the Dify Cloud Sandbox plan only; retry the request later.