# Knowledge base

## **Create knowledge base**

To create a knowledge base on ZBrain Builder, send a POST request to a given URL with their specific information. They ensure that the payload includes an optional description and the name of the knowledge base while confirming that the necessary headers are correctly incorporated.

* Request URL: **<https://api.zbrain.ai/contentms/api/knowledge-base>**
* Request method: **POST**
* Request payload:&#x20;
  1. name:  Knowledge Base Name
  2. description: Description (Optional)
  3. retrieval: Retrieval Object (Optional)
  4. searchMethod: Currently, we support only 'SEMANTIC\_SEARCH' (Optional)
  5. topK: Maximum number of chunks for similar context in App. (Optional)
  6. scoreThreshold: Adjust this value to filter search results based on relevance. (Optional)
  7. scoreThresholdEnabled: Value will be a boolean. (Optional)
* Request headers:
  1. Authorization: Bearer <\<API Key >>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="207">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>description</code></td><td>description about knowledge base</td></tr><tr><td><code>name</code></td><td>name to the knowledge base</td></tr></tbody></table>

* Sample request body payload:<br>

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "name": "KnowledgeBaseName",
      "description": "description",
       "retrieval": {
           "searchMethod": "SEMANTIC_SEARCH",
            "topK": 50,
            "scoreThresholdEnabled": false,
            "scoreThreshold": 0.1
       }
  }
  </code></pre>
* Code snippets:

{% tabs %}
{% tab title="Node Js" %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.zbrain.ai/contentms/api/knowledge-base',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "name": "Knowledgebase Name",
    "description": "description"
  })
};

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python " %}
{% code lineNumbers="true" %}

```python
import requests
import json

url = "https://api.zbrain.ai/contentms/api/knowledge-base"

payload = json.dumps({
    "name": "Knowledgebase Name",
    "description": "description",
})
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/contentms/api/knowledge-base' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API Key>' \
--data '{
    "name": "knowledgebase name",
    "description": "description"
}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": {
          "name": "string",
          "description": "string",
          "tenantId": "string",
          "createdBy": "string",
          "_id": "string",
          "addedOn": number,
          "modifiedOn": number
      },
      "message": "Knowledge base created successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

## Get knowledge bases

Using the provided ZBrain Builder API, users can easily fetch their knowledge base data. By sending a GET request to the given URL and adjusting the 'limit' and 'skip' parameters, users can tailor the amount of data retrieved and its starting point, simplifying access to their specific knowledge base content.

* Request URL: **<https://api.zbrain.ai/contentms/api/knowledge-bases?limit=10\\&skip=0>**
* Request method: **GET**
* Query strings:&#x20;
  1. skip: << numeric value >>
  2. limit: << numeric value >>
* Request headers:
  1. Authorization: Bearer <\<API key>>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="185">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>skip</code></td><td>Number of knowledge bases to skip</td></tr><tr><td><code>limit</code></td><td>Number of knowledge bases to listout</td></tr></tbody></table>

* Sample request query payload:<br>

  <pre data-line-numbers><code>?limit=10&#x26;skip=0
  </code></pre>
* Code snippets:

{% tabs %}
{% tab title="Node Js" %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.zbrain.ai/contentms/api/knowledge-bases?limit=10&skip=0',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python " %}
{% code lineNumbers="true" %}

```python
import requests

url = "https://api.zbrain.ai/contentms/api/knowledge-bases?limit=10&skip=0"

payload = {}
headers = {
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/contentms/api/knowledge-bases?limit=10&skip=0' \
--header 'Authorization: Bearer <API token>'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": {
          "data": [
              {
                  "_id": "string",
                  "name": "string",
                  "description": "string",
                  "tenantId": "string",
                  "createdBy": "string",
                  "addedOn": number,
                  "modifiedOn": number,
                  "importsExists": boolean
              }
          ],
          "total": number
      },
      "message": "Information fetched successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

## Get knowledge base by ID

* Request URL: **<https://api.zbrain.ai/contentms/api/knowledge-base/><*****knowledgeBaseId*****>**
* Request method: **GET**
* Path parameters:
  1. knowledgebaseId : << knowledgebaseId >>
* Request headers:
  1. Authorization: Bearer <\<API Key >>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="214">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>knowledgeBaseId</code></td><td>unique id (<code>_id</code>) of knowledge base (get it from the <a href="#get-knowledge-bases">Get knowledge bases</a> API)</td></tr></tbody></table>

* Sample path parameters:

  ```
  /knowledge-base/<knowledgeBaseId>
  ```
* Code snippets:

