> ## Documentation Index
> Fetch the complete documentation index at: https://anam.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Base Setup

> Create folders and organize your documents for semantic search with RAG

## Overview

Setting up your knowledge base is the first step to enabling your AI personas to search and retrieve information from your documents. This guide walks you through creating folders, understanding the organizational structure, and preparing for document uploads.

## Before You Begin

<Warning>**Beta Feature**: Knowledge Base is currently in beta. You may encounter some issues as we continue to improve the feature. Please report any feedback or issues to help us make it better.</Warning>

<Info>
  **What you'll need**:

  * An Anam account with API access
  * Documents to upload (PDF, TXT, MD, DOCX, CSV, JSON, or LOG files)
  * Basic understanding of your content organization

  **Time to complete**: 10-15 minutes
</Info>

## Understanding Folder Structure

Knowledge folders organize your documents by topic, use case, or category. Think of them as searchable collections that can be assigned to different knowledge tools.

### Example Organization

```
Your Organization
├── Product Documentation (Folder)
│   ├── user-guide.pdf
│   ├── api-reference.md
│   └── faq.pdf
│
├── Technical Support (Folder)
│   ├── troubleshooting-guide.pdf
│   ├── error-codes.txt
│   └── common-issues.md
│
├── Company Policies (Folder)
│   ├── privacy-policy.pdf
│   ├── terms-of-service.md
│   └── refund-policy.pdf
│
└── Customer FAQs (Folder)
    ├── billing-faq.md
    ├── account-faq.md
    └── shipping-faq.pdf
```

### Why Organize by Folder?

<AccordionGroup>
  <Accordion title="Better search relevance">
    Smaller, focused folders return more relevant results than searching across all documents at once.
  </Accordion>

  <Accordion title="Easier tool assignment">Different folders can be assigned to different knowledge tools, allowing the LLM to search only relevant content.</Accordion>

  <Accordion title="Simpler maintenance">Update or replace documents in specific knowledge domains without affecting others.</Accordion>

  <Accordion title="Clear organization">
    Easy to understand what content is available and where it's located.
  </Accordion>
</AccordionGroup>

## Step 1: Plan Your Folder Structure

Before creating folders, plan your organization strategy based on your use case.

### By Content Type

Organize by the type of information:

```
├── Product Documentation
├── API Reference
├── User Guides
├── FAQs
└── Policies
```

**Good for**: SaaS products, developer platforms

### By Department

Organize by who creates or owns the content:

```
├── Sales Resources
├── Support Knowledge Base
├── HR Policies
├── Engineering Docs
└── Marketing Materials
```

**Good for**: Internal knowledge bases, employee assistants

### By User Journey

Organize by when users need the information:

```
├── Getting Started
├── Basic Features
├── Advanced Features
├── Troubleshooting
└── Account Management
```

**Good for**: Customer support, onboarding assistants

### By Product/Service

Organize by different offerings:

```
├── Product A Documentation
├── Product B Documentation
├── Service C Information
└── General Company Info
```

**Good for**: Multi-product companies

<Tip>Start simple with 3-5 folders. You can always create more as your knowledge base grows.</Tip>

## Step 2: Create Your First Folder

<Tabs>
  <Tab title="UI">
    <Steps>
      <Step title="Navigate to Knowledge Base">
        Go to `/knowledge` in the Anam Lab
      </Step>

      <Step title="Create new folder">Click the **Create Folder** button in the top right</Step>

      <Step title="Fill in details">
        Enter folder information:

        **Name**: Descriptive name for the folder

        * Examples: "Product Documentation", "Customer FAQs", "API Reference"
        * Use clear, specific names
        * 1-100 characters

        **Description** (optional): What content is in this folder

        * Helps you remember the folder's purpose
        * Useful when you have many folders
        * 0-500 characters
      </Step>

      <Step title="Create folder">
        Click **Create**

        <Check>
          Your folder is created and appears in the folder list. You'll see:

          * Folder name and description
          * Document count (0 initially)
          * Created date
          * Folder ID (UUID) for API usage
        </Check>
      </Step>
    </Steps>
  </Tab>

  <Tab title="API">
    Create folders programmatically using the API:

    ```bash cURL theme={"system"}
    curl -X POST 'https://api.anam.ai/v1/knowledge/groups' \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      -H 'Content-Type: application/json' \
      -d '{
        "name": "Product Documentation",
        "description": "Technical guides and product information for customer support"
      }'
    ```

    ```javascript JavaScript theme={"system"}
    const response = await fetch("https://api.anam.ai/v1/knowledge/groups", {
      method: "POST",
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        name: "Product Documentation",
        description: "Technical guides and product information for customer support",
      }),
    });

    const folder = await response.json();
    console.log("Folder created with ID:", folder.id);
    ```

    ```python Python theme={"system"}
    import requests

    response = requests.post(
        'https://api.anam.ai/v1/knowledge/groups',
        headers={
            'Authorization': 'Bearer YOUR_API_KEY',
            'Content-Type': 'application/json'
        },
        json={
            'name': 'Product Documentation',
            'description': 'Technical guides and product information for customer support'
        }
    )

    folder = response.json()
    print(f"Folder created with ID: {folder['id']}")
    ```

    **Response**:

    ```json theme={"system"}
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Product Documentation",
      "description": "Technical guides and product information for customer support",
      "documentCount": 0,
      "organizationId": "org-uuid",
      "createdAt": "2024-03-10T10:30:00Z",
      "updatedAt": "2024-03-10T10:30:00Z"
    }
    ```

    <Check>
      Save the folder `id` - you'll need it for uploading documents and creating knowledge tools.
    </Check>
  </Tab>
