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

# Update template preview

> Update the preview HTML for a template. The preview can be accessed publicly at /preview/{template_id} without authentication.



## OpenAPI

````yaml /openapi.json put /v1/templates/{id}/preview
openapi: 3.0.3
info:
  title: Emailr API
  version: 1.0.0
servers:
  - url: https://api.emailr.dev
    description: Production
security: []
tags:
  - name: emails
    description: Email sending and management
  - name: contacts
    description: Contact management
  - name: templates
    description: Email template management
  - name: domains
    description: Domain verification and management
  - name: webhooks
    description: Webhook configuration
  - name: broadcasts
    description: Broadcast campaign management
  - name: segments
    description: Contact segmentation
paths:
  /v1/templates/{id}/preview:
    put:
      tags:
        - templates
      summary: Update template preview
      description: >-
        Update the preview HTML for a template. The preview can be accessed
        publicly at /preview/{template_id} without authentication.
      operationId: updateTemplatePreview
      parameters:
        - schema:
            type: string
            format: uuid
            example: 123e4567-e89b-12d3-a456-426614174000
          required: true
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePreviewRequest'
      responses:
        '200':
          description: Preview updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdatePreviewResponse'
        '400':
          description: Invalid HTML content
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Template not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    UpdatePreviewRequest:
      type: object
      properties:
        html_content:
          type: string
          minLength: 1
          description: HTML content for the template preview
          example: <h1>Welcome {{name}}</h1><p>Preview content here</p>
      required:
        - html_content
    UpdatePreviewResponse:
      type: object
      properties:
        preview_url:
          type: string
          description: Public URL to access the preview (no authentication required)
          example: /preview/123e4567-e89b-12d3-a456-426614174000
      required:
        - preview_url
    Error:
      type: object
      properties:
        error:
          type: string
          example: An error occurred
        code:
          type: string
          example: VALIDATION_ERROR
        details: {}
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API key authentication. Use your API key as the bearer token.

````