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

# Upload Knowledge Base Item

> Upload a new knowledge base item (PDF or TXT file) to a specific knowledge base.

# Upload Knowledge Base Item

This endpoint allows you to upload a new item (PDF or TXT file) to a knowledge base.

## Request

### Headers

| Name          | Type   | Required | Description                     |
| ------------- | ------ | -------- | ------------------------------- |
| Authorization | string | Yes      | Bearer token for authentication |
| Content-Type  | string | Yes      | multipart/form-data             |

### Path Parameters

| Name   | Type   | Required | Description                  |
| ------ | ------ | -------- | ---------------------------- |
| kb\_id | string | Yes      | The ID of the knowledge base |

### Form Data

| Name | Type   | Required | Description                                     |
| ---- | ------ | -------- | ----------------------------------------------- |
| file | file   | Yes      | The PDF or TXT file to upload                   |
| name | string | No       | Custom name for the item (defaults to filename) |

## Response

### 200 OK

```json theme={null}
{
  "data": {
    "id": "string",
    "name": "string",
    "file_type": "string",
    "status": "string",
    "created_at": "string",
    "updated_at": "string",
    "knowledge_base_id": "string"
  }
}
```

### Response Fields

| Field               | Type   | Description                                   |
| ------------------- | ------ | --------------------------------------------- |
| id                  | string | Unique identifier for the uploaded item       |
| name                | string | Name of the item                              |
| file\_type          | string | Type of the file (PDF or TXT)                 |
| status              | string | Current status of the item                    |
| created\_at         | string | Timestamp when the item was created           |
| updated\_at         | string | Timestamp when the item was last updated      |
| knowledge\_base\_id | string | ID of the knowledge base this item belongs to |

## Example

```bash theme={null}
curl -X POST 'https://api.kollie.ai/api/v1/knowledge-base/123e4567-e89b-12d3-a456-426614174000/items' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -F 'file=@document.pdf' \
  -F 'name=Product Manual'
```


## OpenAPI

````yaml POST /api/v1/knowledge-base/{kb_id}/items
openapi: 3.1.0
info:
  title: kollie-backend
  version: v1
servers: []
security: []
paths:
  /api/v1/knowledge-base/{kb_id}/items:
    post:
      tags:
        - knowledge-base
      summary: Upload Knowledge Base Item
      description: >-
        Upload a new knowledge base item (PDF or TXT file) to a specific
        knowledge base.
      operationId: upload_knowledge_base_item_api_v1_knowledge_base__kb_id__items_post
      parameters:
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Kb Id
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_upload_knowledge_base_item_api_v1_knowledge_base__kb_id__items_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
        - HTTPBearer: []
components:
  schemas:
    Body_upload_knowledge_base_item_api_v1_knowledge_base__kb_id__items_post:
      properties:
        file:
          type: string
          format: binary
          title: File
        name:
          type: string
          title: Name
        notes:
          anyOf:
            - type: string
            - type: 'null'
          title: Notes
      type: object
      required:
        - file
        - name
      title: Body_upload_knowledge_base_item_api_v1_knowledge_base__kb_id__items_post
    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
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
    HTTPBearer:
      type: http
      scheme: bearer

````