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

# Get a template

> Returns one template including its TSX source in `document.content`.
Approved templates are visible to everyone; others only to their author
(everyone else gets 404).




## OpenAPI

````yaml /openapi.yaml get /templates/{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:
  /templates/{id}:
    parameters:
      - name: id
        in: path
        required: true
        description: Template id
        schema:
          type: string
          format: uuid
    get:
      tags:
        - Templates
      summary: Get a template
      description: |
        Returns one template including its TSX source in `document.content`.
        Approved templates are visible to everyone; others only to their author
        (everyone else gets 404).
      operationId: getTemplate
      responses:
        '200':
          description: The template
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Template'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: invalid_request
                  message: Request failed validation
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Template or document not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: not_found
                  message: Template not found
components:
  schemas:
    Template:
      type: object
      description: A community-published render template
      properties:
        id:
          type: string
          format: uuid
        documentId:
          type: string
          format: uuid
          description: The template's own (frozen) copy of the source document
        sourceDocumentId:
          type:
            - string
            - 'null'
          description: The document the author published it from
        userId:
          type: string
          description: Author user id
        description:
          type: string
        tags:
          type:
            - array
            - 'null'
          items:
            type: string
        status:
          type: string
          description: Moderation status. Only `approved` templates are public.
          example: approved
        useCount:
          type: integer
        favoriteCount:
          type: integer
        isFavorited:
          type: boolean
          description: Whether the calling user has favorited it
        thumbnailObjectPosition:
          type: string
          example: center center
        videoObjectPosition:
          type: string
          example: center center
        isServiceTemplate:
          type: boolean
        previewUrl:
          type:
            - string
            - 'null'
          description: Short autoplay clip; null until the preview is ready
        createdAt:
          type: string
          format: date-time
        document:
          $ref: '#/components/schemas/TemplateDocument'
        thumbnailUrl:
          type:
            - string
            - 'null'
        outputMediaUrl:
          type:
            - string
            - 'null'
        outputMediaType:
          type:
            - string
            - 'null'
        durationMs:
          type:
            - integer
            - 'null'
          description: Output video duration in milliseconds
        author:
          $ref: '#/components/schemas/TemplateAuthor'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: model_not_found
            message:
              type: string
              example: 'Unknown model: flux-shnell'
            details: {}
    TemplateDocument:
      type: object
      description: The document that holds the template's TSX source
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        content:
          type:
            - string
            - 'null'
          description: varg TSX source of the template
        metadata:
          type:
            - object
            - 'null'
          additionalProperties: true
        kind:
          type: string
          example: media
        visibility:
          type: string
          example: private
        createdBy:
          type: string
        projectId:
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
    TemplateAuthor:
      type: object
      properties:
        id:
          type: string
          description: Author user id
        displayName:
          type:
            - string
            - 'null'
        avatarUrl:
          type:
            - string
            - 'null'
  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.