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

# List templates

> List all templates. Pass `?draft=true` to list draft templates instead of published ones.

The response is paged stream-style: `results_total` is the number of items in this response, `total_messages` is the total available, and `next_sequence` is the cursor for the next page.



## OpenAPI

````yaml /api-reference/endpoint/documents/openapi.json get /file-generator/templates
openapi: 3.1.0
info:
  title: Documents API
  description: >-
    Document templates, generated documents, e-signature requests, and checkbox
    approvals. Template and document routes are served under `/file-generator`,
    approval routes under `/workspaces/approvals`.
  version: 1.2.0
servers:
  - url: https://api.quiva.ai
    description: Production API server
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Templates
    description: >-
      Template lifecycle — create, read, publish, validate, trigger, and delete
      document templates. Templates follow a **draft → published** model: writes
      (`POST`, `PATCH`) always target the draft version, and `POST
      /templates/{key}/publish` promotes the draft. Document generation only
      ever uses the published version, so drafts can be edited safely without
      affecting production output. A template's `source` is a DOCX file
      containing angular-expression tags rendered at trigger time.
  - name: Documents
    description: >-
      Document lifecycle — read, update, and delete generated documents. A
      document record is created immediately when a template is triggered and is
      updated asynchronously: first with the generated `output.key` (an `obj://`
      or `kv://` storage URI) or `errors`, then with `signatures` progress as
      signatories sign.
  - name: Signatures
    description: >-
      E-signature workflows powered by HelloSign (Dropbox Sign). Signature
      requests are created automatically when a triggered template defines
      `signatories`. Each signatory tracks a status lifecycle of `DRAFT → SENT →
      SIGNED`, with `EXPIRED` (validity window elapsed) and `FAILED`
      (delivery/signing error) as terminal failure states. Embedded signing URLs
      can be generated for signatures created in embedded mode.
  - name: Approvals
    description: Checkbox approval of a workspace file, recorded as e-signature evidence.
  - name: Generation
  - name: Template Source
