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

# Add Documents to Knowledge Base

> Uploads additional content or a document to an existing Knowledge Base. Requires `x-api-key` authentication.



## OpenAPI

````yaml POST /ext/kb/{id}/doc
openapi: 3.0.3
info:
  title: TruGen Developer Platform API
  version: 1.0.0
  description: OpenAPI specification for MCP endpoint
servers:
  - url: https://api.trugen.ai/v1
security: []
paths:
  /ext/kb/{id}/doc:
    post:
      summary: Add content to an existing knowledge base
      description: >-
        Uploads additional content or a document to an existing Knowledge Base.
        Requires `x-api-key` authentication.
      operationId: addKnowledgeBaseDocument
      parameters:
        - name: id
          in: path
          required: true
          description: UUID of the Knowledge Base to which the content will be added
          schema:
            type: string
            format: uuid
            example: d837afdc-f95f-4e4d-abe4-40894db22a02
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                text:
                  type: string
                  description: Text or URL content to be added to the Knowledge Base
                  example: >-
                    Sample knowledge base text or URL like
                    https://docs.trugen.ai/
                input:
                  type: string
                  format: binary
                  description: Optional file upload (e.g., .pdf, .docx)
              required:
                - text
      responses:
        '200':
          description: Content added successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  added:
                    type: integer
                    example: 1
                  message:
                    type: string
                    example: Content added successfully to existing Knowledge Base
              example:
                added: 1
                message: Content added successfully to existing Knowledge Base
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: Invalid request body
        '401':
          description: Unauthorized – Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: 'Unauthorized: not a valid authorization api key'
        '404':
          description: Knowledge Base not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                message: Knowledge Base not found
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: Failed to retrieve knowledge base
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````