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

# Validate template

> Validate a base64-encoded template file before storing it.

The file is checked by rendering tags with empty data, and any tag errors are returned without persisting anything. The `errors` entries are error explanations, covering problems such as unclosed loop tags, duplicate/unopened close tags, and expressions that fail to compile.

Validation is **syntactic**: it confirms the tags compile, not that the payload you eventually send will contain every referenced identifier — unresolved identifiers at trigger time render as an empty string rather than failing.

Always run this before `POST /templates` / `PATCH /templates/{key}` when the source DOCX changes — a template that stores an invalid source will fail every trigger.



## OpenAPI

````yaml /api-reference/endpoint/documents/openapi.json post /file-generator/templates/validate
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/validate:
    post:
      tags:
        - Templates
      summary: Validate template
      description: >-
        Validate a base64-encoded template file before storing it.


        The file is checked by rendering tags with empty data, and any tag
        errors are returned without persisting anything. The `errors` entries
        are error explanations, covering problems such as unclosed loop tags,
        duplicate/unopened close tags, and expressions that fail to compile.


        Validation is **syntactic**: it confirms the tags compile, not that the
        payload you eventually send will contain every referenced identifier —
        unresolved identifiers at trigger time render as an empty string rather
        than failing.


        Always run this before `POST /templates` / `PATCH /templates/{key}` when
        the source DOCX changes — a template that stores an invalid source will
        fail every trigger.
      operationId: validateTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidateTemplateRequest'
            example:
              content_type: >-
                application/vnd.openxmlformats-officedocument.wordprocessingml.document
              content: UEsDBBQABgAIAAAAIQDfpNJ...
      responses:
        '200':
          description: Validation result returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidateTemplateResponse'
              examples:
                valid:
                  summary: Template compiles cleanly
                  value:
                    is_valid: true
                    errors: []
                invalid:
                  summary: Template has tag errors
                  description: Each entry is an error explanation for one failing tag.
                  value:
                    is_valid: false
                    errors:
                      - The tag beginning with "{#line_items" is unclosed
                      - >-
                        The scope parser for the tag "subtotal +" failed to
                        compile
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ValidateTemplateRequest:
      type: object
      required:
        - content_type
        - content
      properties:
        content_type:
          type: string
          enum:
            - application/msword
            - >-
              application/vnd.openxmlformats-officedocument.wordprocessingml.document
            - application/xml
          example: >-
            application/vnd.openxmlformats-officedocument.wordprocessingml.document
        content:
          type: string
          format: byte
          description: >-
            Base64-encoded template file content. The file is compiled with
            angular expression parser and any tag errors are reported — nothing
            is persisted.
          example: UEsDBBQABgAIAAAAIQDfpNJ...
    ValidateTemplateResponse:
      type: object
      properties:
        is_valid:
          type: boolean
          example: true
        errors:
          type: array
          items:
            type: string
          example: []
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: '"key" is required'
  responses:
    BadRequest:
      description: Invalid or missing request parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: '"key" is required'
    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.