Create Document

Create Document

This method allows you to upload a document to an index.

If the document is accepted by the API, the system will automatically trigger an indexing to process the document and add its document chunks to the index. To check the indexing progress and status, you can use the methods for listing documents or retrieving the document by its ID.

Once the indexing of the uploaded document is complete, only the document metadata and any embedded chunks are stored. The original, uploaded document is deleted.

Note that you can only upload documents to an index for a knowledge base that was created with data_origin_type=LOCAL_FILES. For details, refer to the method to Create a new knowledge base.

Request
URI
POST
https://{api_host}/api/v1/control/knowledge-bases/{knowledge_base_id}/indexes/{index_id}/documents
COPY
Path Parameters
string
knowledge_base_id
Required

knowledge_base_id

string
index_id
Required

index_id


Request Body
Body_createDocument of type(s) multipart/form-data
Required
{
    "file": "string"
}
string As binary As binary
file
Required

file

Authentication
This operation uses the following authentication methods.
Responses
201

Successful Response

Returns Document of type(s) application/json
"Document Object"
string
origin_name
Optional
Constraints: maxLength: 256

Name of the original document, if one was provided during indexing.

string
origin_ref
Optional
Constraints: maxLength: 256

Link to the original document, if one was available during indexing.

string As uuid As uuid
id
Required

ID of the document.

string
object
Optional
Constraints: default: document

Object type, which is always document.

state
Optional

Indexing state of the document.

media_type
Optional

Media type detected for the document.

string As uuid As uuid
knowledge_base_id
Required

ID of the Knowledge Dase of the document.

string As uuid As uuid
index_id
Required

ID of the index.

string As uuid As uuid
data_source_id
Optional

ID of the data source from which the document originates (if backed by a data source).

integer
created_at
Required

Unix timestamp (in seconds) when the document was added to the index.

integer
last_embedded_at
Required

Unix timestamp (in seconds) when the document was last embedded in the index.

string As uuid As uuid
last_indexed_by_id
Optional

Most recent indexing job affecting this document. Updated once the state of this indexing becomes INDEXED.

integer
size_bytes
Optional
Constraints: minimum: 0 default: 0

Size in bytes of the document.

string
hash_sha256
Optional

SHA256 hash of the document.

boolean
reindexing_needed
Required

If set, the document embeddings require an indexing to guarantee they are in sync with any updates from the data source.


400

Cannot upload a document to knowledge base configured with a data_origin_type=DATA_SOURCES.

Operation doesn't return any data structure

404

Invalid knowledge base ID.

Operation doesn't return any data structure

409

A document with this file name already existsin this knowledge base.

Operation doesn't return any data structure

413

The uploaded file is too large. File size limit is 10.00 MiB.

Operation doesn't return any data structure

422

An empty file or unsupported extra parameters were supplied.

Operation doesn't return any data structure

500

The uploaded file could not be processed.

Operation doesn't return any data structure

Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: multipart/form-data' -d '{"file:"string"}' https://{api_host}/api/v1/control/knowledge-bases/{knowledge_base_id}/indexes/{index_id}/documents