---
title: "Render Template"
description: "How to call Render Template (POST /api/template-render) in the Klaviyo REST API: authentication, parameters, request and response bodies, and an example request."
url: "https://developers.klaviyo.com/en/reference/render_template"
revision: "2026-10-15"
operationId: "render_template"
aliases: ["create_template_render"]
method: "POST"
endpoint: "https://a.klaviyo.com/api/template-render"
authentication: "privateKey"
scopes: ["templates:read"]
rateLimits: {"burst":"3/s","steady":"60/m"}
revisionHeader: {"name":"revision","required":true}
deprecated: false
openApi: "https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15/openapi/stable/apis/render_template.json"
jsonApi: {"fields":{"template":["amp","created","editor_type","html","id","name","screenshot_url","text","updated"]}}
related: ["https://developers.klaviyo.com/en/reference/templates/llms.txt","https://developers.klaviyo.com/en/reference/get_templates.md","https://developers.klaviyo.com/en/reference/get_template.md","https://developers.klaviyo.com/en/reference/create_template.md","https://developers.klaviyo.com/en/reference/update_template.md","https://developers.klaviyo.com/en/reference/delete_template.md","https://developers.klaviyo.com/en/reference/get_template_conversion_jobs.md","https://developers.klaviyo.com/en/reference/get_template_conversion_job.md","https://developers.klaviyo.com/en/reference/create_template_conversion_job.md","https://developers.klaviyo.com/en/reference/clone_template.md","https://developers.klaviyo.com/en/reference/create_template_preview_send_job.md"]
---

# Render Template

> This is the Markdown version of https://developers.klaviyo.com/en/reference/render_template

```http
POST https://a.klaviyo.com/api/template-render
```

Render a template with the given template ID and context attribute. Returns the AMP, HTML, and plain text versions of the email template.

**Request body parameters** (nested under `attributes`):

