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

# Create Knowledge Base

> Create a knowledge base pipeline, optionally deploying it.

Set deploy=false to save as draft without deploying to Flink.



## OpenAPI

````yaml /openapi/openapi.json post /knowledge-bases/config
openapi: 3.1.0
info:
  title: Streamkap REST API
  description: >-
    The Streamkap REST API allows you to programmatically manage your CDC
    pipelines, sources, destinations, transforms, and more.


    Authenticate using a bearer token obtained from the [Access
    Token](/api-reference/auth/access-token) endpoint with your API client
    credentials.
  contact:
    name: Streamkap Support
    url: https://streamkap.com/
    email: support@streamkap.com
  license:
    name: Proprietary
  version: 2.0.0
servers:
  - url: https://api.streamkap.com
    description: Production
security: []
tags:
  - name: Agents
    description: Create, deploy, and manage Flink-based AI agents.
  - name: Agents Observability
    description: >-
      Read-only views over the MCP audit log: agent rollup, sessions, spans,
      histograms, external-agent verify.
  - name: Alerts
    description: Manage alert subscribers, preferences, and notification credentials.
  - name: Authentication
    description: Obtain and refresh access tokens, manage client credentials and roles.
  - name: Billing
    description: Retrieve usage metrics, summaries, and export billing data.
  - name: Consumer Groups
    description: List, inspect, and reset Kafka consumer group offsets.
  - name: Dashboard
    description: Retrieve organisation-level statistics and overview data.
  - name: Destinations
    description: Create, configure, and manage data destinations and their lifecycle.
  - name: Kafka Access
    description: Manage Kafka users and their access permissions.
  - name: Logs
    description: Query and summarise system logs.
  - name: Pipelines
    description: Create, configure, and manage CDC pipelines and their lifecycle.
  - name: Project Keys
    description: Manage project keys that bundle API credentials and optional Kafka access.
  - name: Schema Registry
    description: Browse schema subjects, versions, and retrieve schema definitions.
  - name: Services
    description: View and switch service metadata.
  - name: Sources
    description: >-
      Create, configure, and manage data sources, snapshots, and their
      lifecycle.
  - name: Tags
    description: Create, update, and manage resource tags for organisation.
  - name: Topics
    description: Browse topic details, statistics, configurations, metrics, and messages.
  - name: Transforms
    description: >-
      Create, deploy, and manage data transforms, unit tests, and implementation
      details.
paths:
  /knowledge-bases/config:
    post:
      tags:
        - Knowledge Bases
      summary: Create Knowledge Base
      description: |-
        Create a knowledge base pipeline, optionally deploying it.

        Set deploy=false to save as draft without deploying to Flink.
      operationId: createKnowledgeBase
      parameters:
        - name: deploy
          in: query
          required: false
          schema:
            type: boolean
            default: true
            title: Deploy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKnowledgeBaseRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeBaseResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - FronteggHTTPAuthentication: []