{% tabs %}
{% tab title="Node Js " %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.zbrain.ai/contentms/api/knowledge-base/<knowledgebaseId>',
  'headers': {
    'Authorization': 'Bearer <API token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python - Requests" %}
{% code lineNumbers="true" %}

```python
import requests

url = "https://api.zbrain.ai/contentms/api/knowledge-base/<knowledgebaseId>"

payload = {}
headers = {
  'Authorization': 'Bearer <API token>'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/contentms/api/knowledge-base/<knowledgebaseId>' \
--header 'Authorization: Bearer <API token>'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": {
          "_id": "string",
          "name": "string",
          "description": "string",
          "tenantId": "string",
          "createdBy": "string",
          "addedOn": number,
          "knowledgeBaseImports": [
              {
                  "title": "string",
                  "summary": "string",
                  "knowledgeBaseId": "string",
                  "importedType": "string",
                  "status": "string",
                  "file": {
                      "url": "string",
                      "path": "string",
                      "bucket": "string"
                  },
                  "document": {
                      "url": "string",
                      "path": "string",
                      "bucket": "string"
                  },
                  "visitedPages": ["string"],
                  "characters": number,
                  "chunksCount": number,
                  "_id": "string",
                  "addedOn": number,
                  "modifiedOn": number
              }
          ]
      },
      "message": "Information fetched successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

## **Knowledge base import creation types**

On ZBrain Builder, users have multiple options to create a knowledge base by importing information. They can import data from files such as PDF, TXT, CSV, DOCX, or XLSX, website links, or even through APIs. This approach enables users to gather and integrate relevant information into their knowledge base, feeding their AI applications with accurate and domain-specific data from diverse sources.

### **Using FILE**

ZBrain Builder allows users to create a knowledge base by importing files directly into the system using a specified API. Users can seamlessly import file types such as PDF, TXT, CSV, DOCX, or XLSX into their designated knowledge base by initiating a POST request to the provided URL, ensuring that the AI applications have direct access to the required domain-specific information.

* Request URL: **<https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=><*****knowledgeBaseId*****>\&importType=FILE**
* Request method: **POST**
* Query string&#x73;**:**&#x20;
  1. knowledgeBaseId: << knowledgeBaseId >>
  2. importType: FILE
* Request headers:
  1. Authorization: Bearer <\<API Key >>&#x20;
  2. Content-Type: application/json
* form data:&#x20;
  1. file : << select file (Supported formats : PDF, TXT, CSV, DOCX or XLSX)>>

<table><thead><tr><th width="206">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>knowledgeBaseId</code></td><td>unique id (<code>_id</code>) of knowledge base to where the file to be imported (get it from the <a href="#get-knowledge-bases">Get knowledge bases</a> Api)</td></tr><tr><td><code>importType</code></td><td>method of importing the content</td></tr><tr><td><code>file</code></td><td>in formdata user needs to select the file to be uploaded and these are the supported file formates PDF, TXT, CSV, DOCX or XLSX</td></tr></tbody></table>

* Sample request query strings:&#x20;

  <pre data-line-numbers><code>?knowledgeBaseId=&#x3C;knowledgeBaseId>&#x26;importType=FILE
  </code></pre>
* Code snippets:

{% tabs %}
{% tab title="Node Js " %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=FILE',
  'headers': {
      'Authorization': 'Bearer <API token>'
    },
  formData: {
    'file': {
      'value': fs.createReadStream('</path/to/file>'),
      'options': {
        'filename': '<file name>',
        'contentType': null
      }
    }
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python " %}
{% code lineNumbers="true" %}

```python
import requests

url = "https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=FILE"

payload = {}
files=[
  ('file',('fileName',open('/path/to/file','rb'),'application/pdf'))
]
headers = {
  'Authorization': 'Bearer <API token>'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=FILE' \
--header 'Authorization: Bearer <API token>' \
--form 'file=@"<path/to/file>"'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": [
          {
              "title": "string",
              "summary": "string",
              "knowledgeBaseId": "string",
              "importedType": "string",
              "status": "string",
              "file": {
                  "url": "string",
                  "path": "string",
                  "bucket": "string"
              },
              "document": {
                  "url": "string",
                  "path": "string",
                  "bucket": "string"
              },
              "visitedPages": ["string"],
              "characters": number,
              "chunksCount": number,
              "_id": "string",
              "input": object,
              "error": object,
              "addedOn": number,
              "modifiedOn": number,
              "charactersLimit": number
          }
      ],
      "message": "Knowledge base import added successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

### **Using website url**

When one seeks to construct a ZBrain Builder knowledge base using a website, they must employ a certain web address or API. This process involves providing necessary details such as the knowledge base's identification, the import type (in this instance, a website), and the desired number of pages for indexing. The interface allows indexing of up to 50 pages at a time, while the API supports large-scale indexing for greater flexibility. Including the website URL from which the knowledge base will be created is crucial. Additionally, they must authenticate their request with their API key.

* Request URL: **<https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=><*****knowledgeBaseId*****>\&importType=WEBSITE**
* Request method: **POST**
* Query string&#x73;**:**&#x20;
  1. knowledgeBaseId: << knowledgeBaseId >>
  2. importType: WEBSITE
* Request payload:
  1. numberOfPages: << No.of pages to index>>
  2. websiteUrl:<< URL >>
* Request headers:
  1. Authorization: Bearer <\<API Key>>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="221">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>knowledgeBaseId</code></td><td>unique id (<code>_id</code>)  of knowledge base to where the file to be imported (get it from the <a href="#get-knowledge-bases">Get knowledge bases</a> Api)</td></tr><tr><td><code>importType</code></td><td>method of importing the content</td></tr><tr><td><code>numberOfPages</code></td><td>no.of pages to index</td></tr><tr><td><code>websiteUrl</code></td><td>URL of the website</td></tr></tbody></table>

* Sample request body payload:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "numberOfPages": 4,
      "websiteUrl": "https://www.leewayhertz.com"
  }
  </code></pre>

* Sample request query payload:

  <pre data-line-numbers><code>?knowledgeBaseId=&#x3C;knowledgeBaseId>&#x26;importType=WEBSITE
  </code></pre>

* Code snippets:

{% tabs %}
{% tab title="Node Js " %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "numberOfPages": <No.of pages to index>,
    "websiteUrl": "<url>"
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endcode %}
{% endtab %}

{% tab title="Python " %}
{% code lineNumbers="true" %}

```python
import requests
import json

url = "https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE"

payload = json.dumps({
  "numberOfPages": <No.of pages to index>,
  "websiteUrl": "<url>"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/importms/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API token>' \
--data '{
    "numberOfPages":<No.of pages to index>,
    "websiteUrl":"<url>"
}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": {
          "title": "string",
          "summary": "string",
          "knowledgeBaseId": "string",
          "importedType": "string",
          "status": "string",
          "file": {
              "url": "string",
              "path": "string",
              "bucket": "string"
          },
          "document": {
              "url": "string",
              "path": "string",
              "bucket": "string"
          },
          "visitedPages": ["string"],
          "characters": number,
          "chunksCount": number,
          "_id": "string",
          "input": object,
          "error": object,
          "addedOn": number,
          "modifiedOn": number,
          "charactersLimit": number
      },
      "message": "Knowledge base import added successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

### **Using API**

When someone aims to construct a ZBrain Builder knowledge base utilizing an API, they send specific data to a ZBrain web address. The information comprises the type of activity (API), a title for their data, and the data content itself, which should span at least 100 characters. They also need to include their API key for security purposes.

* Request URL: **<https://api.zbrain.ai/importms/api/knowledge-base-import-by-api?importType=API>**
* Request method: **POST**
* Query string&#x73;**:**&#x20;
  1. importType: API
* Request headers:
  1. Authorization: Bearer <\<api key>>&#x20;
  2. Content-Type: application/json
* Request Payload:&#x20;
  1. title: \<Enter your file name>
  2. content: <\<Enter your content not less than 100 characters>>
  3. knowledgeBaseId : << knowledgeBaseId >>

<table><thead><tr><th width="215">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>importType</code></td><td>method of importing the content</td></tr><tr><td><code>title</code></td><td>title of the file</td></tr><tr><td><code>content</code></td><td>the content that will be uploaded to knowledge base and it should not be less than 100 characters</td></tr><tr><td><code>knowledgeBaseId</code></td><td>unique id (<code>_id</code>)  of knowledge base to where the file to be imported (get it from the<a href="#get-knowledge-bases"> Get knowledge bases</a> Api)</td></tr></tbody></table>

* Sample request body payload:&#x20;

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "title": "fileName",
      "content": "file content",
      "knowledgeBaseId": "knowledgeBaseId"
  }
  </code></pre>

**Note**: If knowledgeBaseId is empty, new knowledge base will be created. Otherwise, specified knowledge base will get updated.

* Sample request query payload:

  <pre data-line-numbers><code>?importType=API
  </code></pre>

* Code snippets:

{% tabs %}
{% tab title="Node Js " %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.zbrain.ai/importms/api/knowledge-base-import-by-api?importType=API',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "title": "<name>",
    "content": "<content>",
    "knowledgeBaseId": "<knowledgeBaseId>"
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endcode %}
{% endtab %}

{% tab title="Python " %}
{% code lineNumbers="true" %}

```python
import requests
import json

url = "https://api.zbrain.ai/importms/api/knowledge-base-import-by-api?importType=API"

payload = json.dumps({
  "title": "<name>",
  "content": "<content>",
  "knowledgeBaseId": "<knowledgeBaseId>"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/importms/api/knowledge-base-import-by-api?importType=API' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API token>' \
--data '{
    "title": "<name>",
    "content": "<content>",
    "knowledgeBaseId" :"<knowledgeBaseId>"
}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
    "responseData": {
      "title": "string",
      "summary": "string",
      "knowledgeBaseId": "string",
      "importedType": "string",
      "status": "string",
      "file": {
        "url": "string",
        "path": "string",
        "bucket": "string"
      },
      "document": {
        "url": "string",
        "path": "string",
        "bucket": "string"
      },
      "visitedPages": ["string"],
      "characters": number,
      "chunksCount": number,
      "_id": "string",
      "input": object,
      "error": object,
      "addedOn": number,
      "modifiedOn": number,
      "charactersLimit": number
    },
    "message": "Knowledge base import added successfully",
    "success": true,
    "responseCode": 200
  }
  </code></pre>

## Update knowledge base

When a user wishes to update an existing knowledge base in ZBrain Builder, they can utilize the following specific API, which sends a PUT request, along with their API key, to modify the knowledge base's name and description. Providing the correct knowledge base ID is important to ensure the updates are applied to the desired base.

* Request URL:  **<https://api.zbrain.ai/contentms/api/knowledge-base>**
* Request method: **PUT**
* Request payload:&#x20;
  1. description:  << Enter new description (optional)>>
  2. knowledgeBaseId: << knowledgeBaseId  >>
  3. name: << Enter new knowledge base name >>
  4. retrieval: Retrieval Object (Optional)
  5. searchMethod: Currently we support only 'SEMANTIC\_SEARCH' (Optional)
  6. topK: Maximum number of chunks for similar context in App. (Optional)
  7. scoreThreshold: Adjust this value to filter search results based on relevance. (Optional)
  8. scoreThresholdEnabled: Value will be boolean. (Optional)
* Request headers:
  1. Authorization: Bearer <\<API Key>>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="221">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>knowledgeBaseId</code></td><td>unique id (<code>_id</code>)  of knowledge base to where the file to be imported (get it from the <a href="#get-knowledge-bases">Get knowledge bases</a> Api)</td></tr><tr><td><code>name</code></td><td>knowledge base name</td></tr><tr><td><code>description</code></td><td>description about knowledge base</td></tr></tbody></table>

* Sample request body payload:&#x20;

{% code lineNumbers="true" %}

```json
{
    "knowledgeBaseId": "knowledgeBaseId",
    "name": "sample name",
    "description": "description",
    "retrieval": {
         "searchMethod": "SEMANTIC_SEARCH",
          "topK": 50,
          "scoreThresholdEnabled": false,
          "scoreThreshold": 0.1
    }
}
```

{% endcode %}

* Code snippets:

{% tabs %}
{% tab title="Node Js " %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'PUT',
  'url': ' https://api.zbrain.ai/contentms/api/knowledge-base',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "name": "<name>",
    "description": "<description>",
    "knowledgeBaseId": "<knowledgeBaseId>"
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python " %}
{% code lineNumbers="true" %}

```python
import requests
import json

url = " https://api.zbrain.ai/contentms/api/knowledge-base"

payload = json.dumps({
    "description": "<description>",
    "knowledgeBaseId": "<knowledgeBaseId>",
    "name": "<name>"
  })
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location --request PUT ' https://api.zbrain.ai/contentms/api/knowledge-base' \
--header 'Content-Type: application/json' \
--header 'Authorization': 'Bearer <API token>' \
--data '{
    "description": "<description>",
    "knowledgeBaseId": "<knowledgeBaseId>",
    "name": "<name>"
 }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": {
          "name": "string",
          "description": "string",
          "tenantId": "string",
          "createdBy": "string",
          "_id": "string",
          "addedOn": number,
          "modifiedOn": number
      },
      "message": "Information added successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

&#x20;

## Delete knowledge base

If a user wishes to delete a specific knowledge base in ZBrain Builder, the following API is used, which sends a DELETE request to the designated URL, including the knowledge base's unique ID in the path. The request must also contain its API key in the header for authorization.

* Request URL:  **<https://api.zbrain.ai/contentms/api/knowledge-base/\\><knowledgebaseId>**
* Request method: **DELETE**
* Path parameters:
  1. knowledgebaseId : << knowledgebaseId >>
* Request headers:
  1. Authorization: Bearer <\<API Key>>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="208">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>knowledgebaseId</code></td><td>unique id (<code>_id</code>)  of knowledge base to where the file to be imported (get it from the <a href="#get-knowledge-bases">Get knowledge bases</a> Api) (send this on path parameter)</td></tr></tbody></table>

* Code snippets:

{% tabs %}
{% tab title="Node Js - Request" %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': ' https://api.zbrain.ai/contentms/api/knowledge-base/<knowledgeBaseId>',
  'headers': {
    'Authorization': 'Bearer <API token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endcode %}
{% endtab %}

{% tab title="Python - Request" %}
{% code lineNumbers="true" %}

```python
import requests

url = " https://api.zbrain.ai/contentms/api/knowledge-base/<knowledgeBaseId>"

payload = {}
headers = {
  'Authorization': 'Bearer <API token>'
}

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location --request DELETE ' https://api.zbrain.ai/contentms/api/knowledge-base/<knowledgeBaseId>' \
--header 'Authorization': 'Bearer <API token>'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": "Knowledge base deleted successfully",
      "message": "Knowledge base deleted successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

## Delete import

If a user wishes to delete a specific knowledge base import in ZBrain Builder, the following API is used, which sends a DELETE request to the designated URL, including the knowledge base import's unique ID in the body. The request must also contain its API key in the header for authorization.

* Request URL:  **<https://api.zbrain.ai/contentms/api/knowledge-base-import>**
* Request method: **DELETE**
* Request payload:&#x20;
  1. ids:  << Array of knowledgeBaseImport Id's>>
* Request headers:
  1. Authorization: Bearer <\<API Key>>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="226">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td><code>ids</code></td><td>Array of knowledgeBaseImport unique Id's to be deleted, get these id's from the response of <a href="#get-knowledge-base-by-id">get knowledge base by id</a></td></tr></tbody></table>

* Sample request body payload:&#x20;

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "ids": [
          "knowledgeBaseImportId"
      ]
  }
  </code></pre>
* Code snippets:

{% tabs %}
{% tab title="Node Js - Request" %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': ' https://api.zbrain.ai/contentms/api/knowledge-base-import',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "ids": [
      "<knowledgeBaseId>",
      "<knowledgeBaseId>"
    ]
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endcode %}
{% endtab %}

