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

> Creates one or more sources. Accepts an **array**.

- **URL sources** are crawled and ingested automatically.
- **File sources** return a `presigned_url` and `content_type` in the response — upload the file bytes to that URL, then mark the source ready with [Update a source](#tag/sources/put/knowledge-base/sources/{source_id}) (`file_upload_status: COMPLETE`).

Attach sources to a knowledge base with [Add sources to a knowledge base](#tag/knowledge-base-sources/post/knowledge-base/datasets/{dataset_id}/sources). Requires a token with write access.



## OpenAPI

````yaml /openapi-knowledge-base.json post /knowledge-base/sources
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/sources:
    post:
      tags:
        - Sources
      summary: Create sources
      description: >-
        Creates one or more sources. Accepts an **array**.


        - **URL sources** are crawled and ingested automatically.

        - **File sources** return a `presigned_url` and `content_type` in the
        response — upload the file bytes to that URL, then mark the source ready
        with [Update a
        source](#tag/sources/put/knowledge-base/sources/{source_id})
        (`file_upload_status: COMPLETE`).


        Attach sources to a knowledge base with [Add sources to a knowledge
        base](#tag/knowledge-base-sources/post/knowledge-base/datasets/{dataset_id}/sources).
        Requires a token with write access.
      operationId: createSources
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/SourceCreateRequest'
            examples:
              url:
                summary: URL source
                value:
                  - name: https://docs.example.com/getting-started
                    type: URL
                    chunking_strategy:
                      method: structure_based
              file:
                summary: File source
                value:
                  - name: faq.md
                    type: FILE
                    file_size: 20480
                    chunking_strategy:
                      method: fixed
                      chunk_size: 1000
      responses:
        '200':
          description: The created sources. File sources include an upload URL.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SourceCreateResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    SourceCreateRequest:
      type: object
      required:
        - name
        - type
        - chunking_strategy
      properties:
        id:
          type: string
          format: uuid
          description: Optional client-supplied ID. Generated if omitted.
        name:
          type: string
          description: File name (e.g. faq.md) for FILE, or a valid URL for URL.
        type:
          $ref: '#/components/schemas/SourceType'
        domain:
          type: string
          description: Domain, for URL sources.
        chunking_strategy:
          $ref: '#/components/schemas/ChunkingStrategy'
        file_size:
          type: integer
          description: Size in bytes, for file sources.
    SourceCreateResponse:
      allOf:
        - $ref: '#/components/schemas/Source'
        - type: object
          properties:
            presigned_url:
              type: string
              nullable: true
              description: >-
                For file sources: upload the file bytes here, then mark the
                source COMPLETE.
            content_type:
              type: string
              nullable: true
              description: The MIME type to use when uploading to presigned_url.
    SourceType:
      type: string
      enum:
        - FILE
        - URL
      description: Whether the source is an uploaded file or a crawled URL.
    ChunkingStrategy:
      type: object
      description: How the source's content is split into chunks before embedding.
      properties:
        method:
          type: string
          enum:
            - fixed
            - structure_based
          description: >-
            fixed splits by size; structure_based splits along the document's
            structure.
        chunk_size:
          type: integer
          default: 1000
          description: Target chunk size (used by the fixed method).
      required:
        - method
    Source:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique source ID.
        organization_id:
          type: string
        type:
          $ref: '#/components/schemas/SourceType'
        name:
          type: string
          description: File name (FILE) or URL (URL).
        domain:
          type: string
          nullable: true
          description: Domain, for URL sources.
        file_upload_status:
          $ref: '#/components/schemas/UploadStatus'
        chunking_strategy:
          $ref: '#/components/schemas/ChunkingStrategy'
        file_size:
          type: integer
          nullable: true
          description: Size in bytes, for file sources.
        description:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        detail:
          type: string
          example: Dataset not found
    UploadStatus:
      type: string
      enum:
        - PENDING
        - IN_PROGRESS
        - COMPLETE
        - FAILED
      description: Upload/ingestion status of the source's content.
  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.

````