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

# Create KB Source

> Creates a new knowledge base source with inline content. Automatically triggers indexing for vector search. For file uploads, use the upload endpoint instead.



## OpenAPI

````yaml post /knowledge-base/sources
openapi: 3.0.1
info:
  title: Attention Service V2
  description: Attention Service API V2
  termsOfService: https://www.attention.com/terms-of-use
  contact:
    name: Attention Team
    url: https://docs.attention.com/welcome
    email: support@attention.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.8.0
servers:
  - url: https://api.attention.tech/v2
security:
  - APIKeyHeader: []
paths:
  /knowledge-base/sources:
    post:
      tags:
        - Knowledge Base
      summary: Create KB Source
      description: >-
        Creates a new knowledge base source with inline content. Automatically
        triggers indexing for vector search. For file uploads, use the upload
        endpoint instead.
      operationId: createKBSource
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKBSourceRequest'
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/CreateKBSourceRequest'
        required: true
      responses:
        '201':
          description: KB source created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KBSourceResponse'
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/KBSourceResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Valid API key required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateKBSourceRequest:
      required:
        - title
      type: object
      properties:
        title:
          maxLength: 500
          type: string
          description: Title of the KB source
        content:
          maxLength: 524288
          type: string
          description: Content of the source (required for manual entries)
        format:
          type: string
          description: >-
            Content format (defaults to text/markdown). For PDF files, use the
            upload endpoint instead.
          default: text/markdown
          enum:
            - text/markdown
            - text/html
            - text/plain
      example:
        title: Q4 Product Launch Playbook
        content: |-
          # Product Launch Playbook

          ## Overview
          This document covers the key steps for launching our Q4 product line.

          ## Timeline
          - Week 1: Internal enablement
          - Week 2: Beta launch
          - Week 3: GA release
        format: text/markdown
    KBSourceResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/KBSource'
      example:
        data:
          type: kb_sources
          id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
          attributes:
            title: Q4 Product Launch Playbook
            source_type: manual
            content: |-
              # Product Launch Playbook

              ## Overview
              This document covers the key steps...
            format: text/markdown
            status: indexed
            file_size: 4096
            chunk_count: 12
            created_at: '2025-01-15T10:30:00Z'
            updated_at: '2025-01-15T10:35:00Z'
    Error:
      type: object
      properties:
        id:
          type: string
          description: A unique identifier for the error.
        status:
          type: string
          description: >-
            The HTTP status code applicable to this problem, expressed as a
            string value.
        code:
          type: string
          description: An application-specific error code, expressed as a string value.
        title:
          type: string
          description: A short, human-readable summary of the problem.
        detail:
          type: string
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
        source:
          type: object
          properties:
            pointer:
              type: string
            parameter:
              type: string
        meta:
          type: object
          properties: {}
      example:
        id: not_found_error
        status: '404'
        code: '404'
        title: Not Found Error
        detail: The requested resource was not found
        source:
          pointer: /data/attributes/id
    KBSource:
      type: object
      properties:
        type:
          type: string
          description: Resource type
        id:
          type: string
          description: Unique identifier of the KB source
        attributes:
          $ref: '#/components/schemas/KBSourceAttributes'
      example:
        type: kb_sources
        id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        attributes:
          title: Q4 Product Launch Playbook
          source_type: manual
          format: text/markdown
          status: indexed
          file_size: 4096
          chunk_count: 12
          created_at: '2025-01-15T10:30:00Z'
          updated_at: '2025-01-15T10:35:00Z'
    KBSourceAttributes:
      type: object
      properties:
        title:
          type: string
          description: Title of the KB source
        source_type:
          type: string
          description: 'Type of source: manual (inline content) or upload (S3 file)'
          enum:
            - manual
            - upload
        content:
          type: string
          description: Content of the source (present on get, absent on list)
        format:
          type: string
          description: >-
            Content format (e.g. text/markdown, application/pdf, text/html,
            text/plain)
        status:
          type: string
          description: Processing status of the source
          enum:
            - pending
            - uploading
            - indexing
            - indexed
            - failed
        file_size:
          type: integer
          description: File size in bytes
        chunk_count:
          type: integer
          description: Number of indexed chunks
        created_at:
          type: string
          description: Creation timestamp
          format: date-time
        updated_at:
          type: string
          description: Last update timestamp
          format: date-time
      example:
        title: Q4 Product Launch Playbook
        source_type: manual
        content: |-
          # Product Launch Playbook

          ## Overview
          This document covers the key steps...
        format: text/markdown
        status: indexed
        file_size: 4096
        chunk_count: 12
        created_at: '2025-01-15T10:30:00Z'
        updated_at: '2025-01-15T10:35:00Z'
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      name: Authorization
      in: header

````