---
title: "Create Template"
description: "How to call Create Template (POST /api/templates) in the Klaviyo REST API: authentication, parameters, request and response bodies, and an example request."
url: "https://developers.klaviyo.com/en/reference/create_template"
revision: "2026-10-15"
operationId: "create_template"
method: "POST"
endpoint: "https://a.klaviyo.com/api/templates"
authentication: "privateKey"
scopes: ["templates:write"]
rateLimits: {"burst":"75/s","steady":"750/m"}
revisionHeader: {"name":"revision","required":true}
deprecated: false
openApi: "https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15/openapi/stable/apis/create_template.json"
jsonApi: {"fields":{"template":["amp","created","definition","definition.body","definition.body.id","definition.body.properties","definition.body.properties.css_class","definition.body.properties.id","definition.body.sections","definition.body.styles","definition.body.styles.background_color","definition.body.styles.width","definition.id","definition.styles","definition.template_id","editor_type","html","id","name","screenshot_url","text","updated"]},"additionalFields":{"template":["definition"]}}
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/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/render_template.md","https://developers.klaviyo.com/en/reference/clone_template.md","https://developers.klaviyo.com/en/reference/create_template_preview_send_job.md"]
---

# Create Template

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

```http
POST https://a.klaviyo.com/api/templates
```

Create a new HTML or drag-and-drop template.

If there are 1,000 or more templates in an account, creation will fail as there is a limit of 1,000 templates that can be created via the API.

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

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

## Example request

### curl

```bash
curl --request POST \
     --url 'https://a.klaviyo.com/api/templates' \
     --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",
    "attributes": {
      "name": "Monthly Newsletter Template",
      "editor_type": "string",
      "text": "hello world"
    }
  }
}'
```

### CLI

```bash
klaviyo templates create \
  -d '{
  "data": {
    "type": "template",
    "attributes": {
      "name": "Monthly Newsletter Template",
      "editor_type": "string",
      "text": "hello world"
    }
  }
}'
```

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.create_template(
    {
        "data": {
            "type": "template",
            "attributes": {
                "name": "Monthly Newsletter Template",
                "editor_type": "string",
                "text": "hello world",
            },
        },
    },
)
```

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.createTemplate(
  {
    data: {
      type: 'template',
      attributes: {
        name: 'Monthly Newsletter Template',
        editorType: 'string',
        text: 'hello world',
      },
    },
  },
)
```

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.create_template(
  {
    data: {
      type: 'template',
      attributes: {
        name: 'Monthly Newsletter Template',
        editor_type: 'string',
        text: 'hello world',
      },
    },
  },
)
```

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->createTemplate(
    [
        'data' => [
            'type' => 'template',
            'attributes' => [
                'name' => 'Monthly Newsletter Template',
                'editor_type' => 'string',
                'text' => 'hello world',
            ],
        ],
    ],
);
```

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

## Query parameters