{% tab title="Python - Request" %}
{% code lineNumbers="true" %}

```python
import requests
import json
url = " https://api.zbrain.ai/contentms/api/knowledge-base-import"
payload = json.dumps({
    "ids": [
      "<knowledgeBaseId>",
      "<knowledgeBaseId>"
    ]
  })
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location --request DELETE ' https://api.zbrain.ai/contentms/api/knowledge-base-import' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API token>' \
--data '{
    "ids":["<knowledgeBaseId>","<knowledgeBaseId>"]
}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:&#x20;

  <pre class="language-json" data-line-numbers><code class="lang-json">{
      "responseData": "Deleted successfully",
      "message": "Knowledge base import deleted successfully",
      "success": true,
      "responseCode": 200
  }
  </code></pre>

## Get import status

To get the status of the imports, send a GET request to the following URL with the specified query parameters. Ensure that the query payload includes the knowledge base import IDs and tenant IDs.

* Request URL: **<https://api.zbrain.ai/importms/v2/api/import>**
* Request method: **GET**
* Query strings:&#x20;
  1. **kbImportIds:** << A comma-separated list of identifiers for the knowledge base import jobs you want to check the status of >>
* Request headers:
  1. Authorization: Bearer <\<API key>>&#x20;
  2. Content-Type: application/json

<table><thead><tr><th width="185">Parameters</th><th> </th></tr></thead><tbody><tr><td><code>Authorization</code></td><td>Bearer API-Key (get it from settings > profile from <a href="https://app.zbrain.ai/settings/profile">https://app.zbrain.ai/settings/profile</a> )</td></tr><tr><td>kbImportIds</td><td>Knowledge Base Import Ids</td></tr></tbody></table>

* Code snippets:

{% tabs %}
{% tab title="Node Js" %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.zbrain.ai/importms/v2/api/import?kbImportIds=<id1,id2>',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests

url = "https://api.zbrain.ai/importms/v2/api/import?kbImportIds=<id1,id2>"

payload = {}
headers = {
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/importms/v2/api/import?kbImportIds=<id1,id2>' \
--header 'Authorization: Bearer <API token>'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

{% code lineNumbers="true" %}

```json
{
    "responseData": {
        "preview": [
            {
                "content": "",
                "metaData": {
                    "fileName": "",
                    "file": "",
                    "id": 0,
                    "hash": "",
                    "words": 0,
                    "isActive": true
                }
            }
        ],
        "status": "STAGED",
        "data": [
            {
                "title": "",
                "characters": 0,
                "chunksCount": 0,
                "paragraphsCount": 0,
                "avgParagraphsCount": 0,
                "chunkingRules": {
                    "mode": "",
                    "rules": {}
                },
                "status": "STAGED",
                "addedOn": 1714985786550
            },
        ]
    },
    "message": "",
    "success": true,
    "responseCode": 200
}
```

{% endcode %}

## **Create a new chunk in the knowledge base import** <a href="#create-a-new-chunk-in-the-knowledge-base-import" id="create-a-new-chunk-in-the-knowledge-base-import"></a>

To add a chunk to the knowledge base import, send a POST request to the given URL with the chunk's specific information. Ensure that the payload includes a knowledge base import ID, the content you want to add to the chunk while confirming that the necessary headers are correctly incorporated.

* Request URL: **<https://api.zbrain.ai/importms/v2/api/knowledge-base-import/chunk>**
* Request method: POST
* Request payload:
  * knowledgeBaseImportId:  << Enter knowledge base import's \_id, in which you want to add the chunk>>
  * content: << Add the text content that you want to add in the chunk  >>
* Request headers:
  * Authorization: Bearer <\<API Key>>
  * Content-Type: application/json
* Sample request body payload:

{% code lineNumbers="true" %}

```json
{  
    "knowledgeBaseImportId": "",
    "content": ""
}
```

{% endcode %}

Code snippets:

{% tabs %}
{% tab title="Node JS" %}

<pre class="language-javascript" data-line-numbers><code class="lang-javascript">var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.zbrain.ai/importms/v2/api/knowledge-base-import/chunk',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer &#x3C;API token>'
  },
  body: JSON.stringify({  
    "knowledgeBaseImportId": "",
    "content": ""
<strong>  })
</strong>};

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
</code></pre>

{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
import json

url = "https://api.zbrain.ai/importms/v2/api/knowledge-base-import/chunk"

payload = json.dumps({  
    "knowledgeBaseImportId": "",
    "content": ""
})
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location 'https://api.zbrain.ai/importms/v2/api/knowledge-base-import/chunk' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API Key>' \
--data '{  
    "knowledgeBaseImportId": "",
    "content": ""
}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

{% code lineNumbers="true" %}

```json
{
    "responseData": {
        "tenantId": "",
        "addedBy": "",
        "kbImportId": "",
        "content": "",
        "embeddings": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        }
    },
    "message": "Knowledge base import chunk added successfully",
    "success": true,
    "responseCode": 200
}
```

{% endcode %}

## **Custom chunking** <a href="#custom-chunking" id="custom-chunking"></a>

#### **Step 1: Add import** <a href="#step-1-add-import" id="step-1-add-import"></a>

To add content to a Knowledge Base in ZBrain Builder via API, users can use this endpoint. This API enables programmatic ingestion of documents by specifying a title and content body. In this step, the content is staged; it is stored within the specified Knowledge Base, but not yet processed for chunking or retrieval. Further processing (i.e., applying chunking strategies) must be initiated separately using the appropriate import-init API.

* Request URL: **<https://api.zbrain.ai/importms/v2/api/import>**
* Request method: POST
* Query parameters
  * importType=API
  * knowledgeBaseId=\<Knowledge\_Base\_ID>
* Request payload
  * **title:** <\<The title of the document you want to import into the Knowledge Base>>
  * **content:** <\<The full text content of the document>>
* Request headers
  * **Authorization:** Bearer \<Your\_API\_Key>
  * **Content-Type:** application/json
* Sample request payload

{% code lineNumbers="true" %}

```json
{
"title": "Sample Policy Document",
"content": "This is the full text of the policy document that needs to be indexed..." 
}
```

{% endcode %}

* **Code snippets**

{% tabs %}
{% tab title="Node Js" %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  method: 'POST',
  url: 'https://api.zbrain.ai/importms/v2/api/import',
  qs: {
    importType: 'API',
    knowledgeBaseId: '<KNOWLEDGE_BASE_ID>'
  },
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <YOUR_API_TOKEN>'
  },
  body: JSON.stringify({
    title: "Sample Policy Document",
    content: "This is the full text of the policy document that needs to be indexed..."
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
import json
url = "https://api.zbrain.ai/importms/v2/api/import"
params = {
    "importType": "API",
    "knowledgeBaseId": "<KNOWLEDGE_BASE_ID>"
}
payload = {
    "title": "Sample Policy Document",
    "content": "This is the full text of the policy document that needs to be indexed..."
}
headers = {
    "Authorization": "Bearer <YOUR_API_TOKEN>",
    "Content-Type": "application/json"
}
response = requests.post(url, headers=headers, params=params, data=json.dumps(payload))
print(response.status_code)
print(response.json())
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl -X POST 'https://api.zbrain.ai/importms/api/import?importType=API&knowledgeBaseId=<KNOWLEDGE_BASE_ID>' \
  -H 'Authorization: Bearer <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "title": "Sample Policy Document",
    "content": "This is the full text of the policy document that needs to be indexed..."
}'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* **Sample response**

{% code lineNumbers="true" %}

```json
{
  {
    "responseData": {
      "kbImportIds": [
        "6836a63ce9f28ecb8e9aa0f3"
      ],
      "status": "STAGED"
    },
    "message": "Process started successfully",
    "success": true,
    "responseCode": 200
  }
}
```

{% endcode %}

#### **Step 2: Apply custom chunking** <a href="#step-2-apply-custom-chunking" id="step-2-apply-custom-chunking"></a>

To apply a custom chunking strategy to the staged content, users can initiate the import processing step using this API. This allows you to precisely control how the content is segmented by configuring parameters such as chunk size, overlap, and text separators. Setting the mode to "CUSTOM" gives you full flexibility over how the document is structured for semantic search and retrieval. During this process, embeddings are generated, enabling the system to semantically index and match content. This API does not upload new content; instead, it processes documents that have already been staged, using the defined chunking rules.

* Request URL: **<https://api.zbrain.ai/importms/v2/api/import-init>**
* Request method: **POST**
* Query parameters:
  * importType=API
  * knowledgeBaseId=\<knowledgeBaseId>
* Request payload
  * **tenantId**: << Enter the tenant ID associated with your ZBrain account >>
  * **kbImportIds**: << IDs of the staged document(s) for which chunking is to be applied >>
  * **chunkingRules**: << Rules that define how the text is chunked >>
  * **mode**: << Chunking mode — set to "CUSTOM" for manual chunk configuration >>
  * **chunkSize**: << Enter the maximum number of characters per chunk >>
  * **separator**: << Enter the character or pattern used to split content (e.g., \n, \t) >>
  * **chunkOverlap**: << Enter the number of overlapping characters between chunks to preserve context >>
* Request headers
  * Authorization: Bearer \<API Key>
  * Content-Type: application/json
* Sample request payload

```json
{
  "tenantId": "6628c196301afe0024fbf181",
  "kbImportIds": ["684abe5ba1ee2f1473ffe588", "682f27aba98297373f9e2b4d"],
  "chunkingRules": {
    "mode": "CUSTOM",
    "rules": {
      "segmentation": {
        "chunkSize": 20000,
        "separator": "\n",
        "chunkOverlap": 200
      }
    }
  }
}

