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

# Preview a template

> Renders template markup against caller-supplied sample data and returns the output, without creating a template or generating a report. A Pdf template previews as the HTML stage that would feed the PDF engine. The whole request body is capped at 3211264 bytes and a larger one is refused with 413 before it is parsed; content and sampleData carry their own ceilings.



## OpenAPI

````yaml /pt/openapi/v3-current/reporter.yaml post /v1/templates/preview
openapi: 3.1.0
info:
  contact:
    name: Discord community
    url: https://discord.gg/DnhqKwkGv3
  description: >-
    This is OpenAPI documentation for Reporter. The unified reporter binary
    serves the REST API (RUN_MODE=api) and/or the RabbitMQ report-generation
    worker (RUN_MODE=worker); RUN_MODE=all runs both in one process for local
    development. All REST endpoints documented here serve only when RUN_MODE=api
    or all (port :4005); the worker (port :4006) exposes health/readyz/version
    only.
  license:
    name: Lerian Studio General License
  title: Midaz Reporter API
  version: 4.0.0
servers:
  - url: http://localhost:4005
  - url: https://localhost:4005
security:
  - BearerAuth: []
tags:
  - description: Generated report instances and their lifecycle.
    name: Reports
  - description: Reusable report definitions.
    name: Templates
  - description: Interactive construction of report templates.
    name: Template Builder
  - description: Scheduled report due-date tracking.
    name: Deadlines
  - description: Configured inputs that feed report data.
    name: Data Sources
  - description: Aggregated reporting metrics.
    name: Metrics
  - description: Published business event catalog and delivery policies.
    name: Streaming
paths:
  /v1/templates/preview:
    post:
      tags:
        - Templates
      summary: Preview a template
      description: >-
        Renders template markup against caller-supplied sample data and returns
        the output, without creating a template or generating a report. A Pdf
        template previews as the HTML stage that would feed the PDF engine. The
        whole request body is capped at 3211264 bytes and a larger one is
        refused with 413 before it is parsed; content and sampleData carry their
        own ceilings.
      operationId: previewTemplate
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewTemplateInput'
        description: Template markup and the sample data to render it against.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreviewTemplateResult'
          description: OK
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unauthorized
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Forbidden
        '413':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Request Entity Too Large
        '429':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Too Many Requests
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
components:
  schemas:
    PreviewTemplateInput:
      additionalProperties: false
      properties:
        content:
          description: >-
            Raw pongo2 template markup to render. At most 512 KiB, measured on
            the decoded bytes.
          examples:
            - 'Total: {{ ledger.accounts.0.balance }}'
          maxLength: 524288
          type: string
        outputFormat:
          description: >-
            One of Html, Csv, Txt, Xml or Pdf, matched case-insensitively.
            Decides the response content type only; defaults to Html when
            omitted or empty.
          examples:
            - Html
          pattern: >-
            ^([Hh][Tt][Mm][Ll]|[Cc][Ss][Vv]|[Tt][Xx][Tt]|[Xx][Mm][Ll]|[Pp][Dd][Ff])?$
          type: string
        sampleData:
          additionalProperties:
            additionalProperties:
              items:
                additionalProperties: {}
                type: object
              type:
                - array
                - 'null'
            type: object
          description: >-
            Render context shaped as data source, then table, then rows. At most
            1 MiB, measured on the raw JSON bytes sent for this member.
          type: object
      required:
        - content
      type: object
    PreviewTemplateResult:
      additionalProperties: false
      properties:
        contentType:
          description: Content type the rendered output should be displayed as.
          examples:
            - text/html
          type: string
        durationMs:
          description: How long the preview took, in milliseconds.
          examples:
            - 12
          format: int64
          type: integer
        rendered:
          description: >-
            Rendered output. For a Pdf template this is the HTML stage that
            would feed the PDF engine.
          examples:
            - 'Total: 1500.00'
          type: string
        warnings:
          description: Non-fatal render notes, such as output having been truncated.
          items:
            type: string
          type: array
      required:
        - rendered
        - contentType
        - warnings
        - durationMs
      type: object
    Detail:
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          examples:
            - - location: body.templateId
                message: expected string to match 'uuid' format
                value: not-a-uuid
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    ErrorDetail:
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          examples:
            - body.templateId
          type: string
        message:
          description: Error message text
          examples:
            - expected string to match 'uuid' format
          type: string
        value:
          description: The value at the given location
          examples:
            - not-a-uuid
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````