- `additional-fields[template]` (string[]): Request additional fields not included by default in the response. Supported values: 'definition' Allowed values: `definition`
- `fields[template]` (string[]): For more information please visit [API overview](https://developers.klaviyo.com/en/reference.md) Allowed values: `amp`, `created`, `definition`, `definition.body`, `definition.body.id`, `definition.body.properties`, `definition.body.properties.css_class`, `definition.body.properties.id`, `definition.body.sections`, `definition.body.styles`, `definition.body.styles.background_color`, `definition.body.styles.width`, `definition.id`, `definition.styles`, `definition.template_id`, `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`
  - `attributes` (object, required)
    - `name` (string, required): The name of the template Example: `Monthly Newsletter Template`
    - `editor_type` (string, required): Restricted to CODE, USER_DRAGGABLE, or SYSTEM_DRAGGABLE
    - `html` (string, nullable): The HTML contents of the template. Required for CODE/USER_DRAGGABLE; not allowed for SYSTEM_DRAGGABLE.
    - `definition` (object)
      - `id` (string, nullable)
      - `template_id` (string, nullable)
      - `body` (object, required): Fields nested this deep are in [the endpoint's OpenAPI document](https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15/openapi/stable/apis/create_template.json).
      - `styles` (oneOf[], required): When present, must contain exactly one of each style type. Fields nested this deep are in [the endpoint's OpenAPI document](https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15/openapi/stable/apis/create_template.json).
    - `text` (string, nullable): The plaintext version of the template Example: `hello world`
    - `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) Not allowed for SYSTEM_DRAGGABLE.

### Example request body

```json
{
  "data": {
    "type": "template",
    "attributes": {
      "name": "Monthly Newsletter Template",
      "editor_type": "string",
      "text": "hello world"
    }
  }
}
```

## 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.
    - `definition` (object): Same fields as TemplateDefinition in the request body above.
  - `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",
      "definition": {
        "id": "string",
        "template_id": "string",
        "body": {
          "id": "string",
          "properties": {
            "id": "string",
            "css_class": "string"
          },
          "styles": {
            "background_color": "string",
            "width": 0
          },
          "sections": [
            {
              "id": "string",
              "data_id": "string",
              "universal_id": "string",
              "content_type": "section",
              "type": "section",
              "data": {
                "properties": {
                  "is_ai_generated": true,
                  "is_prebuilt_content": true
                },
                "display_options": {
                  "show_on": "all",
                  "content_repeat": {
                    "repeat_for": "string",
                    "item_alias": "string"
                  },
                  "visibility": {
                    "check": "string",
                    "definition": "string",
                    "is_code_only": true
                  },
                  "layout_type": "string",
                  "layout_config": {}
                },
                "styles": {
                  "background_asset_id": "string",
                  "background_color": "string",
                  "background_format": "auto",
                  "background_image_full_width": true,
                  "background_position": "center-bottom",
                  "background_repeat": true,
                  "background_url": "string",
                  "border_color": "string",
                  "border_style": "dashed",
                  "border_width": 0,
                  "column_align": "baseline",
                  "column_direction": "ltr",
                  "content_color": "string",
                  "content_color_type": "none",
                  "inner_padding_bottom": 0,
                  "inner_padding_left": 0,
                  "inner_padding_right": 0,
                  "inner_padding_top": 0,
                  "stack_on_mobile": true
                }
              },
              "rows": [
                {
                  "id": "string",
                  "data_id": "string",
                  "data": {
                    "styles": {
                      "column_layout": "1-column-full-width"
                    }
                  },
                  "columns": [
                    {
                      "id": "string",
                      "data_id": "string",
                      "data": {},
                      "blocks": [
                        {
                          "id": "string",
                          "data_id": "string",
                          "universal_id": "string",
                          "content_type": "block",
                          "type": "button",
                          "data": {
                            "content": "string",
                            "properties": {
                              "href": "string"
                            },
                            "display_options": {
                              "show_on": "all",
                              "content_repeat": {
                                "repeat_for": "string",
                                "item_alias": "string"
                              },
                              "visibility": {
                                "check": "string",
                                "definition": "string",
                                "is_code_only": true
                              },
                              "layout_type": "string",
                              "layout_config": {}
                            },
                            "styles": {
                              "background_color": "string",
                              "block_background_color": "string",
                              "block_padding_bottom": 0,
                              "block_padding_left": 0,
                              "block_padding_right": 0,
                              "block_padding_top": 0,
                              "border_color": "string",
                              "border_radius": 0,
                              "border_style": "dashed",
                              "border_width": 0,
                              "color": "string",
                              "drop_shadow_color": "string",
                              "font_family": "string",
                              "font_size": 0,
                              "font_style": "italic",
                              "font_weight": "string",
                              "inner_padding_bottom": 0,
                              "inner_padding_left": 0,
                              "inner_padding_right": 0,
                              "inner_padding_top": 0,
                              "letter_spacing": 0,
                              "mobile_stretch_content": true,
                              "stretch": true,
                              "text_align": "center",
                              "text_decoration": "string"
                            }
                          }
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        "styles": [
          {
            "id": "string",
            "style_type": "base-styles",
            "properties": {
              "currency": "string",
              "currency_set_on_template": true,
              "disable_websafe_fonts": true,
              "is_user_draggable": true,
              "mobile_optimizations": true,
              "tip_tap_enabled": true
            },
            "styles": {
              "background_asset_id": "string",
              "background_format": "auto",
              "background_position": "center-bottom",
              "background_repeat": true,
              "background_url": "string",
              "border_color": "string",
              "border_radius": 0,
              "border_style": "dashed",
              "border_width": 0,
              "content_background_color": "string",
              "inner_padding_bottom": 0,
              "inner_padding_left": 0,
              "inner_padding_right": 0,
              "inner_padding_top": 0,
              "margin_top": 0
            }
          }
        ]
      }
    },
    "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"
      }
    }
  ]
}
```