```

* Code snippets

{% tabs %}
{% tab title="Node Js" %}
{% code lineNumbers="true" %}

```java
var request = require('request');
var options = {
  method: 'POST',
  url: 'https://api.zbrain.ai/importms/v2/api/import-init',
  qs: {
    importType: 'API',
    knowledgeBaseId: '<knowledgeBaseId>'
  },
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    tenantId: '<tenantId>',
    kbImportIds: ["<knowledgeBaseImportId>", "<knowledgeBaseImportId>"],
    chunkingRules: {
      mode: 'CUSTOM',
      rules: {
        segmentation: {
          chunkSize: <CHUNK_SIZE>,
          separator: '\n',
          chunkOverlap: <CHUNK_SIZE>
        }
      }
    }
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
import json
url = "https://api.zbrain.ai/importms/v2/api/import-init"
params = {
    "importType": "API",
    "knowledgeBaseId": "<knowledgeBaseId>"
}
payload = {
    "tenantId": "<tenantId>",
    "kbImportIds": ["<knowledgeBaseImportId>", "<knowledgeBaseImportId>"],
    "chunkingRules": {
        "mode": "CUSTOM",
        "rules": {
            "segmentation": {
                "chunkSize": <CHUNK_SIZE>,
                "separator": "\n",
                "chunkOverlap": <CHUNK_OVERLAP>
            }
        }
    }
}
headers = {
    "Authorization": "Bearer <API token>",
    "Content-Type": "application/json"
}
response = requests.post(url, headers=headers, params=params, data=json.dumps(payload))
print(response.status_code)
print(response.json())
```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl -X POST 'https://api.zbrain.ai/importms/v2/api/import-init?importType=API&knowledgeBaseId=<knowledgeBaseId>' \
  -H 'Authorization: Bearer <API token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "tenantId": "<tenantId>",
    "kbImportIds": ["<knowledgeBaseImportId>", "<knowledgeBaseImportId>"],
    "chunkingRules": {
      "mode": "CUSTOM",
      "rules": {
        "segmentation": {
          "chunkSize": <CHUNK_SIZE>,
          "separator": "\n",
          "chunkOverlap": <CHUNK_OVERLAP>
        }
      }
    }
  }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response

{% code lineNumbers="true" %}

```json
{
  "responseData": "Process started",
  "message": "Process started successfully",
  "success": true,
  "responseCode": 200
}
```

{% endcode %}

## **Update metadata of knowledge base import** <a href="#update-metadata-of-knowledge-base-import" id="update-metadata-of-knowledge-base-import"></a>

To update the metadata of a knowledge base import, send a PATCH request to the following URL with the specified information. Ensure that the payload includes the knowledge base import ID, metadata details, and the isEnabled status.

* Request URL:  **<https://api.zbrain.ai/contentms/v2/api/knowledge-base-import>**
* Request method: PATCH
* Request headers:
  * Authorization: Bearer <\<API Key>>
  * Content-Type: application/json
* Request payload:
  * knowledgeBaseImportId: << Enter the unique identifier of the knowledge base import you want to update >>
  * metadata: << An object containing the metadata fields you want to modify >>
  * title: << The title of the knowledge base import >>
  * author: << The author of the content within the import >>
  * documentType: << The type of document(s) included in the import >>
  * departmentTeam: << The department or team associated with the import content >>
  * isEnabled: << Set it to true or false to indicate whether the import should be included in retrieval operations >>
* Sample request body payload:

{% code lineNumbers="true" %}

```json
{
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
}
```

{% endcode %}

* Code snippets:

{% tabs %}
{% tab title="Node Js" %}
{% code lineNumbers="true" %}

```javascript
var request = require('request');
var options = {
  'method': 'PATCH',
  'url': ' https://api.zbrain.ai/contentms/v2/api/knowledge-base-import',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
})
};

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
import json

