# Knowledge Base

Manage contents for your chatbot instant replies using our RAG engine. Populate your KBs using your own contents (URLs, sitemaps, pdfs, docx, text or FAQs). Our semantic engine will help you provide the best answers based on user questions using advanced Semantic indexing and the OpenAI generative AI. [More info](https://gethelp.tiledesk.com/categories/knowledge-base/)

### The Knowledge Base model

| Key               | Type    | Description                                                                                                      |
| ----------------- | ------- | ---------------------------------------------------------------------------------------------------------------- |
| id                | String  | The unique identifier for the knowledge base which is given by Tiledesk.                                         |
| name              | String  | The knowledge base name.                                                                                         |
| id\_project       | String  | The unique identifier of the project                                                                             |
| preview\_settings | Object  | The settings for the knowledge base preview                                                                      |
| default           | Boolean | Specifies if the knowledge base is the default one                                                               |
| hybrid            | Boolean | Specifies if the knowledge base is hybrid. Default is false (standard type)                                      |
| engine            | Object  | Specifies the configuration of the vector store system used by the knowledge base. A default engine is provided. |
| embedding         | Object  | Indicates which embeddings are used for vector-based search. A default embedding is present.                     |

## Get all knowledge bases

<mark style="color:blue;">`GET`</mark> `https://api.tiledesk.com/v3/:project_id/kb/namespace/all`

Allows to list all the knowledge bases of a project. Returns at least the default knowledge base.

#### Path Parameters

| Name        | Type   | Description                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------- |
| project\_id | string | The Project Id is a unique code assigned to your project when you create it in Tiledesk. |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | Authorization token. Basic Auth or JWT |

{% tabs %}
{% tab title="200 " %}

```
[
    {
        "default": true,
        "id_project": "63ad512e70d5ed0012ad6286",
        "id": "63ad512e70d5ed0012ad6286",
        "name": "Customer Support",
        "preview_settings": {
            "model": "gpt-3.5-turbo",
            "max_tokens": 128,
            "temperature": 0.7,
            "top_k": 4,
            "context": "You are an awesome AI Assistant."
        },
        "createdAt": "2024-06-20T13:49:04.006Z",
        "updatedAt": "2024-06-21T10:52:55.235Z"
    },
    {
        "default": false,
        "id_project": "63ad512e70d5ed0012ad6286",
        "id": "66755b6b9fee7f001357bc7f",
        "name": "Sales",
        "preview_settings": {
            "model": "gpt-3.5-turbo",
            "max_tokens": 128,
            "temperature": 0.7,
            "top_k": 4,
            "context": "You are an awesome AI Assistant."
        },
        "createdAt": "2024-06-21T10:52:27.111Z",
        "updatedAt": "2024-06-21T10:52:27.111Z"
    }
]
```

{% endtab %}
{% endtabs %}

Example

```
curl -v -X GET -u giovanni@tiledesk.com:password https://api.tiledesk.com/v3/63ad512e70d5ed0012ad6286/kb/namespace/all
```

***

## Create new knowledge base

<mark style="color:green;">`POST`</mark> `https://api.tiledesk.com/v3/:project_id/kb/namespace`

Allows to create a new knowledge base for a project.

#### Path Parameters

| Name        | Type   | Description                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------- |
| project\_id | string | The Project Id is a unique code assigned to your project when you create it in Tiledesk. |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | Authorization token. Basic Auth or JWT |

#### Request Body

| Name | Type   | Description                     |
| ---- | ------ | ------------------------------- |
| name | string | The name of the knowledge base. |

{% tabs %}
{% tab title="200 " %}

```
{
    "default": false,
    "id_project": "63ad512e70d5ed0012ad6286",
    "id": "6675a1b3c08d0b00141c415b",
    "name": "Products",
    "preview_settings": {
        "model": "gpt-3.5-turbo",
        "max_tokens": 128,
        "temperature": 0.7,
        "top_k": 4,
        "context": "You are an awesome AI Assistant."
    },
    "createdAt": "2024-06-21T15:52:19.036Z",
    "updatedAt": "2024-06-21T15:52:19.036Z"
}
```

{% endtab %}
{% endtabs %}

Example

```
curl -v -X GET -u giovanni@tiledesk.com:password -d '{"name": "Products"}' https://api.tiledesk.com/v3/63ad512e70d5ed0012ad6286/kb/namespace
```

***

## Update a knowledge base

<mark style="color:orange;">`PUT`</mark> `https://api.tiledesk.com/v3/:project_id/kb/namespace/:id`

Allows to update a knowledge base info and preview settings.

#### Path Parameters

| Name        | Type   | Description                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------- |
| project\_id | string | The Project Id is a unique code assigned to your project when you create it in Tiledesk. |
| id          | string | The unique identifier for the knowledge base                                             |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | Authorization token. Basic Auth or JWT |

#### Request Body

| Name              | Type   | Description                                      |
| ----------------- | ------ | ------------------------------------------------ |
| name              | string | The name of the knowledge base.                  |
| preview\_settings | object | The AI settings for the knowledge base settings. |

{% tabs %}
{% tab title="200 " %}

```
{
    "default": false,
    "id_project": "63ad512e70d5ed0012ad6286",
    "id": "6675a1b3c08d0b00141c415b",
    "name": "New Products",
    "preview_settings": {
        "model": "gpt-4o",
        "max_tokens": 256,
        "temperature": 0.5,
        "top_k": 5,
        "context": "Custom context."
    },
    "createdAt": "2024-06-21T15:52:19.036Z",
    "updatedAt": "2024-06-24T08:37:32.313Z"
}
```

{% endtab %}
{% endtabs %}

Example

```
curl -v -X PUT -u giovanni@tiledesk.com:password -d '{"name": "New Products", "preview_settings": { "model": "gpt-4o", "max_tokens": 256, "temperature": 0.5, "top_k": 5,"context": "Custom context." }}' 
https://api.tiledesk.com/v3/63ad512e70d5ed0012ad6286/kb/namespace/6675a1b3c08d0b00141c415b
```

***

## Delete a knowledge base

<mark style="color:red;">`DELETE`</mark> `https://api.tiledesk.com/v3/:project_id/kb/namespace/:id`

Allows to delete the whole knowledge base or it's contents only.

#### Path Parameters

| Name        | Type   | Description                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------- |
| project\_id | string | The Project Id is a unique code assigned to your project when you create it in Tiledesk. |
| id          | string | The unique identifier for the knowledge base                                             |

#### Query Parameters

| Name           | Type    | Description                                          |
| -------------- | ------- | ---------------------------------------------------- |
| contents\_only | boolean | (Optional) if TRUE will be deleted only the contents |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | Authorization token. Basic Auth or JWT |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "message": "Namespace deleted succesfully"
}
```

{% endtab %}
{% endtabs %}

Example

```

curl -v -X DELETE -u giovanni@tiledesk.com:password -d https://api.tiledesk.com/v3/63ad512e70d5ed0012ad6286/kb/namespace/6675a1b3c08d0b00141c415b
```
