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

# Upload bytes to an upload session

> Second step of the large-file flow started by `POST /files/upload-session`.
Send the raw file bytes as the request body (not multipart) with the
`Content-Type` from the session. Maximum size is 200 MB. A session
accepts one upload and expires after 1 hour.

This endpoint needs no API key: the unguessable `session_id` is the
credential, and CORS allows any origin so browser widgets can call it.
The file is registered in your account automatically; `registered` is
`false` only if registration failed after the bytes were stored, in
which case call `POST /files/import` with `public_url`.




## OpenAPI

````yaml /openapi.yaml put /files/upload/{session_id}
openapi: 3.1.0
info:
  title: varg API
  version: 2.0.0
  description: |
    Unified REST API for AI media generation at `api.varg.ai/v2`.

    One API key, ~80 models across 8 providers, async jobs, stable output URLs
    on `s3.varg.ai`, files with lineage, and transparent credit billing
    (1 credit = 1 cent = $0.01).

    **The async job pattern:** every generation request returns `202 Accepted`
    with a job object (`status: queued`). Poll `GET /jobs/{id}` until the job
    reaches a terminal status (`completed`, `failed`, or `cancelled`), then read
    `output.outputs[0].url`. Alternatively, set `options.webhook_url` in the
    request to receive an HMAC-signed callback when the job finishes.
servers:
  - url: https://api.varg.ai/v2
security:
  - bearerAuth: []
tags:
  - name: Generation
    description: >-
      Create generation jobs (image, video, speech, music, transcription,
      ffmpeg, render, pipeline)
  - name: Tools
    description: Discover tools, their schemas, and call any tool generically
  - name: Jobs
    description: Poll and manage job lifecycle
  - name: Files
    description: Upload, import, probe, and manage files
  - name: Folders
    description: Group files into folders and file generated output automatically
  - name: Lineage
    description: Resolve which job produced a file
  - name: Presets
    description: Browse and apply reusable parameter values — voices, styles
  - name: Templates
    description: Browse, publish, use and render community templates
  - name: Pricing
    description: Estimate costs and browse the price catalog
  - name: Billing
    description: Balance, usage, and transaction history
  - name: Analytics
    description: >-
      Spend, runs and files over time — summaries, time series, breakdowns,
      activity
  - name: Account
    description: Identity and API key management
paths:
  /files/upload/{session_id}:
    put:
      tags:
        - Files
      summary: Upload bytes to an upload session
      description: >
        Second step of the large-file flow started by `POST
        /files/upload-session`.

        Send the raw file bytes as the request body (not multipart) with the

        `Content-Type` from the session. Maximum size is 200 MB. A session

        accepts one upload and expires after 1 hour.


        This endpoint needs no API key: the unguessable `session_id` is the

        credential, and CORS allows any origin so browser widgets can call it.

        The file is registered in your account automatically; `registered` is

        `false` only if registration failed after the bytes were stored, in

        which case call `POST /files/import` with `public_url`.
      operationId: uploadFileToSession
      parameters:
        - name: session_id
          in: path
          required: true
          description: The `session_id` from `POST /files/upload-session`
          schema:
            type: string
          example: file_abc123
      requestBody:
        required: true
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
          '*/*':
            schema:
              type: string
              format: binary
      responses:
        '200':
          description: Bytes stored
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadSessionResult'
              examples:
                stored:
                  value:
                    ok: true
                    public_url: https://s3.varg.ai/files/acc_x/file_abc123.mp4
                    size: 48234112
                    media_type: video/mp4
                    file_id: file_abc123
                    registered: true
        '400':
          description: Empty body (`empty_body`) or missing session id (`missing_session`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '410':
          description: >-
            Session not found, expired, or already used (`session_expired`).
            Create a new session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: File larger than 200 MB (`file_too_large`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Storing the file failed (`upload_failed`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security: []
components:
  schemas:
    UploadSessionResult:
      type: object
      required:
        - ok
        - public_url
        - size
        - media_type
        - registered
      properties:
        ok:
          type: boolean
        public_url:
          type: string
        size:
          type: integer
          description: Bytes stored
        media_type:
          type: string
        file_id:
          type:
            - string
            - 'null'
          description: Null when registration failed (`registered` is false)
        registered:
          type: boolean
          description: Whether the file was added to your Files
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: model_not_found
            message:
              type: string
              example: 'Unknown model: flux-shnell'
            details: {}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        varg API key (`varg_...`). Get one at [app.varg.ai](https://app.varg.ai)
        or run `bunx vargai login`. App sessions may alternatively send a
        Supabase JWT.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.