---
title: "Add a new template"
method: POST
path: "/templates"
tags: ["templates"]
---

# Add a new template

`POST /templates`

Add a new template to be used in the e-mail campaigns. The template's parts (subject, html and text) can
contain tags which are used to personalize the campaign's content. The tag names are defined between two curly brackets e.g. `{{name}}`.

## Request body

- object
  - `name` string, required — The name of the new template, must be unique.
  - `subject_part` string, required — The subject part
  - `html_part` string, required — The HTML content used in the e-mail campaign.
  - `text_part` string, required — The text content used in the e-mail campaign.

## Response `201`

OK

- Template
  - `id` integer — The ID of the resource.
  - `created_at` string, date-time — The date and time when the resource was created.
  - `updated_at` string, date-time — The date and time when the resource was last updated.
  - `name` string — The name of the template.
  - `subject_part` string — The subject part.
  - `html_part` string — The HTML content used in the e-mail campaign.
  - `text_part` string — The text content used in the e-mail campaign.

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `422` — Unprocessable entity
- `default` — Unexpected error

---

[API](https://skmtc.dev/mailbadger/apis/mailbadger-api.md) · [All operations](https://skmtc.dev/mailbadger/apis/mailbadger-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/mailbadger/mailbadger-api/revisions/3a7ef49250a1/schema)
