> For the complete documentation index, see [llms.txt](https://api.docs.blockbrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.docs.blockbrain.ai/getting-started/knowledge-management/create-a-database/create-folders.md).

# Create Folders

BlockBrain organizes documents within databases using hierarchical **Folders** that enforce access rights across tenants, users, and groups. The system aligns with bot/conversation sharing patterns and maintains strict tenant isolation.

## Create a new folder

Using the **`_id`** from our last step [Create a Database](/getting-started/knowledge-management/create-a-database.md), we now start creating subfolders to organize documents.  The **`root`** folder is the baseline Knowledgebase **`parentPath`** here.

## POST /folder

> Create Folder

```json
{"openapi":"3.1.0","info":{"title":"Blockbrain Knowledge Bots","version":"0.2.6"},"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}},"schemas":{"DocumentFolderCreateRequest":{"properties":{"name":{"type":"string","title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"knowledgeBase":{"type":"string","title":"Knowledgebase"},"parentPath":{"type":"string","title":"Parentpath"}},"type":"object","required":["name","knowledgeBase","parentPath"],"title":"DocumentFolderCreateRequest"},"DocumentFolder":{"properties":{"_id":{"type":"string","title":"Id"},"createdAt":{"type":"string","format":"date-time","title":"Createdat"},"modifiedAt":{"type":"string","format":"date-time","title":"Modifiedat"},"name":{"type":"string","title":"Name"},"path":{"type":"string","title":"Path","default":"root"},"knowledgeBase":{"type":"string","title":"Knowledgebase"},"user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"},"accessMode":{"$ref":"#/components/schemas/DocumentAccessMode","default":"restricted"},"isShareAll":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Isshareall","default":false},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"archivedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Archivedat"},"sourceType":{"anyOf":[{"$ref":"#/components/schemas/FolderDocumentSourceType"},{"type":"null"}]}},"type":"object","required":["name","knowledgeBase"],"title":"DocumentFolder"},"DocumentAccessMode":{"type":"string","enum":["private","restricted","any-one-with-link"],"title":"DocumentAccessMode"},"FolderDocumentSourceType":{"type":"string","enum":["FOLDER_UPLOAD","ONE_DRIVE","GOOGLE_DRIVE"],"title":"FolderDocumentSourceType"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/folder":{"post":{"tags":["folder"],"summary":"Create Folder","operationId":"create_folder_folder_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentFolderCreateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentFolder"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

When creating folders, we again get access to an **`_id`** property that can be used for further operations like moving or deleting folders. The **`path`** should be used as parentPath when creating more subfolders.

## Delete a Folder

The delete method can either use one or several ids to remove folders inside of a Knowledgebase. Here we need to use our **`_id`** from the folder creation to delete a given folder again.

## DELETE /folder/{knowledge\_base}/remove

> Remove Folder

```json
{"openapi":"3.1.0","info":{"title":"Blockbrain Knowledge Bots","version":"0.2.6"},"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}},"schemas":{"DocumentFolderRemoveRequest":{"properties":{"sourceItems":{"items":{"$ref":"#/components/schemas/SourceDocumentFolderItem"},"type":"array","title":"Sourceitems"}},"type":"object","required":["sourceItems"],"title":"DocumentFolderRemoveRequest"},"SourceDocumentFolderItem":{"properties":{"id":{"type":"string","title":"Id"},"type":{"$ref":"#/components/schemas/api__textdatabase__constants__DocumentType","default":"file"}},"type":"object","required":["id"],"title":"SourceDocumentFolderItem"},"api__textdatabase__constants__DocumentType":{"type":"string","enum":["file","folder"],"title":"DocumentType"},"CommonResponseDTO":{"properties":{"code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Code"},"key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Key"},"body":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Body"}},"type":"object","title":"CommonResponseDTO"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/folder/{knowledge_base}/remove":{"delete":{"tags":["folder"],"summary":"Remove Folder","operationId":"remove_folder_folder__knowledge_base__remove_delete","parameters":[{"name":"knowledge_base","in":"path","required":true,"schema":{"type":"string","title":"Knowledge Base"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentFolderRemoveRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommonResponseDTO"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Next Steps

Now that we have our folder structure set up, time to [Upload Documents to DBs](/getting-started/knowledge-management/upload-documents-to-dbs.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api.docs.blockbrain.ai/getting-started/knowledge-management/create-a-database/create-folders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