</Tabs>

## Step 3: Create Additional Folders

Create folders for your other content categories:

<CodeGroup>
  ```bash cURL theme={"system"}
  # Create Technical Support folder
  curl -X POST 'https://api.anam.ai/v1/knowledge/groups' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "name": "Technical Support",
      "description": "Troubleshooting guides and error documentation"
    }'

  # Create Company Policies folder

  curl -X POST 'https://api.anam.ai/v1/knowledge/groups' \
   -H 'Authorization: Bearer YOUR_API_KEY' \
   -H 'Content-Type: application/json' \
   -d '{
  "name": "Company Policies",
  "description": "Privacy policy, terms of service, and legal documents"
  }'

  # Create Customer FAQs folder

  curl -X POST 'https://api.anam.ai/v1/knowledge/groups' \
   -H 'Authorization: Bearer YOUR_API_KEY' \
   -H 'Content-Type: application/json' \
   -d '{
  "name": "Customer FAQs",
  "description": "Frequently asked questions from customers"
  }'

  ```

  ```javascript JavaScript theme={"system"}
  const folders = [
    {
      name: 'Technical Support',
      description: 'Troubleshooting guides and error documentation'
    },
    {
      name: 'Company Policies',
      description: 'Privacy policy, terms of service, and legal documents'
    },
    {
      name: 'Customer FAQs',
      description: 'Frequently asked questions from customers'
    }
  ];

  for (const folderData of folders) {
    const response = await fetch('https://api.anam.ai/v1/knowledge/groups', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(folderData)
    });

    const folder = await response.json();
    console.log(`Created: ${folder.name} (${folder.id})`);
  }
  ```
</CodeGroup>

## Step 4: View Your Folders

<Tabs>
  <Tab title="UI">
    All your folders are listed on the Knowledge Base page at `/knowledge`:

    * **Folder cards** show name, description, and document count
    * **Click a folder** to see its documents
    * **Search folders** using the search bar
    * **Sort folders** by name or creation date
  </Tab>

  <Tab title="API">
    List all folders in your organization:

    ```bash theme={"system"}
    curl -X GET 'https://api.anam.ai/v1/knowledge/groups' \
      -H 'Authorization: Bearer YOUR_API_KEY'
    ```

    **Response**:

    ```json theme={"system"}
    {
      "folders": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Product Documentation",
          "description": "Technical guides and product information",
          "documentCount": 0,
          "createdAt": "2024-03-10T10:30:00Z"
        },
        {
          "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
          "name": "Technical Support",
          "description": "Troubleshooting guides and error documentation",
          "documentCount": 0,
          "createdAt": "2024-03-10T10:31:00Z"
        }
      ],
      "total": 2
    }
    ```
  </Tab>
</Tabs>

## Step 5: Prepare Your Documents

Before uploading, organize and prepare your documents:

### Supported File Types

<ResponseField name="PDF" type="file">
  Product manuals, guides, reports, brochures - Max size: 50MB - Chunking: Paragraph-based
</ResponseField>

<ResponseField name="TXT" type="file">
  Plain text documentation, notes, logs - Max size: 50MB - Chunking: Paragraph-based
</ResponseField>

<ResponseField name="MD (Markdown)" type="file">
  Technical documentation, README files, wikis - Max size: 50MB - Chunking: Paragraph-based (respects headings)
</ResponseField>

<ResponseField name="DOCX" type="file">
  Word documents, reports, guides - Max size: 50MB - Chunking: Paragraph-based
</ResponseField>

<ResponseField name="CSV" type="file">
  Structured data, product catalogs, FAQs - Max size: 50MB - Chunking: Row-based (each row is a chunk)
</ResponseField>

<ResponseField name="JSON" type="file">
  Structured data, API responses, configurations - Max size: 50MB - Chunking: Whole file (structure preserved)
</ResponseField>

<ResponseField name="LOG" type="file">
  Log files, system outputs - Max size: 50MB - Chunking: Line-based
</ResponseField>

### Document Preparation Tips

