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

# Create a new datasource

> Creates a datasource shell when only a display name is provided. When file_id is provided, the uploaded file is queued for chunking and ingestion.

<Note>
  **Related guide**: Knowledge bases guide. See the [Knowledge bases guide](/docs/ai-studio/ai-engineering/knowledge-bases) for a walkthrough with examples.
</Note>


## OpenAPI

````yaml post /v2/knowledge/{knowledge_id}/datasources
openapi: 3.1.0
info:
  title: orq.ai API
  version: '2.0'
  description: orq.ai API documentation
servers:
  - url: https://my.orq.ai
security:
  - ApiKey: []
tags:
  - name: Chunking
    description: Split text into smaller chunks for retrieval and generation workflows.
  - name: File Systems
    description: >-
      Create and manage persistent file systems that agents and MCP clients read
      from and write to.
  - name: Knowledge Bases
    description: Create and manage knowledge bases used by agents and retrieval workflows.
  - name: Memory Stores
    description: Create and manage memory stores, memories, and memory documents.
  - name: Evals
    description: Run an evaluator against a conversation and its result
  - description: List models available through the AI Router.
    name: Models
  - name: Policies
  - name: Alerts
    description: >-
      Alerts evaluate a Reporting API metric on a fixed interval and fire
      notifications through notifiers when the value breaches a threshold. Each
      breach opens a trigger that tracks the incident until the value recovers.
  - name: Annotation Queues
    description: Annotation queues collect spans for human review.
  - name: API keys
    description: >-
      API keys authenticate programmatic access to the workspace. They expose
      opaque tokens, per-domain access grants, and budget and rate-limit
      constraints.
  - name: Audit Logs
    description: Audit logs record workspace entity changes and access-relevant events.
  - name: Budgets
    description: >-
      Budgets govern spend, token usage, and request rate across six scopes:
      workspace, project, identity, API key, provider, and model. Every
      applicable budget is enforced, and the most restrictive limit applies per
      dimension.
  - name: Files
    description: File upload and retrieval operations.
  - name: Guardrail Rules
    description: >-
      Guardrail Rules conditionally enforce evaluators and plugins for AI
      Gateway traffic. Rules may be scoped to a project or the whole workspace.
  - name: Identities
    description: >-
      Identities represent end users from your system for usage and engagement
      tracking.
  - name: Management keys
    description: >-
      Management keys are workspace-scoped credentials that authenticate
      programmatic access to workspace administration surfaces (API keys,
      budgets). Unlike project-scoped API keys, a management key always operates
      at the workspace level.
  - name: MCP Gateway
    description: >-
      Register upstream MCP servers, discover and sync their tools, and assemble
      gateways that expose a curated tool surface to MCP clients.
  - name: Model Catalog
    description: >-
      Browse the orq.ai model catalog: every model orq offers, across every
      provider, with pricing, capabilities and benchmark data. List endpoints
      only return models that are not deprecated. This API is public, requires
      no authentication, and is rate limited to 120 requests per minute per IP.
      Responses carry a 5-minute cache-control max-age.
  - name: Notifiers
    description: Notifier destinations used to send delivery and workflow notifications.
  - name: Projects
    description: Projects organize resources within a workspace
  - name: Routing Rules
    description: >-
      Routing Rules conditionally select models and enforce request plugins for
      AI Gateway traffic. Rules are evaluated by ascending priority and may be
      scoped to a project or the whole workspace.
  - name: Skills
    description: >-
      Skills are modular instructions you can use to codify processes and
      conventions
  - name: Smart Routers
    description: >-
      Create and manage workspace Smart Routers. A Smart Router selects a model
      from an eligible pool for each request according to a quality, balanced,
      or cost profile.
  - name: Webhooks
    description: >-
      Create and manage webhooks that deliver workspace events to external HTTPS
      endpoints.
  - name: Workspace Security
    description: >-
      Workspace-level domain verification and IP allowlist controls. These
      operations are restricted to workspace administrators.
  - name: Workspace Settings
    description: >-
      Workspace-level settings managed with a workspace credential. A workspace
      is the tenant, so these settings are a singleton — there is nothing to
      create or delete, only read and update.
  - name: Responses
  - description: Run agents on a cron cadence. Minimum firing interval is 1 hour.
    name: Agent Schedules
  - name: Embeddings
  - name: Logs
    description: >-
      OpenTelemetry log query API. Search, filter, aggregate, and facet log
      records ingested via OTLP.
  - name: Reporting
    description: >-
      GenAI reporting API over canonical analytics rollups. Accepts a metric
      name, time range, grain, group-by, and filters; returns a typed time
      series and optional totals.
  - name: Traces
    description: >-
      Query and inspect ingested trace data: search trace summaries, aggregate
      metrics, and read individual traces and their spans.
externalDocs:
  url: https://docs.orq.ai
  description: orq.ai Documentation
