---
title: "Render a template"
description: "The subject, HTML and text a send of this template would carry, with your footer and branding, without sending or storing anything. `POST /api/v1/email/templates/{id}/render`"
url: https://www.unitpost.com/docs/email/post-email-templates-id-render
section: "Email API reference"
updated: 2026-10-13
---
# Render a template

`POST /api/v1/email/templates/{id}/render`

The subject, HTML and text a send of this template would carry, with your footer and branding, without sending or storing anything. Pass `variables` as a send's `template.variables`, and `contact_id` to fill contact fields from that contact. `missing_variables` lists the variables left without a value: they render as a literal `{{token}}` here, and a real send refuses them. `{{unsubscribe_url}}` renders a preview link. A POST only because it takes a body; any other key is a `422`. Requires the `templates:read` capability.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | — |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `variables` | object | no | Values for the template's {{variables}}, as a send's `template.variables`. One with no value stays a literal {{token}} and is listed in `missing_variables`. |
| `subject` | string | no | Render this subject instead of the template's. |
| `contact_id` | string | no | Fill contact fields ({{first_name}}, custom fields) from this contact (`con_…`), as a send to them would. |

## Response fields (200)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | string | yes | — |
| `subject` | string | yes | — |
| `html` | string | yes | The HTML a send would carry, footer and branding included. `{{unsubscribe_url}}` is a preview link. |
| `text` | string | yes | — |
| `missing_variables` | string[] | yes | Variables with no value: they render as a literal {{token}}, and a real send would refuse them. |

## Responses

| Status | Description |
| --- | --- |
| 200 | The rendered email. |
| 400 | The body isn't JSON. |
| 401 | Missing or invalid API key. |
| 403 | Insufficient scope. |
| 404 | Template (or `contact_id`) not found. |
| 422 | An unknown key, a bad value, or `template_invalid`: the template has no content yet. |
| 429 | Too many renders; retry after the wait. |

## Example request

```bash
curl -X POST 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/render' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{ }'
```

## Example response (200)

```json
{
  "object": "template_render",
  "subject": "Welcome to Acme",
  "html": "string",
  "text": "string",
  "missing_variables": [
    "string"
  ]
}
```

## Links

- HTML reference (with Node.js, Python, Ruby, PHP, Laravel, Go, Java, Rust, .NET and CLI examples): https://www.unitpost.com/docs/email/post-email-templates-id-render
- OpenAPI 3.1 (full schemas): https://www.unitpost.com/api/v1/openapi.json