<AccordionGroup>
  <Accordion title="Use clear file names">
    ```
    ✅ Good:
    - product-installation-guide-v2.pdf
    - password-reset-faq.md
    - api-authentication-reference.pdf

    ❌ Bad:

    - document1.pdf
    - file.md
    - untitled.pdf

    ```
  </Accordion>

  <Accordion title="Structure content with headings">
    ```markdown theme={"system"}
    # Installation Guide

    ## Prerequisites
    Before installing, ensure you have...

    ## Step 1: Download
    Navigate to our downloads page...

    ## Step 2: Install
    Run the installer and follow...
    ```

    Headings help the chunking algorithm create semantic segments.
  </Accordion>

  <Accordion title="Keep documents focused">
    Instead of one 500-page manual, split into topic-specific documents:

    * installation-guide.pdf
    * configuration-guide.pdf
    * troubleshooting-guide.pdf
    * api-reference.pdf

    This improves search relevance.
  </Accordion>

  <Accordion title="Remove unnecessary content">
    * Remove cover pages and table of contents
    * Delete outdated information
    * Remove duplicate content across files
    * Strip unnecessary images from PDFs to reduce size
  </Accordion>
</AccordionGroup>

## Upload Limits

Document uploads are subject to file size and storage limits based on your plan.

* **File size limits** apply per document
* **Batch uploads** supported for multiple files
* **Storage quotas** count only non-deleted documents
* Deleting documents frees up quota for new uploads

<Info>**Need higher limits?** Contact us about Enterprise plans with custom upload limits tailored to your needs.</Info>

### Check Your Usage

<Tabs>
  <Tab title="UI">
    View your current storage usage on the Knowledge Base page at `/knowledge`:

    * **Total uploaded**: Shows your cumulative upload amount
    * **Document count**: Number of active documents
  </Tab>
</Tabs>

## Managing Folders

### Rename a Folder

<Tabs>
  <Tab title="UI">
    1. Click the folder to open it
    2. Click the **Edit** button (pencil icon)
    3. Update name or description
    4. Click **Save**
  </Tab>

  <Tab title="API">
    ```bash theme={"system"}
    curl -X PATCH 'https://api.anam.ai/v1/knowledge/groups/FOLDER_ID' \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      -H 'Content-Type: application/json' \
      -d '{
        "name": "Updated Folder Name",
        "description": "Updated description"
      }'
    ```
  </Tab>
</Tabs>

### Delete a Folder

<Warning>Deleting a folder deletes all documents inside it. This action cannot be undone.</Warning>

<Tabs>
  <Tab title="UI">
    1. Click the folder to open it
    2. Click the **Delete** button (trash icon)
    3. Confirm deletion in the modal
  </Tab>

  <Tab title="API">
    ```bash theme={"system"}
    curl -X DELETE 'https://api.anam.ai/v1/knowledge/groups/FOLDER_ID' \
      -H 'Authorization: Bearer YOUR_API_KEY'
    ```

    This performs a soft delete (sets `deleted_at` timestamp). Documents are removed from search immediately.
  </Tab>
</Tabs>

## Best Practices

<AccordionGroup>
  <Accordion title="Start with 3-5 folders">
    Don't over-organize initially. Create folders as you need them.

    **Good starting structure**:

    * Product Documentation
    * FAQs
    * Support/Troubleshooting

    Add more specialized folders as your knowledge base grows.
  </Accordion>

  <Accordion title="Use descriptive names">
    Folder names should clearly indicate their content:

    ```
    ✅ Good:
    - API Reference Documentation
    - Customer Billing FAQs
    - Product Installation Guides

    ❌ Too vague:
    - Documents
    - Stuff
    - Files
    ```
  </Accordion>

  <Accordion title="Keep folders focused">
    Each folder should serve a specific purpose:

    ```
    ✅ Good (focused):
    - Product Features
    - Installation Guides
    - Troubleshooting

    ❌ Too broad:
    - Everything
    - All Documents
    - General
    ```
  </Accordion>

  <Accordion title="Plan for growth">
    Choose a structure that scales:

    ```
    Today (10 documents):
    ├── Documentation
    └── FAQs

    Future (100+ documents):
    ├── Product Documentation
    │   ├── Features
    │   ├── Installation
    │   └── API Reference
    ├── Support
    │   ├── Troubleshooting
    │   ├── Common Issues
    │   └── Error Codes
    └── Customer FAQs
        ├── Billing
        ├── Account
        └── Technical
    ```

    Start simple, but use a structure that allows subdivision later.
  </Accordion>
</AccordionGroup>

## Next Steps

Now that your folders are set up, you're ready to upload documents:

<CardGroup cols={2}>
  <Card title="Upload Documents" icon="upload" href="/personas/knowledge/uploading-documents">
    Step-by-step guide to uploading and processing documents
  </Card>

  <Card title="Create Knowledge Tools" icon="wrench" href="/personas/knowledge/tools">
    Enable semantic search with knowledge tools
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/knowledge/create-knowledge-group">
    Complete API documentation for knowledge base
  </Card>

  <Card title="Concepts" icon="book" href="/personas/knowledge/overview">
    Learn more about how RAG works
  </Card>
</CardGroup>