paths:
  /v2/knowledge/{knowledge_id}/datasources:
    post:
      tags:
        - Knowledge Bases
      summary: Create a new datasource
      description: >-
        Creates a datasource shell when only a display name is provided. When
        file_id is provided, the uploaded file is queued for chunking and
        ingestion.
      operationId: CreateDatasource
      parameters:
        - name: knowledge_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DatasourcesServiceCreateRequest'
        required: true
      responses:
        '200':
          description: Datasource successfully created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Datasource'
        '500':
          description: Failed to create datasource
      x-code-samples:
        - lang: curl
          label: Core - Create datasource
          source: |
            curl --request POST \
              --url 'https://my.orq.ai/v2/knowledge/01JEXAMPLEKNOWLEDGEBASE01/datasources' \
              --header "Authorization: Bearer $ORQ_API_KEY" \
              --header 'Content-Type: application/json' \
              --data '{
                "display_name": "Product guide",
                "file_id": "file_01JEXAMPLE00000000000001",
                "chunking_options": {
                  "chunking_configuration": {
                    "type": "advanced",
                    "chunk_max_characters": 800,
                    "chunk_overlap": 100
                  }
                }
              }'
components:
  schemas:
    DatasourcesServiceCreateRequest:
      required: []
      type: object
      properties:
        display_name:
          type: string
        description:
          type:
            - string
            - 'null'
          description: The description of the knowledge base
        file_id:
          type: string
        chunking_options:
          $ref: '#/components/schemas/DatasourceChunkingOptions'
        id:
          type: string
          description: >-
            Compatibility fields used by the former datasource shell/legacy
            route.
        attachment:
          $ref: '#/components/schemas/DatasourceAttachment'
        metadata:
          $ref: '#/components/schemas/CountMetadata'
    Datasource:
      required:
        - _id
        - display_name
        - status
        - created
        - updated
        - knowledge_id
        - chunks_count
      type: object
      properties:
        display_name:
          type: string
        description:
          type:
            - string
            - 'null'
          description: The description of the knowledge base
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
            - queued
        file_id:
          type:
            - string
            - 'null'
          description: The unique identifier of the file used to create the datasource.
        created:
          type: string
        updated:
          type: string
        created_by_id:
          type:
            - string
            - 'null'
          format: uuid
          pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          readOnly: true
          description: The user ID of the creator of the knowledge base
        update_by_id:
          type:
            - string
            - 'null'
          format: uuid
          pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          readOnly: true
          description: The user ID of the last user who updated the knowledge base
        knowledge_id:
          type: string
        chunks_count:
          type: number
          format: double
        processing_attempts:
          type: array
          items:
            $ref: '#/components/schemas/ProcessingAttempt'
          description: >-
            Additive compatibility fields formerly available only from
            database-shaped responses.
        metadata:
          $ref: '#/components/schemas/CountMetadata'
        attachment:
          $ref: '#/components/schemas/DatasourceAttachment'
        _id:
          type: string
    DatasourceChunkingOptions:
      type: object
      properties:
        chunking_configuration:
          $ref: '#/components/schemas/ChunkingConfiguration'
        chunking_cleanup_options:
          $ref: '#/components/schemas/ChunkingCleanupOptions'
    DatasourceAttachment:
      type: object
      properties:
        id:
          type: string
        object_name:
          type: string
    CountMetadata:
      type: object
      properties:
        words_count:
          type: number
          format: double
        sentences_count:
          type: number
          format: double
        paragraphs_count:
          type: number
          format: double
        tokens_count:
          type: number
          format: double
        characters_count:
          type: number
          format: double
        chunks_count:
          type: number
          format: double
    ProcessingAttempt:
      required:
        - id
        - started_at
      type: object
      properties:
        id:
          type: string
        started_at:
          type: string
        queued_at:
          type: string
        completed_at:
          type: string
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ProcessingError'
        retryable:
          type: boolean
    ChunkingConfiguration:
      description: >-
        The chunking configuration settings for the datasource. Defaults to the
        system's standard chunking configuration if not specified.
      oneOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - default
          required:
            - type
          description: >-
            Optimized chunking strategy focusing on speed and avoiding
            duplication of content chunks.
        - type: object
          properties:
            type:
              type: string
              enum:
                - advanced
            chunk_max_characters:
              type: number
              default: 500
              description: >-
                Defines the absolute maximum character length per chunk. Text
                elements exceeding this size will be automatically split into
                multiple chunks.
            chunk_overlap:
              type: number
              default: 0
              description: >-
                Specifies the number of characters to overlap between
                consecutive chunks. This overlap helps maintain semantic
                continuity when splitting large text elements.
          required:
            - type
          description: >-
            Provides advanced settings for customizing chunking behavior,
            enabling fine-grained control to better meet specific data
            processing needs.
    ChunkingCleanupOptions:
      type: object
      properties:
        delete_emails:
          type: boolean
        delete_credit_cards:
          type: boolean
        delete_phone_numbers:
          type: boolean
        clean_bullet_points:
          type: boolean
        clean_numbered_list:
          type: boolean
        clean_unicode:
          type: boolean
        clean_dashes:
          type: boolean
        clean_whitespaces:
          type: boolean
    ProcessingError:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````