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

# Upload File

> Upload a file into a context. The file is validated against the context's rules (allowed extensions, max size, blank/corrupt rejection, virus scanning) before being stored. If any check fails, the upload is rejected and the reason is returned.



## OpenAPI

````yaml POST /api/v1/files/upload
openapi: 3.0.3
info:
  title: Uplint API
  version: 0.1.0
  description: >-
    Uplint is a file safety and integrity platform. Upload files through
    context-aware pipelines that automatically validate integrity, detect blank
    or placeholder content, and scan for viruses — all behind a single API.


    This specification covers the core Uplint REST API:


    - **API Keys** — Create and manage scoped API keys for programmatic access.

    - **File Contexts** — Define upload pipelines with per-context rules
    (allowed extensions, size limits, blank/corrupt rejection, virus scanning,
    rate limits, and storage quotas).

    - **Files** — Upload, list, download, inspect, and delete files. Every
    upload runs through the validation pipeline configured on its context.


    All endpoints are tenant-scoped. Authenticate with an API key or JWT token
    via the `Authorization` header.
  contact:
    name: Uplint Team
    url: https://uplint.dev
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://api.uplint.dev
    description: Production
  - url: http://localhost:8000
    description: Local development
security:
  - BearerAuth: []
tags:
  - name: API Keys
    description: >-
      Create, list, inspect, update, and revoke API keys. Each key carries
      scoped permissions (`upload`, `download`, `metadata`, `delete`, `admin`)
      and is bound to the authenticated tenant.
  - name: File Contexts
    description: >-
      File contexts define upload pipelines. Each context specifies allowed
      extensions, max file size, whether to reject blank or corrupt files, virus
      scanning, rate limits, and storage quotas. Files are always uploaded into
      a context.
  - name: Files
    description: >-
      Upload, list, download, inspect metadata, and delete files. Every upload
      is validated against its context rules before storage.
  - name: Storage Buckets
    description: >-
      Manage the S3 buckets a tenant stores files in. Each tenant can register
      multiple buckets (bring-your-own S3 credentials); one is the **default**
      (fallback) bucket, and file contexts can be routed to any active bucket.
      All storage endpoints require an `admin`-scoped API key.
paths:
  /api/v1/files/upload:
    post:
      tags:
        - Files
      summary: Upload file
      description: >-
        Upload a file into a context. The file is validated against the
        context's rules (allowed extensions, max size, blank/corrupt rejection,
        virus scanning) before being stored. If any check fails, the upload is
        rejected and the reason is returned.
      operationId: uploadFile
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - context
              properties:
                file:
                  type: string
                  format: binary
                  description: The file to upload.
                context:
                  type: string
                  description: The context key to upload into (e.g. `patient_reports`).
                metadata:
                  type: string
                  description: Optional JSON object string with custom metadata (max 4 KB).
                  example: '{"department": "radiology", "patient_id": "P-12345"}'
      responses:
        '201':
          description: File uploaded and validated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse_FileUpload'
              example:
                status: SUCCESS
                message: File uploaded
                data:
                  file_id: 6612f1a2c3b4d5e6f7890abc
                  original_filename: report.pdf
                  content_type: application/pdf
                  size_bytes: 843776
                  context_key: patient_reports
                  metadata:
                    department: radiology
                    patient_id: P-12345
                timestamp: '2026-02-10T12:00:00Z'
        '400':
          description: >-
            Upload rejected — file failed validation (blank, corrupt, virus,
            wrong extension, oversized, quota exceeded).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Context not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded for this context or tenant.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SuccessResponse_FileUpload:
      type: object
      properties:
        status:
          type: string
          enum:
            - SUCCESS
        message:
          type: string
        data:
          $ref: '#/components/schemas/FileUploadResponse'
        timestamp:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - ERROR
        message:
          type: string
        errors:
          type: array
          items:
            type: string
        timestamp:
          type: string
          format: date-time
    FileUploadResponse:
      type: object
      properties:
        file_id:
          type: string
        original_filename:
          type: string
        content_type:
          type: string
        size_bytes:
          type: integer
        context_key:
          type: string
        metadata:
          type: object
          additionalProperties: true
  responses:
    Unauthorized:
      description: Missing, invalid, or expired authentication credentials.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: ERROR
            message: Invalid or missing API key
            errors:
              - Authentication required
            timestamp: '2026-02-10T12:00:00Z'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Pass an API key or JWT token. API keys can be sent as `Authorization:
        Bearer <key>` or `Authorization: <key>`.

````