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

# Create a knowledge base

> Creates an empty knowledge base. Add content to it by [creating sources](#tag/sources) and attaching them. Requires a token with write access.



## OpenAPI

````yaml /openapi-knowledge-base.json post /knowledge-base/datasets
openapi: 3.0.3
info:
  title: AnyReach Knowledge Base API
  version: 1.0.0
  description: Manage knowledge bases, their sources, and run retrieval queries.
servers:
  - url: https://api.anyreach.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Knowledge bases
    description: >-
      A knowledge base (a `dataset` in the API) is a collection of embedded
      content an agent can retrieve from.
  - name: Knowledge base sources
    description: Attach and detach sources to a knowledge base.
  - name: Sources
    description: >-
      A source is a file or URL whose content is ingested, chunked, and
      embedded.
paths:
  /knowledge-base/datasets:
    post:
      tags:
        - Knowledge bases
      summary: Create a knowledge base
      description: >-
        Creates an empty knowledge base. Add content to it by [creating
        sources](#tag/sources) and attaching them. Requires a token with write
        access.
      operationId: createKnowledgeBase
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KnowledgeBaseCreateRequest'
            example:
              name: Product FAQ
              description: Top customer questions about our flagship product.
              embedding_model: text-embedding-3-small
              embedding_dimension: 1536
      responses:
        '200':
          description: The created knowledge base.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeBase'
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    KnowledgeBaseCreateRequest:
      type: object
      required:
        - name
        - embedding_model
        - embedding_dimension
      properties:
        name:
          type: string
          description: Display name.
        description:
          type: string
          description: Optional description.
        embedding_model:
          $ref: '#/components/schemas/EmbeddingModel'
        embedding_dimension:
          $ref: '#/components/schemas/EmbeddingDimension'
    KnowledgeBase:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique knowledge base ID.
        organization_id:
          type: string
          description: Your organization ID.
        name:
          type: string
          description: Display name.
        description:
          type: string
          nullable: true
          description: Optional description.
        embedding_model:
          $ref: '#/components/schemas/EmbeddingModel'
        embedding_dimension:
          $ref: '#/components/schemas/EmbeddingDimension'
        source_count:
          type: integer
          nullable: true
          description: Number of sources attached.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    EmbeddingModel:
      type: string
      enum:
        - text-embedding-3-small
        - text-embedding-3-large
      description: The embedding model used to vectorize content.
    EmbeddingDimension:
      type: integer
      enum:
        - 768
        - 1536
        - 3072
      description: The dimensionality of the embeddings.
    Error:
      type: object
      properties:
        detail:
          type: string
          example: Dataset not found
  responses:
    BadRequest:
      description: The request could not be fulfilled (e.g. a resource limit was reached).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The token's role doesn't grant access to this action.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Personal access token. See Authentication.

````