paths:
  /file-generator/templates:
    get:
      tags:
        - Templates
      summary: List templates
      description: >-
        List all templates. Pass `?draft=true` to list draft templates instead
        of published ones.


        The response is paged stream-style: `results_total` is the number of
        items in this response, `total_messages` is the total available, and
        `next_sequence` is the cursor for the next page.
      operationId: listTemplates
      parameters:
        - $ref: '#/components/parameters/QueryDraft'
      responses:
        '200':
          description: Templates listed successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateListResponse'
              example:
                body:
                  results:
                    - key: invoice-template
                      label: Standard Invoice
                      source:
                        key: invoice.docx
                        content_type: >-
                          application/vnd.openxmlformats-officedocument.wordprocessingml.document
                      output:
                        content_type: application/pdf
                        bucket: microstrate-documents
                        folder: invoices
                      signatories: []
                      sub_templates: []
                  results_total: 1
                  next_sequence: 42
                  total_messages: 1
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  parameters:
    QueryDraft:
      name: draft
      in: query
      required: false
      description: >-
        When `true`, targets the draft version of a template. Defaults to
        published.
      schema:
        type: boolean
        default: false
  schemas:
    TemplateListResponse:
      type: object
      properties:
        body:
          type: object
          properties:
            results:
              type: array
              items:
                $ref: '#/components/schemas/Template'
            results_total:
              type: integer
              description: Number of results in this response.
              example: 3
            next_sequence:
              type: integer
              description: Sequence number to use for the next page.
              example: 42
            total_messages:
              type: integer
              description: Total number of messages in the stream for this subject.
              example: 3
    Template:
      type: object
      required:
        - key
      properties:
        key:
          type: string
          description: Unique identifier for the template.
          example: invoice-template
        label:
          type: string
          description: Human-readable display name.
          example: Standard Invoice
        source:
          type: object
          required:
            - key
            - content_type
          description: >-
            Reference to the source template file in object storage (the
            document object store bucket). DOCX sources are processed with the
            angular expression parser: tags such as `{client_name}`,
            `{#items}…{/items}` (loops), `{price + tax}` (operators), and
            `{amount | formatcurrency:'EUR'}` (filters) are evaluated against
            the trigger payload to produce the final output. PDF sources
            (`application/pdf`) are passed through — and merged with
            sub-templates — without expression rendering, and can only output
            PDF.
          properties:
            key:
              type: string
              description: >-
                Template file reference. Either a simple path (uses default
                `microstrate-documents` bucket) or a full storage URL. Formats:
                `templates/invoice.docx` (default) |
                `obj://bucket-name/path/file.docx` (object store) |
                `kv://bucket-name/path/file.docx` (key-value store).
              examples:
                - templates/invoice.docx
                - obj://microstrate-documents/templates/invoice.docx
                - obj://external-bucket/templates/contract.docx
            content_type:
              type: string
              description: MIME type of the source file.
              example: >-
                application/vnd.openxmlformats-officedocument.wordprocessingml.document
        output:
          $ref: '#/components/schemas/TemplateOutput'
        signatories:
          type: array
          items:
            $ref: '#/components/schemas/TemplateSignatory'
          description: >-
            Signatories to request e-signatures from once the document is
            generated. `name` and `email` support expression placeholders
            resolved against the trigger payload; entries whose rendered email
            is missing or invalid are skipped. An empty/absent array means no
            signature request is sent.
        sub_templates:
          type: array
          items:
            $ref: '#/components/schemas/TemplateSubTemplate'
          description: >-
            Additional published templates rendered with the same payload and
            merged after the main template in array order. Entries with
            `conditions` are included only when the rule-engine conditions
            evaluate to true against the trigger payload.
        modified:
          type: integer
          readOnly: true
          description: Server-set last-modified unix timestamp (read-only).
        sequence:
          type: integer
          readOnly: true
          description: Event-stream sequence number (read-only).
        subject:
          type: string
          readOnly: true
          description: Messaging subject of the aggregate (read-only).
        type:
          type: string
          readOnly: true
          description: Last event type, e.g. created/upserted/published (read-only).
      description: >-
        A document template. The `source` DOCX is rendered with angular
        expression parser when the template is triggered; `output` controls
        where and in what format the rendered file is written.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: '"key" is required'
    TemplateOutput:
      type: object
      properties:
        name:
          type: string
          description: >-
            Output filename template, rendered against the trigger payload with
            single-brace angular expressions (e.g. `invoice-{invoice_number}` →
            `invoice-INV-2026-014`). Defaults to the template key when omitted
            or when rendering fails. The `.pdf`/`.docx` extension is appended
            automatically from `content_type` — do not include it.
          example: invoice-{invoice_number}
        content_type:
          type: string
          description: >-
            Output MIME type. DOCX sources can render to PDF or DOCX; PDF
            sources can only output PDF (PDF→DOCX conversion is not supported).
          enum:
            - application/pdf
            - >-
              application/vnd.openxmlformats-officedocument.wordprocessingml.document
          example: application/pdf
        bucket:
          type: string
          description: >-
            Storage bucket. May be prefixed with `obj://` (object store,
            default) or `kv://` (key-value store) to select the storage backend.
            Defaults to the service's document bucket.
          example: microstrate-documents
        folder:
          type: string
          description: Output folder path within the bucket.
          example: invoices/2024
      description: >-
        Where and how the rendered document is written. The final storage key is
        `{bucket}/{folder}/{name}.{ext}` with the extension derived from
        `content_type`.
    TemplateSignatory:
      type: object
      required:
        - name
        - email
        - validity
      properties:
        name:
          type: string
          description: >-
            Signatory name. Supports single-brace angular expression
            placeholders resolved against the trigger payload, e.g.
            `{client_name}`. The rendered value is trimmed and truncated to 100
            characters (HelloSign limit).
          example: '{client_name}'
        email:
          type: string
          description: >-
            Signatory email. Supports single-brace angular expression
            placeholders resolved against the trigger payload, e.g.
            `{client_email}`. The rendered value is trimmed and lowercased;
            signatories with a missing or invalid rendered email (or empty name)
            are skipped — if none remain, no signature request is sent and the
            document's `signatures` is `null`.
          example: '{client_email}'
        validity:
          $ref: '#/components/schemas/TemplateSignatoryValidity'
        order:
          type: integer
          description: >-
            Signing order index (0-based). Defaults to the signatory's position
            in the array.
          example: 0
    TemplateSubTemplate:
      type: object
      required:
        - key
      properties:
        key:
          type: string
          description: Key of the sub-template to merge.
          example: terms-and-conditions
        conditions:
          type: object
          additionalProperties: true
          description: >-
            Rule-engine condition object evaluated against the trigger payload;
            the sub-template is only included when it resolves to true. Payload
            keys are exposed as facts named `<key>.value` (e.g. payload
            `client_region` → fact `client_region.value`).
          example:
            all:
              - fact: client_region.value
                operator: equal
                value: EU
    TemplateSignatoryValidity:
      type: object
      description: >-
        How long the signatory has to complete signing, measured from when the
        signature request is sent. The day/week/month/year components are
        summed; once elapsed, the signature is marked `EXPIRED` and the
        HelloSign request is cancelled.
      properties:
        day:
          type: integer
          example: 7
        week:
          type: integer
          example: 0
        month:
          type: integer
          example: 0
        year:
          type: integer
          example: 0
  responses:
    Unauthorized:
      description: Missing or invalid Authorization header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Authorization header with a bearer token is required
    ServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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