> For the complete documentation index, see [llms.txt](https://docs.allganize.ai/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.allganize.ai/api-reference/knowledge-base-nodes-api.md).

# Knowledge Base Nodes API

## Constants

### Constants Tables

#### **Status**

| Value | Description                          |
| ----- | ------------------------------------ |
| `on`  | The knowledge base node is active.   |
| `off` | The knowledge base node is inactive. |

***

#### **NodeType**

| Value    | Description                                    |
| -------- | ---------------------------------------------- |
| `file`   | Represents a knowledge base file.              |
| `folder` | Represents a folder within the knowledge base. |

***

#### **ProcessState**

| Value               | Description                                   |
| ------------------- | --------------------------------------------- |
| `initializing`      | The node is being initialized.                |
| `parsing`           | The node is currently being parsed.           |
| `parsing_fail`      | Parsing failed for the node.                  |
| `completed`         | The node has completed processing.            |
| `retrying`          | The system is retrying the process.           |
| `post_parsing`      | Post-parsing is in progress.                  |
| `post_parsing_fail` | Post-parsing failed for the node.             |
| `post_completed`    | Post-parsing has been completed successfully. |
| `post_retrying`     | The system is retrying post-parsing.          |

***

#### **SearchOperator**

| Value | Description                                      |
| ----- | ------------------------------------------------ |
| `and` | Results must match all specified criteria.       |
| `or`  | Results can match any of the specified criteria. |

***

#### **KnowledgeBaseNodeOrder**

| Value             | Description                                     |
| ----------------- | ----------------------------------------------- |
| `name_asc`        | Sorts by name in ascending order.               |
| `name_desc`       | Sorts by name in descending order.              |
| `updated_at_asc`  | Sorts by last updated time in ascending order.  |
| `updated_at_desc` | Sorts by last updated time in descending order. |
| `created_at_asc`  | Sorts by creation time in ascending order.      |
| `created_at_desc` | Sorts by creation time in descending order.     |

***

## Search Knowledge Base Nodes

<mark style="color:green;">`POST`</mark> /webapi/v2/knowledge\_base\_nodes/search

Get knowledge base node list by filter.

### Headers

| Name                                      | Type   | Description                                                                       |
| ----------------------------------------- | ------ | --------------------------------------------------------------------------------- |
| API-KEY<mark style="color:red;">\*</mark> | string | Your API key can be found in your dashboard Settings menu, under the General tab. |

### Request Body

| Name      | Type   | Description                              |
| --------- | ------ | ---------------------------------------- |
| `filter_` | Object | Contains criteria for filtering results. |

| └─ `parentFolderIds` | Array of `string` | Filter knowledge base nodes whose parent folder ID is in the list. Use `[null]` to get top-level knowledge base nodes. |
| -------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------- |

| └─ `searchTerm` | `string` | Search keyword. Searches folders and knowledge bases. Uses ElasticSearch for knowledge base searches if the project's document search mode is `EXACT_AND_ELASTICSEARCH`. |
| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

| └─ `hashtags` | Array of `string` | Filter knowledge base nodes that have the specified hashtags. |
| ------------- | ----------------- | ------------------------------------------------------------- |

| └─ `hashtagsSearchOperator` | Array of `string` | Determines whether the `hashtags` filter applies `AND` or `OR` conditions. |
| --------------------------- | ----------------- | -------------------------------------------------------------------------- |

| └─ `excludingHashtags` | Array of `string` | Filter knowledge base nodes that do not have the specified hashtags. |
| ---------------------- | ----------------- | -------------------------------------------------------------------- |

| └─ `excludingHashtagsSearchOperator` | `string` | Determines whether the `excludingHashtags` filter applies `AND` or `OR` conditions. |
| ------------------------------------ | -------- | ----------------------------------------------------------------------------------- |

| └─ `processState` | Array of `ProcessStateEnum` | Filter by process state. |
| ----------------- | --------------------------- | ------------------------ |

| └─ `status` | Array of `KnowledgeBaseNodeOnOffState` | Filter by status in the docs tab (`"on"` or `"off"`). |
| ----------- | -------------------------------------- | ----------------------------------------------------- |

| └─ `nodeType` | Array of `KnowledgeBaseNodeType` | Filter by node type (`"file"` or `"folder"`). |
| ------------- | -------------------------------- | --------------------------------------------- |

| └─ `knowledgeBaseIds` | Array of `string` | Filter by knowledge base IDs. |
| --------------------- | ----------------- | ----------------------------- |

#### Additional Parameters

| Key     | Type                     | Description                                                                                                                                         |
| ------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `order` | `KnowledgeBaseNodeOrder` | Specifies the order of results. Default is `UPDATED_AT_DESC`.                                                                                       |
| `limit` | `integer`                | Limits the result count. Default is `10`.                                                                                                           |
| `after` | `string`                 | Cursor for pagination. If not provided, the server returns results starting from the first value of the filtered set, limited to the `limit` count. |

{% tabs %}
{% tab title="200" %}
You will get the result in the following JSON format:

* **`id`**: Knowledge base node ID.
* **`name`**: Knowledge base node name.
* **`createdAt`, `updatedAt`**: Timestamps indicating when the knowledge base node was created and last updated.
* **`nodeType`**: Knowledge base node type (e.g., `"folder"` or `"file"`).
* **`hashtags`**: Array of hashtags associated with the knowledge base node.
* **`status`**: Status of the knowledge base node (e.g., `"on"` or `"off"`).
* **`size`**: Size of the knowledge base file in bytes (only for `nodeType: file`).
* **`processState`**: Process status of the knowledge base node (e.g., `"completed"`).
* **`cursor`**: Use this value in the `after` field of the request body to fetch the next set of results starting from the last index of the current result.
  {% endtab %}
  {% endtabs %}

### Request Example

```
{
 "filter_": {
    "searchTerm":"test"
 },
 "limit":2,
 "order":"created_at_desc",
}
```

### Response Example

```
{
    "result": {
        "nodes": [
            # nodeType -> Folder
            {
                "id": "Rm9sZGVyOjY3MmM1OGZiY2M5ZjVmZDY4MTgwMDgyMQ==",
                "name": "test",
                "createdAt": 1730959611701.0,
                "updatedAt": 1730959611701.0,
                "nodeType": "folder"
            },
            # nodeType -> file
            {
                "id": "S25vd2xlZGdlQmFzZTo2NzI5ZWZjY2JlOTRlNzY3OWRlOTFlZjc=",
                "name": "test.xlsx",
                "createdAt": 1730801612004.0,
                "updatedAt": 1730801612004.0,
                "nodeType": "file",
                "hashtags": [],
                "status": "on",
                "size": 26010,
                "processState": "completed"
            }
        ],
        "cursor": "1730801612004.0"
    }
}
```

### Using Cursor-Based Paging

### Request Example

```
{
"limit":3
}
```

### Request Response

```
{
    "result": {
        "nodes": [
            {
                "id": "S25vd2xlZGdlQmFzZTo1NzFmZWMzNjAxMTBkNDMzMTAxMGVkNDk=",
                "name": "Doc1.pdf",
                "createdAt": 1730145334084.0,
                "updatedAt": 1730145334084.0,
                "nodeType": "file",
                "parentFolder": null,
                "breadcrumbs": []
            },
            {
                "id": "S25vd2xlZGdlQmFZZTo2NzFmZWMzMTVmYTM0NmM3OTNiMjA1OTM=",
                "name": "Doc2",
                "createdAt": 1730145329080.0,
                "updatedAt": 1730145329080.0,
                "nodeType": "file",
                "parentFolder": null,
                "breadcrumbs": []
            },
            {
                "id": "S25vd2xlZGdlQmFzZTo5NzFmZWMyZTNmMGRjNDY1OWM4ZGU4NzA=",
                "name": "Doc3.pdf",
                "createdAt": 1730145326499.0,
                "updatedAt": 1730145326499.0,
                "nodeType": "file",
                "parentFolder": null,
                "breadcrumbs": []
            }
        ],
        "cursor": "NjcxZmVjMmUzZjBkYzQ2NTljOGRlODcw:MTczMDE0NTMyNjQ5OQ=="
    }
}
```

If you put `NjcxZmVjMmUzZjBkYzQ2NTljOGRlODcw:MTczMDE0NTMyNjQ5OQ==` in "after", you'll get items after the cursor.

### Request Example

```
{
"limit":2
"after":"NjcxZmVjMmUzZjBkYzQ2NTljOGRlODcw:MTczMDE0NTMyNjQ5OQ=="
}
```

### Request Reponse

```
{
    "result": {
        "nodes": [
            {
                "id": "S25vd2xlZGdlQmFzZTo1NzFmZWMzNjAxMTBkNDMzMTAxMGVkNDk=",
                "name": "Doc4.pdf",
                "createdAt": 1730145334084.0,
                "updatedAt": 1730145334084.0,
                "nodeType": "file",
                "parentFolder": null,
                "breadcrumbs": []
            },
            {
                "id": "S25vd2xlZGdlQmFZZTo2NzFmZWMzMTVmYTM0NmM3OTNiMjA1OTM=",
                "name": "Doc5",
                "createdAt": 1730145329080.0,
                "updatedAt": 1730145329080.0,
                "nodeType": "file",
                "parentFolder": null,
                "breadcrumbs": []
            },
        ],
        "cursor": "NjcxZmVjMjhmYWJjZmYzMWYzMjc0YmM3:MTczMDE0NTMyMDQ5NA=="
    }
}
```

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

* **`id`**: Knowledge base node ID.
* **`name`**: Knowledge base node name.
* **`createdAt`, `updatedAt`**: Timestamps indicating when the knowledge base node was created and last updated.
* **`nodeType`**: Knowledge base node type (e.g., `"folder"` or `"file"`).
* **`hashtags`**: Array of hashtags associated with the knowledge base node.
* **`status`**: Status of the knowledge base node (e.g., `"on"` or `"off"`).
* **`size`**: Size of the knowledge base file in bytes (only for `nodeType: file`).
* **`processState`**: Process status of the knowledge base node (e.g., `"completed"`).
* **`cursor`**: Use this value in the `after` field of the request body to fetch the next set of results starting from the last index of the current result.
  {% endtab %}
  {% endtabs %}

## Get Knowledge Base Nodes by Node-ID

## Move Knowledge Base Nodes to Target Folder

## Delete Knowledge Base Nodes

## Create Folder

## Update Folder

## Get Agents

##