url = " https://api.zbrain.ai/contentms/v2/api/knowledge-base-import"

payload = json.dumps({
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
})
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("PATCH", url, headers=headers, data=payload)

print(response.text)

```

{% endcode %}
{% endtab %}

{% tab title="cURL" %}
{% code lineNumbers="true" %}

```
curl --location ' https://api.zbrain.ai/contentms/v2/api/knowledge-base-import' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API Key>' \
--data '{
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
}'\
--request PATCH
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Sample response:

{% code lineNumbers="true" %}

```json
{
    "responseData": {
        "chunkingRules": {
            "mode": "AUTOMATIC"
        },
        "metadata": {
            "documentType": "",
            "title": " ",
            "author": "",
            "departmentTeam": "",
            "creationDate": 0,
            "modifiedDate": 0
        },
        "title": "",
        "summary": "",
        "knowledgeBaseId": "",
        "importedType": "",
        "status": "",
        "autoEmbedding": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        },
        "embedding": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        },
        "customEmbedding": {
            "url": "",
            "path": ""
        },
        "file": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        },
        "document": {
            "url": "",
            "path": ",
            "bucket": "",
            "storageProvider": ""
        },
        "docHash": "",
        "visitedPages": [],
        "retrievalCount": 0,
        "timeTaken": 0,
        "tokens": 0,
        "characters": 4871,
        "chunksCount": 13,
        "paragraphsCount": 0,
        "avgParagraphsLength": 0,
        "wordsCount": 0,
        "isEnabled": true,
        "historicalDocuments": [],
        "hypotheticalVectorIds": [],
        "smallVectorIds": [],
        "summaryVectorIds": [],
        "faissVectorIds": [],
        "pineconeVectors": 0,
        "pineconeIndexId": "",
        "parentKbImportId": "",
        "currentVersion": 1,
        "isDeleted": false,
        "isActive": true,
        "_id": "",
        "addedOn": 1715145815686,
        "modifiedOn": 1718171976745,
        "__v": 0
    },
    "message": "Information fetched successfully",
    "success": true,
    "responseCode": 200
}
```

{% endcode %}
