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

# Preview a template with ticket data

> Renders a template fragment using the optional ticket or contract data. When `ticketId` is provided, AI extracted intent data is injected before rendering. The response returns HTML with `<br>` tags to preserve formatting in downstream clients.




## OpenAPI

````yaml https://dev.enneo.dev/api/mind/docs/open-api post /template/preview
openapi: 3.0.0
info:
  version: '1'
  title: enneo.MIND API
  description: This describes the API of enneo Mind, the main ticketing backend
  contact:
    name: enneo GmbH
    email: richard@enneo.ai
  license:
    name: Proprietary software
    url: https://enneo.ai
servers:
  - url: https://demo.enneo.ai/api/mind
    description: Production server, demo client
  - url: https://main.enneo.dev/api/mind
    description: Development main branch
  - url: http://localhost:8005/api/mind
    description: Local development server
security:
  - bearerAuth:
      - api
  - cookieAuth:
      - api
paths:
  /template/preview:
    post:
      tags:
        - Template
      summary: Preview a template with ticket data
      description: >
        Renders a template fragment using the optional ticket or contract data.
        When `ticketId` is provided, AI extracted intent data is injected before
        rendering. The response returns HTML with `<br>` tags to preserve
        formatting in downstream clients.
      operationId: previewTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - templateText
              properties:
                templateText:
                  type: string
                  description: >
                    Template text to render. Supports [Handlebars
                    syntax](https://handlebarsjs.com/guide/) plus a set of
                    Enneo-specific helpers — see the [Templates
                    documentation](https://docs.enneo.ai/en/work-resources/templates)
                    for the full list.
                  example: >-
                    <p>Wir haben den Stand {{intent.data.reading}} kWh
                    erfasst.</p>
                ticketId:
                  type: integer
                  description: >-
                    Ticket used to hydrate variables (intent data, customer
                    data, etc.).
                  example: 8821
                contractId:
                  type: string
                  description: >
                    Contract ID used to load customer context when no ticket is
                    available.
                  example: 4711-2023
      responses:
        '200':
          description: Template preview rendered successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  preview:
                    type: string
                    description: >-
                      Rendered HTML preview (line breaks already converted to
                      `<br>`).
                  variables:
                    type: object
                    description: >
                      Replacement data derived from the ticket or contract
                      (returned only when contextual data was available).
              examples:
                ticketContext:
                  summary: Preview rendered with ticket data
                  value:
                    success: true
                    preview: >-
                      <p>Vielen Dank für die Meldung deines
                      Zählerstandes.</p><br><p>Wir haben 20112 kWh für den
                      31.01.2023 erfasst.</p>
                    variables:
                      intent:
                        data:
                          reading: 20112
                          date: '2023-01-31'
                      contract:
                        id: 4711-2023
        '400':
          description: Invalid template or missing required data
        '403':
          description: Unauthorized
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      description: Data format of Enneo error messages
      properties:
        error:
          type: string
          example: Contract 121 could not be processed
          description: Readable error message that should be shown to the user
        details:
          type: string
          example: >-
            Uncatched null point exception in testFunction() in
            /app/src/file:212
          description: Not easily readable error message that is for the developer
        txId:
          type: string
          example: c916167c94
          description: >-
            Internal transaction id. Useful for debugging. Corresponds to the
            OpenTelemetry trace ID.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT-based authentication
      x-scopes:
        api: Full access to the API
    cookieAuth:
      type: apiKey
      in: cookie
      name: connect.sid
      description: Cookie-based authentication
      x-scopes:
        api: Full access to the API

````