iQ Suite - Docs
SDK ReferenceDocument RAG

Add Document

Add a new document to an existing index.

Description

The Add Document endpoint allows you to add a new document to an existing index. This is useful for updating your index with additional information without creating a new index.

Caution

Add Document method is an async process and our server will return with a task_id and check_status URL to check the status of your uploaded file.

We recommend using our webhooks to receive completed index_id or use our polling methods to wait till completion.

HTTP Request

POST /index/add-document

Authentication

All requests must include an Authorization header with a valid API key.

Headers

KeyValue
AuthorizationBearer YOUR_API_KEY
Content-Typemultipart/form-data

Request Body

  • index: The ID of the index to which the document will be added.
  • document: The file to upload.

Form Data

FieldTypeDescription
indexstringThe ID of the index
documentfile (binary)The document file to upload

Request Example

try:
    # Open the new document you want to add in binary read mode
    with open('document.pdf', 'rb') as file:
        # Send a request to add the document to the specified index
        response = client.add_document(
            index_id='your_index_id',      # Use the valid index_id obtained earlier
            document=file,                 # Pass the binary file object
            filename='document.pdf'        # Provide the filename
        )
        # Print the received Task ID to monitor progress
        print(f"Task ID: {response.data.task_id}")
except APIError as e:
    print(f"An error occurred while adding the document: {e}")

Response

Success

Status Code: 200 OK

Body:

{
    "data": {
        "message": "Index creation has started.",
        "task_id": "fe77e15c-17ce-4cec-aeb5-134645fb9d17",
        "check_status": "https://iqsuite.ai/api/v1/create-index/task-status/fe77e15c-17ce-4cec-aeb5-134645fb9d17"
    }
}

Need Help?

On this page