# \[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 %}
