/datastores/{id}/documents

Ingest a document into a given Datastore.

Ingestion is an asynchronous task. Returns a document id which can be used to track the status of the ingestion job through calls to the GET /datastores/{datastore_id}/documents/{document_id}/metadata API.

This id can also be used to delete the document through the DELETE /datastores/{datastore_id}/documents/{document_id} API.

file must be a PDF, HTML, DOC(X), PPT(X), PNG, JPG, or JPEG file. The filename must end with one of the following extensions: .pdf, .html, .htm, .mhtml, .doc, .docx, .ppt, .pptx, .png, .jpg, .jpeg.

post/datastores/{datastore_id}/documents

Request

  • Base URL
    https://api.contextual.ai/v1
  • URL
    https://api.contextual.ai/v1/datastores/{datastore_id}/documents
  • Auth
    HTTP bearer

Path parameters

datastore_idstring uuid required

Datastore ID of the datastore in which to ingest the document

Request body multipart/form-data

filestring binary required

File to ingest.

metadatastring

Metadata request in stringified JSON format. custom_metadata is a flat dictionary containing one or more key-value pairs, where each value must be a primitive type (str, bool, float, or int). The default maximum metadata fields that can be used is 15, contact support@contextual.ai if more is needed. The combined size of the metadata must not exceed 2 KB when encoded as JSON. The strings with date format must stay in date format or be avoided if not in date format. The custom_metadata.url or link field is automatically included in returned attributions during query time, if provided.

        **Example Request Body (as returned by `json.dumps`):**

        ```json
        "{{
        \"custom_metadata\": {{
            \"topic\": \"science\",
            \"difficulty\": 3
        }}
        }}"
        ```
configurationstring

Overrides the datastore's default configuration for this specific document. This allows applying optimized settings tailored to the document's characteristics without changing the global datastore configuration.

Response

Successful Response

idstring uuid required

ID of the document being ingested

Changes