components:
  schemas:
    CreateKnowledgeBaseRequest:
      properties:
        name:
          type: string
          maxLength: 200
          minLength: 1
          title: Name
          description: Knowledge base display name
        description:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Description
          description: Human-readable context
        source:
          $ref: '#/components/schemas/KBSourceConfig'
        text:
          $ref: '#/components/schemas/KBTextConfig'
          description: Text template configuration
        embedding:
          $ref: '#/components/schemas/KBEmbeddingConfig'
        vectorStore:
          $ref: '#/components/schemas/KBVectorStoreConfig'
        processing:
          $ref: '#/components/schemas/KBProcessingConfig'
      additionalProperties: false
      type: object
      required:
        - name
        - source
        - embedding
        - vectorStore
      title: CreateKnowledgeBaseRequest
      description: >-
        Request body for POST /knowledge-bases/config — create a knowledge base
        pipeline.
    KnowledgeBaseResponse:
      properties:
        _id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        job_type:
          $ref: >-
            #/components/schemas/app__models__api__agents_api_models__flink_jobs__FlinkJobTypeEnum
        status:
          $ref: '#/components/schemas/FlinkJobStatusEnum'
        desired_status:
          anyOf:
            - $ref: '#/components/schemas/FlinkJobStatusEnum'
            - type: 'null'
        flink_job_name:
          type: string
          title: Flink Job Name
        flink_job_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Flink Job Id
        parallelism:
          type: integer
          title: Parallelism
          default: 1
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
        agent_config:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Agent Config
          description: KB config (secrets masked)
        created_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By
        created_timestamp:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created Timestamp
        updated_timestamp:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated Timestamp
      additionalProperties: true
      type: object
      required:
        - _id
        - name
        - job_type
        - status
        - flink_job_name
      title: KnowledgeBaseResponse
      description: >-
        Response model for knowledge base entities. Mirrors FlinkJobResponse
        shape.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    KBSourceConfig:
      properties:
        topic:
          anyOf:
            - type: string
              maxLength: 249
            - type: 'null'
          title: Topic
          description: >-
            Exact Kafka topic name (Kafka's own limit is 249). Mutually
            exclusive with ``topicPattern``. The deploy-time builder turns this
            into ``^re.escape(topic)$`` for the Java runtime.
        topicPattern:
          anyOf:
            - type: string
              maxLength: 1024
            - type: 'null'
          title: Topicpattern
          description: >-
            Regex pattern for input topics, e.g. ``^source_.*\.orders$``.
            Mutually exclusive with ``topic`` — set this only for programmatic
            multi-topic fan-in.
        inputSerialization:
          $ref: '#/components/schemas/AgentSerializationEnum'
          description: Input deserialization format
          default: JsonConfluent
        fields:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Fields
          description: Column-level filter — only these fields processed
        textFields:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Textfields
          description: Fields to include in the embedded text (if not using textTemplate)
        metadataFields:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Metadatafields
          description: Fields to store as vector metadata (filterable at query time)
      additionalProperties: false
      type: object
      title: KBSourceConfig
      description: |-
        Kafka source configuration for the knowledge base pipeline.

        Exactly one of ``topic`` or ``topicPattern`` must be set:

        - ``topic`` — exact Kafka topic name (the FE wizard's single-topic
          picker emits this). The service layer composes
          ``^re.escape(topic)$`` for the Java ``--topicMatcherRegex`` CLI
          arg, so the Java side keeps the regex-only contract.
        - ``topicPattern`` — escape hatch for tenants who genuinely need a
          multi-topic regex (e.g. fan-in of a sharded topic family). Not
          exposed by the FE wizard today — programmatic API callers only.

        The XOR rule is enforced by ``_topic_xor`` below: empty payload
        (neither set) and over-specified payload (both set) both 422.
    KBTextConfig:
      properties:
        textTemplate:
          type: string
          maxLength: 8000
          title: Texttemplate
          description: >-
            Template with ${field} placeholders, e.g. 'Customer ${customer_id}
            ordered ${product}'
          default: ''
      additionalProperties: false
      type: object
      title: KBTextConfig
      description: >-
        Text template configuration for composing the embedding input from
        record fields.
    KBEmbeddingConfig:
      properties:
        embeddingConnectionId:
          type: string
          maxLength: 64
          minLength: 1
          title: Embeddingconnectionid
          description: >-
            Reference to a saved AgentLlmConnection. The connection must
            advertise the 'embedding' capability.
        model:
          anyOf:
            - type: string
              maxLength: 200
            - type: 'null'
          title: Model
          description: >-
            Per-KB embedding-model override. ``None`` = use the connection's
            default embedding model (``embedding.model`` on the saved row).
        dimensions:
          anyOf:
            - type: integer
              maximum: 65536
              minimum: 1
            - type: 'null'
          title: Dimensions
          description: >-
            Per-KB dimensions override. ``None`` = use the connection's default
            (``embedding.dimensions`` on the saved row), or the provider default
            when neither is set.
        batchSize:
          anyOf:
            - type: integer
              maximum: 2048
              minimum: 1
            - type: 'null'
          title: Batchsize
          description: >-
            Per-KB batchSize override. ``None`` = use the connection's default
            (``embedding.batchSize`` on the saved row, falls back to 100).
      additionalProperties: false
      type: object
      required:
        - embeddingConnectionId
      title: KBEmbeddingConfig
      description: |-
        Embedding-side configuration for a knowledge base.

        Carries a reference to a saved ``AgentLlmConnection`` plus optional
        per-KB overrides of the connection's defaults. Credentials, provider,
        and the default model live on the connection — there is no inline
        apiKey / baseUrl path on a KB. The deploy-time resolver
        (``resolve_kb_connections``) reads the referenced connection's
        ``embedding`` defaults block, applies any per-KB overrides, and stamps
        the resulting bundle into the Flink CLI JSON.

        The referenced connection must carry ``'embedding'`` in its
        ``capabilities`` list and have a non-empty ``embedding.model`` — the
        validator inside ``resolve_saved_embedding_credentials`` raises 422 at
        deploy time otherwise so the FE error surfaces the cause without
        waiting for a Java runtime 4xx.
    KBVectorStoreConfig:
      properties:
        vectorStoreConnectionId:
          type: string
          maxLength: 64
          minLength: 1
          title: Vectorstoreconnectionid
          description: >-
            Reference to a saved AgentVectorStoreConnection. BE resolves
            credentials at deploy time.
        indexName:
          type: string
          maxLength: 200
          minLength: 1
          title: Indexname
          description: Index or collection name in the vector store
        namespace:
          anyOf:
            - type: string
              maxLength: 200
            - type: 'null'
          title: Namespace
          description: Namespace or partition within the index
        metric:
          type: string
          enum:
            - cosine
            - dot_product
            - euclidean
          title: Metric
          description: Distance metric
          default: cosine
      additionalProperties: false
      type: object
      required:
        - vectorStoreConnectionId
        - indexName
      title: KBVectorStoreConfig
      description: |-
        Vector store configuration for the knowledge base.

        References a lightweight ``AgentVectorStoreConnection`` by id. The BE
        resolves the connection's credentials (apiKey + endpoint) at deploy
        time. There is no inline-credentials path — KBs must reference a saved
        connection (the FE picker is the only authoring surface).
    KBProcessingConfig:
      properties:
        parallelism:
          type: integer
          maximum: 128
          minimum: 1
          title: Parallelism
          description: Flink parallelism
          default: 1
        checkpointIntervalMin:
          type: integer
          maximum: 60
          minimum: 1
          title: Checkpointintervalmin
          description: Checkpoint interval in minutes
          default: 5
        chunkSize:
          type: integer
          maximum: 8192
          minimum: 1
          title: Chunksize
          description: Text chunk size in tokens
          default: 512
        chunkOverlap:
          type: integer
          maximum: 4096
          minimum: 0
          title: Chunkoverlap
          description: Overlap tokens between chunks
          default: 50
      additionalProperties: false
      type: object
      title: KBProcessingConfig
      description: Processing configuration for the knowledge base pipeline.
    app__models__api__agents_api_models__flink_jobs__FlinkJobTypeEnum:
      type: string
      enum:
        - pyflink
        - jar
        - agent_config
        - knowledge_base
      title: FlinkJobTypeEnum
    FlinkJobStatusEnum:
      type: string
      enum:
        - CREATED
        - DEPLOYING
        - RUNNING
        - CANCELLING
        - CANCELLED
        - FAILED
        - FINISHED
      title: FlinkJobStatusEnum
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    AgentSerializationEnum:
      type: string
      enum:
        - JsonConfluent
        - AvroConfluent
      title: AgentSerializationEnum
  securitySchemes:
    FronteggHTTPAuthentication:
      type: http
      scheme: bearer

````