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

# Preview an email template

> Renders a template as a send would: for the contact you name and their account (real field values; the account needs accounts:read), or the account you name, with sample values for the rest and always for the sender (user); `samples` says which. Nothing is sent, and the unsubscribe link is a placeholder. The subject comes back as written, since sends don't fill in merge tags there. A template that fails to render (invalid Jinja, an operation on a value of the wrong type, a {{user.*}} tag with no sample) is a 422 that says why, and so is one that grows too large or loops too long to preview. Safe to retry: it only reads.



## OpenAPI

````yaml /api/statisfy-api.openapi.json post /v1/templates/{template_id}/preview
openapi: 3.1.0
info:
  description: >-
    The agent-first Statisfy API. Authenticate with an API key (`Authorization:
    Bearer stfy_live_…`), then call `GET /v1/meta/capabilities` to discover
    every operation and its schemas.
  title: Statisfy API
  version: 1.0.0
servers:
  - url: https://api.statisfy.com
    description: Production
security: []
paths:
  /v1/templates/{template_id}/preview:
    post:
      tags:
        - templates
      summary: Preview an email template
      description: >-
        Renders a template as a send would: for the contact you name and their
        account (real field values; the account needs accounts:read), or the
        account you name, with sample values for the rest and always for the
        sender (user); `samples` says which. Nothing is sent, and the
        unsubscribe link is a placeholder. The subject comes back as written,
        since sends don't fill in merge tags there. A template that fails to
        render (invalid Jinja, an operation on a value of the wrong type, a
        {{user.*}} tag with no sample) is a 422 that says why, and so is one
        that grows too large or loops too long to preview. Safe to retry: it
        only reads.
      operationId: templates_preview
      parameters:
        - description: The template's id, from GET /v1/templates
          in: path
          name: template_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                account_id:
                  anyOf:
                    - maxLength: 255
                      type: string
                    - type: 'null'
                  default: null
                  description: >-
                    Their account's id, from GET /v1/objects/account/records.
                    Needs accounts:read. Left out, the contact's own account
                    when the key has accounts:read, and sample values when it
                    doesn't
                  title: Account Id
                contact_id:
                  anyOf:
                    - maxLength: 255
                      type: string
                    - type: 'null'
                  default: null
                  description: >-
                    The recipient: a contact's id, from GET
                    /v1/objects/contact/records. Needs contacts:read
                  title: Contact Id
              type: object
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplatePreview'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    TemplatePreview:
      properties:
        empty_merge_tags:
          description: Merge tags the HTML uses whose value is missing or blank here
          items:
            type: string
          title: Empty Merge Tags
          type: array
        html:
          description: >-
            The HTML as a send would render it; the unsubscribe link is a
            placeholder
          title: Html
          type: string
        samples:
          description: >-
            The merge-tag groups filled with sample values rather than real
            ones: contact unless you named one, account unless you named one or
            it is the named contact's (read with accounts:read), and always user
            (the sender)
          items:
            enum:
              - account
              - contact
              - user
            type: string
          title: Samples
          type: array
        subject:
          anyOf:
            - type: string
            - type: 'null'
          description: 'Sent as written: merge tags in a subject are not filled in'
          title: Subject
      required:
        - subject
        - html
        - samples
        - empty_merge_tags
      title: TemplatePreview
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http
      description: >-
        An API key, sent as `Authorization: Bearer stfy_live_…`. See
        [Authentication](/rest-api/authentication) for how to get one and which
        scopes it needs.

````

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