# \[In beta] Email Templates

## Create new email template

<mark style="color:green;">`POST`</mark> `https://api.smtpd.dev/api/v1/email/template`

This endpoint creates a new email template, each template as an associated revision. When you send an email using a template you can default to latest OR a specific revisions, which enables testing for new revisions.&#x20;

#### Headers

| Name           | Type   | Description             |
| -------------- | ------ | ----------------------- |
| Authentication | string | `Bearer {access_token}` |

#### Request Body

| Name                 | Type    | Description                                                            |
| -------------------- | ------- | ---------------------------------------------------------------------- |
| tags                 | object  |                                                                        |
| link\_tracking       | boolean |                                                                        |
| open\_tracking       | boolean |                                                                        |
| reply\_to            | string  |                                                                        |
| from\_name           | string  |                                                                        |
| from\_email\_address | string  |                                                                        |
| content\_text        | string  | The Text email content                                                 |
| content\_html        | string  | The HTML email content                                                 |
| template\_name       | string  | Template name, this will be automatically added as a tag when sending. |

{% tabs %}
{% tab title="201 Template created" %}

```
{
    "template_id": "b9106530-aa81-4776-bf65-ac7d226ae528",
    "revision": 1
}
```

{% endtab %}
{% endtabs %}

## Create new email template revision

<mark style="color:green;">`POST`</mark> `https://api.smtpd.dev/api/v1/email/template/:id`

This endpoint creates a new email template

#### Headers

| Name           | Type   | Description             |
| -------------- | ------ | ----------------------- |
| Authentication | string | `Bearer {access_token}` |

#### Request Body

| Name                 | Type    | Description                                                            |
| -------------------- | ------- | ---------------------------------------------------------------------- |
| tags                 | object  |                                                                        |
| link\_tracking       | boolean |                                                                        |
| open\_tracking       | boolean |                                                                        |
| reply\_to            | string  |                                                                        |
| from\_name           | string  |                                                                        |
| from\_email\_address | string  |                                                                        |
| content\_text        | string  | The Text email content                                                 |
| content\_html        | string  | The HTML email content                                                 |
| template\_name       | string  | Template name, this will be automatically added as a tag when sending. |

{% tabs %}
{% tab title="202 Template created" %}

```
{
    "template_id": "b9106530-aa81-4776-bf65-ac7d226ae528",
    "revision": 2
}
```

{% endtab %}

{% tab title="404 " %}

```
{
  "code": 40401,
  "message": "Resource ID provided is invalid"
}
```

{% endtab %}
{% endtabs %}

## Set revision to $latest

<mark style="color:green;">`POST`</mark> `https://api.smtpd.dev/api/v1/email/template/:id/latest`

This endpoint creates a new email template

#### Headers

| Name           | Type   | Description             |
| -------------- | ------ | ----------------------- |
| Authentication | string | `Bearer {access_token}` |

#### Request Body

| Name     | Type   | Description                     |
| -------- | ------ | ------------------------------- |
| revision | number | The revsion that will be latest |

{% tabs %}
{% tab title="200 Template created" %}

```
null
```

{% endtab %}

{% tab title="404 " %}

```
{
  "code": 40401,
  "message": "Resource ID provided is invalid"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.smtpd.dev/api/email-templates-in-beta.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
