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

# Create Source

> Registers a previously-uploaded file as a document source under a source batch and queues it for asynchronous parsing. Once `status: "success"`, the source is searchable in chat/search conversations that reference its `source_batch_id`.

**Important Notes:**
- **Prerequisite:** A source batch must be created first using `POST /v1/source_batches`
- **The file must already be in S3** before calling this endpoint. Two ways to get it there:
  - **Recommended:** call `POST /v1/sources/upload_url` to obtain a presigned PUT URL, upload the file directly via that URL, then pass the returned `file_key` here. No client-side AWS setup required.
  - **Alternative:** if you already have your own S3 staging bucket integrated with us, upload there and pass the resulting `file_key`.
- **Processing:** Sources are queued for asynchronous processing. Use `GET /v1/sources/{source_id}` to poll the processing status before using in conversations.
- **File Requirements:**
  - Supported formats: PDF, DOCX, XLSX, DOC, TXT, PPTX
  - Maximum size: 20MB per file
  - Maximum files per batch: 10 files
- **Usage in Conversations:**
  - Reference sources via `source_batch_id` in chat/search API requests
  - All sources in a batch are accessible when the batch is referenced
  - Sources remain available for reuse within conversations that reference their batch

**Workflow (presigned-URL path):**
1. `POST /v1/source_batches` → `source_batch_id`
2. `POST /v1/sources/upload_url` → `upload_url`, `file_key`, `content_type`
3. PUT the file body to `upload_url` with header `Content-Type: <content_type>`
4. `POST /v1/sources` (this endpoint) with `file_key` from step 2
5. Poll `GET /v1/sources/{source_id}` until `status: "success"`
6. Reference `source_batch_id` in chat/search requests



## OpenAPI

````yaml POST /v1/sources
openapi: 3.0.1
info:
  title: LinqAlpha API
  description: >-
    Linq helps finance professionals make informed decisions using
    Retrieval-Augmented Generation (RAG)-enhanced answers. By leveraging
    cutting-edge Large Language Models (LLM) and supplementary technology, Linq
    provides the most optimized responses based on your queries.
  version: 1.0.0
  license:
    name: MIT
servers:
  - url: https://api.linqalpha.com
security:
  - ApiKeyAuth: []
tags:
  - name: Search
    description: Search and generate responses
  - name: Data
    description: Data retrieval and mapping
  - name: Feedback
    description: Conversation feedback
  - name: RMS
    description: Research Management System
  - name: Source Management
    description: Source batch and file management
  - name: MCP
    description: >-
      LinqAlpha MCP — Financial data tools for AI assistants via Model Context
      Protocol
  - name: Connectors
    description: Customer Connectors — customer-owned MCP connector management
  - name: Briefing
    description: Briefing Agent — automated market briefings with scheduling and delivery
  - name: Status
    description: Sync status — check organization, document, and container sync progress
paths:
  /v1/sources:
    post:
      tags:
        - Source Management
      summary: Create Source
      description: >-
        Registers a previously-uploaded file as a document source under a source
        batch and queues it for asynchronous parsing. Once `status: "success"`,
        the source is searchable in chat/search conversations that reference its
        `source_batch_id`.


        **Important Notes:**

        - **Prerequisite:** A source batch must be created first using `POST
        /v1/source_batches`

        - **The file must already be in S3** before calling this endpoint. Two
        ways to get it there:
          - **Recommended:** call `POST /v1/sources/upload_url` to obtain a presigned PUT URL, upload the file directly via that URL, then pass the returned `file_key` here. No client-side AWS setup required.
          - **Alternative:** if you already have your own S3 staging bucket integrated with us, upload there and pass the resulting `file_key`.
        - **Processing:** Sources are queued for asynchronous processing. Use
        `GET /v1/sources/{source_id}` to poll the processing status before using
        in conversations.

        - **File Requirements:**
          - Supported formats: PDF, DOCX, XLSX, DOC, TXT, PPTX
          - Maximum size: 20MB per file
          - Maximum files per batch: 10 files
        - **Usage in Conversations:**
          - Reference sources via `source_batch_id` in chat/search API requests
          - All sources in a batch are accessible when the batch is referenced
          - Sources remain available for reuse within conversations that reference their batch

        **Workflow (presigned-URL path):**

        1. `POST /v1/source_batches` → `source_batch_id`

        2. `POST /v1/sources/upload_url` → `upload_url`, `file_key`,
        `content_type`

        3. PUT the file body to `upload_url` with header `Content-Type:
        <content_type>`

        4. `POST /v1/sources` (this endpoint) with `file_key` from step 2

        5. Poll `GET /v1/sources/{source_id}` until `status: "success"`

        6. Reference `source_batch_id` in chat/search requests
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSourceRequest'
            example:
              source_batch_id: 123e4567-e89b-12d3-a456-426614174000
              name: Q4_Revenue_Report.pdf
              file_key: uploaded_sources/2024/q4/revenue_report.pdf
      responses:
        '200':
          description: Source created and queued for processing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSourceResponse'
              example:
                source_id: 456e7890-e89b-12d3-a456-426614174001
                size: 2048576
                status: processing
        '400':
          description: >-
            Bad request - invalid file format, size exceeded, or invalid
            source_batch_id
        '401':
          description: Unauthorized - invalid or missing API key
        '404':
          description: Source batch not found
components:
  schemas:
    CreateSourceRequest:
      type: object
      properties:
        user_id:
          type: string
          description: User ID
          example: 123e4567-e89b-12d3-a456-426614174000
        organization_id:
          type: string
          format: uuid
          description: Organization ID
          example: 123e4567-e89b-12d3-a456-426614174000
        user_email:
          type: string
          description: User email
          example: john.doe@example.com
        user_name:
          type: string
          description: User name
          example: John Doe
        source_batch_id:
          type: string
          format: uuid
          description: >-
            ID of the source batch to add this source to. The batch must be
            created first via POST /v1/source_batches.
          example: 123e4567-e89b-12d3-a456-426614174000
        name:
          type: string
          description: >-
            Display name for the source, typically the original filename. Must
            not include a file extension.
          example: Q4_Revenue_Report
        file_key:
          type: string
          description: >-
            S3 object key path where the file is stored. The file must be
            accessible to the API service and meet format/size requirements
            (PDF, DOCX, XLSX, DOC, TXT, PPTX; max 20MB).
          example: uploaded_sources/2024/q4/revenue_report.pdf
      required:
        - source_batch_id
        - name
        - file_key
    CreateSourceResponse:
      type: object
      properties:
        source_id:
          type: string
          format: uuid
          description: >-
            Unique identifier for the created source. Use this ID to poll
            processing status via GET /v1/sources/{source_id}.
          example: 456e7890-e89b-12d3-a456-426614174001
        size:
          type: integer
          description: File size in bytes
          minimum: 0
          example: 2048576
        status:
          type: string
          description: >-
            Initial processing status (typically 'processing' when first
            created)
          enum:
            - processing
            - success
            - failed
          example: processing
      required:
        - source_id
        - size
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````