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

# Set a connection's team binding

> Binds an OAuth connection to a team and optional default folder. Send `team_id: null` (or omit it)
to move the connection back to the personal account. A connected app can only change its own
binding; an app session must pass `client_id` in the body. API keys have no connection and get 400.
Returns the stored binding.




## OpenAPI

````yaml /openapi.yaml put /me/connection
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:
  /me/connection:
    put:
      tags:
        - Account
      summary: Set a connection's team binding
      description: >
        Binds an OAuth connection to a team and optional default folder. Send
        `team_id: null` (or omit it)

        to move the connection back to the personal account. A connected app can
        only change its own

        binding; an app session must pass `client_id` in the body. API keys have
        no connection and get 400.

        Returns the stored binding.
      operationId: setMyConnection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountConnectionRequest'
            example:
              team_id: 0b0a3e0e-1f64-4a6e-9a39-6b2f2f0c6a11
              workspace_id: null
      responses:
        '200':
          description: The stored binding
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountConnection'
        '400':
          description: >-
            Invalid body, API key used, or `client_id` missing
            (`invalid_request`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            No access to that team, or a connected app targeted another client
            (`forbidden`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Folder does not exist in the selected scope (`workspace_not_found`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Could not save the binding or resolve the team account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: The binding could not be read back (`binding_unavailable`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    AccountConnectionRequest:
      type: object
      properties:
        client_id:
          type: string
          description: >-
            Required for an app session; a connected app may omit it or must
            send its own.
        team_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Team to bind to, or null/omitted for the personal account.
        workspace_id:
          type:
            - string
            - 'null'
          description: Default folder in the selected scope, or null.
    AccountConnection:
      type: object
      description: Which team and default folder an OAuth connection works in.
      required:
        - client_id
        - team_id
        - team_slug
        - team_name
        - team_owner
        - workspace_id
        - status
      properties:
        client_id:
          type: string
        team_id:
          type:
            - string
            - 'null'
          description: Null means the personal account.
        team_slug:
          type:
            - string
            - 'null'
        team_name:
          type:
            - string
            - 'null'
        team_owner:
          type: boolean
          description: >-
            True when the user owns the bound team (owners manage its API keys;
            members only spend).
        workspace_id:
          type:
            - string
            - 'null'
          description: Default folder for the connection, if any.
        status:
          type: string
          enum:
            - ok
            - no_team_access
          description: >
            `ok` means the binding is usable (`team_id: null` is the normal
            personal case).

            `no_team_access` means the user can no longer act in the bound team;
            clients should refuse to

            generate rather than fall back to the personal balance.
    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:
    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.