> ## 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.

# Add files to a folder

> Adds up to 100 files to the folder. A file can be in several folders.
Partial success: the response sorts every requested id into `linked`,
`already_linked` or `not_found` (unknown or not owned by the caller),
so one bad id does not lose the rest.




## OpenAPI

````yaml /openapi.yaml post /workspaces/{id}/files
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:
  /workspaces/{id}/files:
    post:
      tags:
        - Folders
      summary: Add files to a folder
      description: |
        Adds up to 100 files to the folder. A file can be in several folders.
        Partial success: the response sorts every requested id into `linked`,
        `already_linked` or `not_found` (unknown or not owned by the caller),
        so one bad id does not lose the rest.
      operationId: addFilesToFolder
      parameters:
        - name: id
          in: path
          required: true
          description: Folder id (uuid) or slug.
          schema:
            type: string
          example: campaign-assets
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FolderFilesRequest'
      responses:
        '200':
          description: Result per file id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FolderFilesResult'
              example:
                linked:
                  - file_abc123
                already_linked: []
                not_found:
                  - file_typo
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Unknown folder (or not owned by the caller)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: workspace_not_found
                  message: Unknown workspace
components:
  schemas:
    FolderFilesRequest:
      type: object
      required:
        - file_ids
      properties:
        file_ids:
          type: array
          minItems: 1
          maxItems: 100
          items:
            type: string
          example:
            - file_abc123
            - file_def456
    FolderFilesResult:
      type: object
      description: Partial success. Each requested file id lands in exactly one bucket.
      required:
        - linked
        - already_linked
        - not_found
      properties:
        linked:
          type: array
          description: Files newly added to the folder.
          items:
            type: string
        already_linked:
          type: array
          description: Files that were already in the folder.
          items:
            type: string
        not_found:
          type: array
          description: Ids that do not exist or are not owned by the caller.
          items:
            type: string
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: model_not_found
            message:
              type: string
              example: 'Unknown model: flux-shnell'
            details: {}
  responses:
    ValidationError:
      description: Request body failed validation
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalid:
              value:
                error:
                  code: invalid_request
                  message: 'Body validation failed (text: Required)'
    Unauthorized:
      description: Missing or invalid API key / JWT
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            unauthorized:
              value:
                error:
                  code: unauthorized
                  message: Invalid or missing API key or JWT
  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.