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

# Render an email message as HTML

> Render an email message as HTML for an immediate preview.

Render an email message as HTML without sending it. The HTML is the same as the body of a preview email. Accepted variable fields depend on the parent's type:

* **Campaign** accepts `contactProperties`.
* **Workflow** accepts `contactProperties` and `eventProperties`.
* **Transactional** accepts `dataVariables`.

Supplying a field the parent cannot reference results in a `400 Bad Request` error. A variable without a value uses its fallback, or shows a missing-value marker as in a preview email.

The HTML has no open tracking pixel. As in a preview email, the unsubscribe link opens a page that does not unsubscribe anyone.


## OpenAPI

````yaml https://app.loops.so/openapi.json post /v1/email-messages/{emailMessageId}/render
openapi: 3.1.0
info:
  title: Loops OpenAPI Spec
  description: This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
  version: 1.23.0
servers:
  - url: https://app.loops.so/api
security: []
tags:
  - name: API key
  - name: Audience segments
    description: View and create audience segments
  - name: Campaigns
    description: Create and manage email campaigns
  - name: Campaign groups
    description: Organize campaigns into groups
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - name: Components
    description: View email components
  - name: Email messages
    description: Manage email message content for campaigns
  - name: Events
    description: Trigger workflows with events
  - name: Event patterns
    description: View workflow event patterns
  - name: Mailing lists
    description: View mailing lists
  - name: Themes
    description: View email themes
  - name: Transactional emails
    description: Create, manage, and send transactional emails
  - name: Transactional groups
    description: Organize transactional emails into groups
  - name: Uploads
    description: Upload image assets
  - name: Workflows
    description: View and mutate workflow graphs
  - name: Workflow groups
    description: Organize workflows into groups
  - name: Workflow nodes
    description: View and mutate workflow nodes
  - name: Webhooks
    description: >-
      Events Loops sends to your configured webhook endpoint when certain events
      happen in your account. Configure an endpoint in Settings → Webhooks. Each
      account supports one webhook endpoint. Events are signed with
      `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers and
      delivered at a maximum rate of 10 per second. See
      https://loops.so/docs/webhooks for setup, verification, and payload
      details.
paths:
  /v1/email-messages/{emailMessageId}/render:
    parameters:
      - name: emailMessageId
        in: path
        required: true
        description: The ID of the email message.
        schema:
          type: string
          examples:
            - cle5f7g9h1i3j5k7l9m1n3p5
    post:
      tags:
        - Email messages
      summary: Render an email message as HTML
      description: >-
        Render the HTML of an email message the way its preview email is
        rendered. Nothing is sent. The accepted variable fields are the same as
        for previews - campaigns accept `contactProperties`, workflows accept
        `contactProperties` and `eventProperties`, and transactional emails
        accept `dataVariables`. A variable without a value uses its fallback, or
        shows a missing-value marker as in a preview email. Supplying a field
        the parent cannot reference is rejected with 400.
      operationId: renderEmailMessage
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailMessageRenderRequest'
            examples:
              campaign:
                summary: Campaign email
                value:
                  contactProperties:
                    firstName: Alex
              workflow:
                summary: Workflow email
                value:
                  contactProperties:
                    firstName: Alex
                  eventProperties:
                    planName: Pro
              transactional:
                summary: Transactional email
                value:
                  dataVariables:
                    loginUrl: https://app.company.com/login
      responses:
        '200':
          description: Rendered email message.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailMessageRenderResponse'
        '400':
          description: >-
            Invalid request body, a variable field the parent cannot reference,
            a sending domain without a domain or address, or a from or reply-to
            address that renders to an invalid email.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailMessageFailureResponse'
        '401':
          description: Invalid API key or content API not enabled for this team.
        '404':
          description: Email message not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailMessageFailureResponse'
        '405':
          description: Wrong HTTP request method.
      security:
        - apiKey: []
components:
  schemas:
    EmailMessageRenderRequest:
      type: object
      properties:
        contactProperties:
          type: object
          additionalProperties:
            type: string
          description: >-
            Contact property values to render. Accepted for campaign and
            workflow emails.
          example:
            firstName: Alex
        eventProperties:
          type: object
          additionalProperties:
            type: string
          description: Event property values to render. Accepted for workflow emails only.
          example:
            planName: Pro
        dataVariables:
          type: object
          additionalProperties:
            type: string
          description: >-
            Transactional data variables to render. Accepted for transactional
            emails only.
          example:
            loginUrl: https://app.company.com/login
      additionalProperties: false
    EmailMessageRenderResponse:
      type: object
      properties:
        html:
          type: string
          description: >-
            The rendered HTML. For emails made in the editor, it includes the
            rendered subject in `<title>` and the rendered preview text.
          examples:
            - <!doctype html><html>...</html>
      required:
        - html
      examples:
        - html: <!doctype html><html>...</html>
    EmailMessageFailureResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      examples:
        - message: Email message not found.
        - message: 'Workflow must not be sending. Current status: Sending.'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

## Related topics

- [Send a preview of an email message](https://loops.so/docs/api-reference/preview-email-message.md)
- [Email messages](https://loops.so/docs/cli/email-messages.md)
- [Why we don't support HTML emails](https://loops.so/docs/guides/html-emails.md)
- [Get an email message](https://loops.so/docs/api-reference/get-email-message.md)
- [Update an email message](https://loops.so/docs/api-reference/update-email-message.md)