* `return_fields`: Request specific fields using [sparse fieldsets](https://developers.klaviyo.com/en/reference.md).

* `context`: This is the context your email template will be rendered with. You must pass in a `context` object as a JSON object.

Email templates are rendered with contexts in a similar manner to Django templates. Nested template variables can be referenced via dot notation. Template variables without corresponding `context` values are treated as `FALSE` and output nothing.

Ex. `{ "name" : "George Washington", "state" : "VA" }`

- Revision header: `revision: 2026-10-15` (required)
- Scopes: `templates:read`
- Rate limits: Burst: `3/s`, Steady: `60/m`
- OpenAPI: [Download this endpoint's OpenAPI document](https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15/openapi/stable/apis/render_template.json)

## Example request

### curl

```bash
curl --request POST \
     --url 'https://a.klaviyo.com/api/template-render' \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'revision: 2026-10-15' \
     --header 'content-type: application/vnd.api+json' \
     --data '{
  "data": {
    "type": "template",
    "id": "string",
    "attributes": {
      "context": {
        "first_name": "Jane",
        "last_name": "Smith"
      }
    }
  }
}'
```

### CLI

```bash
klaviyo templates render-template \
  -d '{
  "data": {
    "type": "template",
    "id": "string",
    "attributes": {
      "context": {
        "first_name": "Jane",
        "last_name": "Smith"
      }
    }
  }
}'
```

Sign in first with `klaviyo auth login`. [Install the Klaviyo CLI](https://developers.klaviyo.com/en/docs/klaviyo_cli.md)

### Python

```python
from klaviyo_api import KlaviyoAPI

klaviyo = KlaviyoAPI("your-private-api-key")

response = klaviyo.Templates.render_template(
    {
        "data": {
            "type": "template",
            "id": "string",
            "attributes": {
                "context": {
                    "first_name": "Jane",
                    "last_name": "Smith",
                },
            },
        },
    },
)
```

Install it with `pip install klaviyo-api`. [The Python SDK on GitHub](https://github.com/klaviyo/klaviyo-api-python)

### Node.js

```javascript
import { ApiKeySession, TemplatesApi } from 'klaviyo-api'

const session = new ApiKeySession('your-private-api-key')
const templatesApi = new TemplatesApi(session)

const response = await templatesApi.renderTemplate(
  {
    data: {
      type: 'template',
      id: 'string',
      attributes: {
        context: {
          first_name: 'Jane',
          last_name: 'Smith',
        },
      },
    },
  },
)
```

Install it with `npm install klaviyo-api`. [The Node.js SDK on GitHub](https://github.com/klaviyo/klaviyo-api-node)

### Ruby

```ruby
require 'klaviyo-api-sdk'

KlaviyoAPI.configure do |config|
  config.api_key['Klaviyo-API-Key'] = 'Klaviyo-API-Key your-private-api-key'
end

response = KlaviyoAPI::Templates.render_template(
  {
    data: {
      type: 'template',
      id: 'string',
      attributes: {
        context: {
          first_name: 'Jane',
          last_name: 'Smith',
        },
      },
    },
  },
)
```

Install it with `gem install klaviyo-api-sdk`. [The Ruby SDK on GitHub](https://github.com/klaviyo/klaviyo-api-ruby)

### PHP

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');

use KlaviyoAPI\KlaviyoAPI;

$klaviyo = new KlaviyoAPI('your-private-api-key');

$response = $klaviyo->Templates->renderTemplate(
    [
        'data' => [
            'type' => 'template',
            'id' => 'string',
            'attributes' => [
                'context' => [
                    'first_name' => 'Jane',
                    'last_name' => 'Smith',
                ],
            ],
        ],
    ],
);
```

Install it with `composer require klaviyo/api`. [The PHP SDK on GitHub](https://github.com/klaviyo/klaviyo-api-php)

## Query parameters

- `fields[template]` (string[]): For more information please visit [API overview](https://developers.klaviyo.com/en/reference.md) Allowed values: `amp`, `created`, `editor_type`, `html`, `id`, `name`, `screenshot_url`, `text`, `updated`

## Headers

- `revision` (string, required): API endpoint revision (format: YYYY-MM-DD[.suffix]) Default: `2026-10-15`

## Request body

Content type: `application/vnd.api+json` (required)

- `data` (object, required)
  - `type` (string, required): Allowed values: `template`
  - `id` (string, required): The ID of template
  - `attributes` (object, required)
    - `context` (object, required): The context for the template render. This must be a JSON object which has values for any tags used in the template. See [this doc](https://help.klaviyo.com/hc/en-us/articles/4408802648731) for more details.

### Example request body

```json
{
  "data": {
    "type": "template",
    "id": "string",
    "attributes": {
      "context": {
        "first_name": "Jane",
        "last_name": "Smith"
      }
    }
  }
}
```

## Responses

### 201: Success

Content type: `application/vnd.api+json`

- `data` (object, required)
  - `type` (string, required): Allowed values: `template`
  - `id` (string, required): The ID of template
  - `attributes` (object, required)
    - `name` (string, required): The name of the template
    - `editor_type` (string, required): `editor_type` has a fixed set of values:
      * SYSTEM_DRAGGABLE: indicates a drag-and-drop editor template
      * SIMPLE: A rich text editor template
      * CODE: A custom HTML template
      * USER_DRAGGABLE: A hybrid template, using custom HTML in the drag-and-drop editor
    - `html` (string, required): The rendered HTML of the template
    - `text` (string, nullable): The template plain_text
    - `amp` (string, nullable): The AMP version of the template. Requires AMP Email to be enabled to access in-app. Refer to the AMP Email setup guide at [Send AMP emails in Klaviyo](https://developers.klaviyo.com/en/docs/send_amp_emails_in_klaviyo.md)
    - `created` (string<date-time>, nullable): The date the template was created in ISO 8601 format (YYYY-MM-DDTHH:MM:SS.mmmmmm) Example: `2022-11-08T00:00:00+00:00`
    - `updated` (string<date-time>, nullable): The date the template was updated in ISO 8601 format (YYYY-MM-DDTHH:MM:SS.mmmmmm) Example: `2022-11-08T00:00:00+00:00`
    - `screenshot_url` (string, nullable): A presigned URL to an image of the rendered template, valid for 24 hours. `null` when no screenshot is currently available for the template.
  - `links` (object, required)
    - `self` (string<uri>, required)
- `links` (ObjectLinks): Same fields as the first ObjectLinks above.
- `meta` (object): Response-level metadata
  - `agent_hints` (object): Optional hints emitted by the API for agent callers
    - `next_steps` (string[]): Suggested follow-up actions for agents to take after this response

#### Example response body

```json
{
  "data": {
    "type": "template",
    "id": "string",
    "attributes": {
      "name": "string",
      "editor_type": "string",
      "html": "string",
      "text": "string",
      "amp": "string",
      "created": "2022-11-08T00:00:00+00:00",
      "updated": "2022-11-08T00:00:00+00:00",
      "screenshot_url": "string"
    },
    "links": {
      "self": "https://www.example.com"
    }
  },
  "links": {
    "self": "https://www.example.com"
  },
  "meta": {
    "agent_hints": {
      "next_steps": [
        "string"
      ]
    }
  }
}
```

### 4XX: Client Error

Content type: `application/vnd.api+json`

- `errors` (object[], required)
  - `id` (string, required)
  - `code` (string, required)
  - `title` (string, required)
  - `detail` (string, required)
  - `source` (object)
    - `pointer` (string)
    - `parameter` (string)

#### Example response body

```json
{
  "errors": [
    {
      "id": "string",
      "code": "string",
      "title": "string",
      "detail": "string",
      "source": {
        "pointer": "string",
        "parameter": "string"
      }
    }
  ]
}
```

### 5XX: Server Error

Content type: `application/vnd.api+json`

- `errors` (object[], required)
  - `id` (string, required)
  - `code` (string, required)
  - `title` (string, required)
  - `detail` (string, required)
  - `source` (object)
    - `pointer` (string)
    - `parameter` (string)

#### Example response body

```json
{
  "errors": [
    {
      "id": "string",
      "code": "string",
      "title": "string",
      "detail": "string",
      "source": {
        "pointer": "string",
        "parameter": "string"
      }
    }
  ]
}
```
