---
title: "Create an email template"
method: POST
path: "/email_templates"
tags: ["Email Templates"]
---

# Create an email template

`POST /email_templates`

Creates a Liquid email template. Variables are auto-extracted when omitted.

## Headers

- `Idempotency-Key` string

## Request body

- CreateEmailTemplateRequest
  - `name` string, required — Letters, numbers, spaces, hyphens, and underscores only.
  - `subject` string, nullable — Liquid template subject.
  - `html_body` string, nullable — Liquid template HTML body.
  - `text_body` string, nullable — Liquid template text body.
  - `variables` string[] — Template variables. Auto-extracted from subject/body fields when absent.
  - `strict_variables` boolean — Per-template strict variable-validation setting. Defaults to `false` for backward compatibility. When `true`, a send or render that is missing a variable marked `required: true` in `variable_schema` fails with 422 naming the variable. Missing optional variables never fail; their schema `default` (when set) is applied to the render.
  - `autoescape` boolean — Per-template HTML autoescaping setting. Defaults to `false` for backward compatibility. When `true`, the rendered `html_body` HTML-escapes each Liquid expression's output at the output boundary (after its filters run, before concatenation with literal template markup). Input values are never mutated and `subject`/`text_body` are never autoescaped. The boundary escape is idempotent: HTML entities already present in the output (e.g. from an explicit `escape` filter) are preserved, so an explicit `escape`/`escape_once` is never double-escaped, and markup introduced by any later filter in the chain is still escaped.
  - `variable_schema` object, nullable — Structured variable requirements. Required variables cannot define defaults; invalid combinations return 422. This is independent of the legacy `variables` array. On render with `strict_variables` enabled: `required` variables must be supplied as non-empty values — absent, `null`, empty string, empty object `{}`, and empty array `[]` all fail with 422 naming the variable, while present values such as `false` and `0` pass (they are present, not empty). Optional variables fall back to their `default` when absent.

## Response `201`

Template created.

- EmailTemplateResponse
  - `data` EmailTemplate, required
    - `record_type` 'email_template', required
    - `id` string, uuid, required
    - `name` string, required
    - `subject` string, nullable, required
    - `html_body` string, nullable, required
    - `text_body` string, nullable, required
    - `variables` string[], required — Legacy unstructured variable names. This path remains supported unchanged.
    - `strict_variables` boolean, required — Whether strict variable validation is enabled for this template. When `true`, sends and renders that are missing a variable marked `required: true` in `variable_schema` fail with 422 naming the variable.
    - `autoescape` boolean, required — Whether HTML autoescaping is enabled for this template. When `true`, only rendered `html_body` expression output is HTML-escaped at the output boundary; `subject` and `text_body` are never autoescaped.
    - `variable_schema` object, nullable, required — Structured variable requirements, or `null` when the template uses only the legacy `variables` array.
    - `created_at` string, date-time, required
    - `updated_at` string, date-time, required

## Other responses

- `400` — Bad Request / Validation Failed (10015). Invalid, duplicate, empty, malformed, or overlong Idempotency-Key headers are rejected by Edge with HTTP 400 and error code 10015.
- `401` — Not authorized (10006).
- `409` — A request with the same Idempotency-Key is still being processed (10036). Retry later with the same key and request.
- `413` — Request body exceeds the 8,000,000-byte limit for this endpoint.
- `422` — Validation Failed (10015) or changeset validation error. Reusing an Idempotency-Key with a different request also returns 422 (10027).
- `503` — Service unavailable (10016), including an unavailable upstream dependency or unavailable Edge idempotency protection for a keyed request.

## Changes

> 93 revisions in range; 1 not diffed.

- **2026-09-23** `16bfa298dc71` — 6 info
  - added the new optional request property `autoescape`
  - added the new optional request property `strict_variables`
  - added the new optional request property `variable_schema`
  - added the required property `data/autoescape` to the response with the `201` status
  - …2 more
- **2026-09-22** `9621f6123ebc` — 12 warning
  - added the new `10011` enum value to the `errors/items/code` response property for the response status `400`
  - added the new `10011` enum value to the `errors/items/code` response property for the response status `401`
  - added the new `10011` enum value to the `errors/items/code` response property for the response status `409`
  - added the new `10011` enum value to the `errors/items/code` response property for the response status `413`
  - …8 more
- **2026-07-16** `2fb3b617430a` — 12 warning, 6 info
  - added the new `recipient_suppressed` enum value to the `errors/items/code` response property for the response status `400`
  - added the new `recipient_suppressed` enum value to the `errors/items/code` response property for the response status `401`
  - added the new `recipient_suppressed` enum value to the `errors/items/code` response property for the response status `409`
  - added the new `recipient_suppressed` enum value to the `errors/items/code` response property for the response status `413`
  - …14 more
- …earlier changes not shown

[Full history](https://skmtc.dev/team-telnyx/apis/telnyx-api-2/changes/email_templates/post.md)

---

[API](https://skmtc.dev/team-telnyx/apis/telnyx-api-2.md) · [All operations](https://skmtc.dev/team-telnyx/apis/telnyx-api-2/llms.txt) · [OpenAPI document](https://skmtc.dev/team-telnyx/apis/telnyx-api-2/revisions/88481995b4ca?raw)
