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

# Delete knowledge base

> Delete a knowledge base collection and purge its vector documents (the KB entity/collection API; the plural `/knowledge-bases` path). Admins only (`knowledge_base:write`). Agents bound to it auto-unbind via the FK (ON DELETE SET NULL). Scope `knowledge_base:write`.



## OpenAPI

````yaml /api-reference/openapi.json delete /knowledge-bases/{knowledge_base_id}
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/{knowledge_base_id}:
    delete:
      tags:
        - Knowledge Base
      summary: Delete knowledge base
      description: >-
        Delete a knowledge base collection and purge its vector documents (the
        KB entity/collection API; the plural `/knowledge-bases` path). Admins
        only (`knowledge_base:write`). Agents bound to it auto-unbind via the FK
        (ON DELETE SET NULL). Scope `knowledge_base:write`.
      operationId: >-
        delete_knowledge_base_ca_api_v0_knowledge_bases__knowledge_base_id__delete
      parameters:
        - name: knowledge_base_id
          in: path
          required: true
          description: Id of the knowledge base collection to delete.
          schema:
            type: string
      responses:
        '200':
          description: >-
            Knowledge base deleted. `documents_deleted` is the count of purged
            vector rows (0 when no vector store is configured); `agents_unbound`
            is how many agents were referencing it.
          content:
            application/json:
              example:
                deleted: true
                documents_deleted: 12
                agents_unbound: 1
        '400':
          description: customer_id is not resolvable from the caller.
          content:
            application/json:
              example:
                error:
                  code: invalid_request
                  message: customer_id is required for knowledge base APIs
        '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
        '404':
          description: No knowledge base with that id exists in the caller's workspace.
          content:
            application/json:
              example:
                error:
                  code: not_found
                  message: Knowledge base not found
        '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

````