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

# Upload a file to a collection

> Uploads a source document (PDF, DOCX, TXT, CSV, XLSX, etc.) directly to a collection. The file is stored in S3 and immediately queued for parsing and knowledge extraction. Max file size: 50 MB.



## OpenAPI

````yaml https://staging.aigmented.io/api/v1/openapi.json post /api/v1/collections/{id}/files/upload
openapi: 3.1.0
info:
  title: Aigmented API
  version: 1.0.0
  description: >-
    REST API for Aigmented — manage knowledge collections, upload files, search
    knowledge cards, and ask questions with LLM-powered answers.
  contact:
    name: Aigmented Support
    url: https://aigmented.com
servers:
  - url: https://aigmented.io
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Collections
    description: Create and manage knowledge collections
  - name: Files
    description: Upload and manage source documents
  - name: Search
    description: Semantic search over knowledge cards in a collection
  - name: Ask
    description: LLM-powered question answering over a collection
paths:
  /api/v1/collections/{id}/files/upload:
    post:
      tags:
        - Files
      summary: Upload a file to a collection
      description: >-
        Uploads a source document (PDF, DOCX, TXT, CSV, XLSX, etc.) directly to
        a collection. The file is stored in S3 and immediately queued for
        parsing and knowledge extraction. Max file size: 50 MB.
      operationId: uploadFileToCollection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Collection ID
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    The file to upload. Field name must be `file`. Supported
                    types: PDF, DOCX, DOC, TXT, MD, CSV, XLSX. Max 50 MB.
      responses:
        '201':
          description: File accepted and queued for processing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadResponse'
              example:
                file_id: 42
                filename: contract-2024.pdf
                status: processing
                content_type: application/pdf
                size_bytes: 1048576
        '400':
          description: No file provided or invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Collection not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: File exceeds the 50 MB size limit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '415':
          description: Unsupported file type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    UploadResponse:
      type: object
      properties:
        file_id:
          type: integer
          description: Database ID of the created file
        filename:
          type: string
        status:
          type: string
          enum:
            - processing
          description: File is queued for parsing/ingestion
        content_type:
          type: string
          description: Detected MIME type
        size_bytes:
          type: integer
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key (sk-...)
      description: >-
        Pass your API key as a Bearer token. Example: `Authorization: Bearer
        sk-xxxxxxxxxxxx`

````