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

# Create knowledge base

> Create a named knowledge base collection (the KB entity/collection API; the plural `/knowledge-bases` path). Admins only — `knowledge_base:write` is not granted to the normal_user role. The collection holds no documents until you ingest into it. Scope `knowledge_base:write`.



## OpenAPI

````yaml /api-reference/openapi.json post /knowledge-bases
openapi: 3.1.0
info:
  title: Lehar API
  version: v0
  description: >-
    Customer-facing REST API for the Lehar voice-AI platform. Platform-admin
    endpoints are intentionally excluded from this reference. Regenerate with
    `npm run sync:openapi`.
servers:
  - url: https://api.lehar.ai/ca/api/v0
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /knowledge-bases:
    post:
      tags:
        - Knowledge Base
      summary: Create knowledge base
      description: >-
        Create a named knowledge base collection (the KB entity/collection API;
        the plural `/knowledge-bases` path). Admins only —
        `knowledge_base:write` is not granted to the normal_user role. The
        collection holds no documents until you ingest into it. Scope
        `knowledge_base:write`.
      operationId: create_knowledge_base_ca_api_v0_knowledge_bases_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: >-
                    Display name, unique per workspace. Trimmed; must be
                    non-empty and at most 200 characters.
                description:
                  type: string
                  maxLength: 2000
                  nullable: true
                  description: Optional free-text description, at most 2000 characters.
            example:
              name: Support FAQ
              description: Answers for common customer questions
      responses:
        '201':
          description: >-
            Knowledge base created. `document_count` is 0 for a brand-new
            collection.
          content:
            application/json:
              example:
                id: kb_01jq8x9m2h4z7c0r5v3b8t6n1e
                name: Support FAQ
                description: Answers for common customer questions
                created_by_user_id: usr_01jq8x9m2h4z7c0r5v3b8t6n1e
                document_count: 0
                created_at: '2026-09-02T10:15:00Z'
                updated_at: '2026-09-02T10:15:00Z'
        '400':
          description: >-
            customer_id is missing or does not exist, the body is not a JSON
            object, or name/description fail validation (missing name, name over
            200 chars, description over 2000 chars).
          content:
            application/json:
              example:
                error:
                  code: invalid_request
                  message: name is required
        '401':
          description: No valid authentication was supplied.
          content:
            application/json:
              example:
                error:
                  code: unauthorized
                  message: Authentication required
        '403':
          description: The caller lacks `knowledge_base:write` (admin-tier).
          content:
            application/json:
              example:
                error:
                  code: forbidden
                  message: Scope 'knowledge_base:write' is required
        '409':
          description: A knowledge base with the same name already exists in the workspace.
          content:
            application/json:
              example:
                error:
                  code: conflict
                  message: A knowledge base named 'Support FAQ' already exists
        '500':
          description: Unexpected server error.
          content:
            application/json:
              example:
                error:
                  code: internal_error
                  message: An unexpected error occurred
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    BearerAuth:
      type: http
      scheme: bearer

````