> ## 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.

# Create Knowledge Base

> Uploads a document or raw text to create a new Knowledge Base entry. Requires `x-api-key` authentication.



## OpenAPI

````yaml POST /ext/kb
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:
    post:
      summary: Create Knowledge Base
      description: >-
        Uploads a document or raw text to create a new Knowledge Base entry.
        Requires `x-api-key` authentication.
      operationId: createKnowledgeBase
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: HR Policy
                  description: Human readable name of the knowledge base.
                description:
                  type: string
                  example: >-
                    This knowledge base contains HR and compensation related
                    information.
                  description: Description of the knowledge base.
                input:
                  type: string
                  format: binary
                  example: HR_Policy.docx
                  description: >-
                    Document file to upload (`.pdf`, `.docx` or `.txt`).
                    Optional if text is provided.
                text:
                  type: string
                  example: >-
                    As of 2025; we have increased the personal leaves to 15 per
                    year.
                  description: >-
                    As of 2025; we have increased the personal leaves to 15 per
                    year.
              required:
                - name
                - description
            example:
              name: HR Policy
              description: >-
                This knowledge base contains HR and compensation related
                information.
              input: HR_Policy.docx
              text: >-
                As of 2025; we have increased the personal leaves to 15 per
                year.
      responses:
        '200':
          description: Knowledge Base created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: UUID of the newly created Knowledge Base
                    example: 5273e435-3cbb-4a11-9ea9-2c150ba19009
                  message:
                    type: string
                    example: Knowledge Base created successfully
              example:
                id: 5273e435-3cbb-4a11-9ea9-2c150ba19009
                message: Knowledge Base created successfully
        '400':
          description: Invalid request or file/text upload error
          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'
        '500':
          description: 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

````