# EmailTemplate type


An e-mail template: the subject and bodies of an e-mail, written in Liquid. It is one of the
organisation's templates or a MAX built-in one.

- A template has a variant per language, and an all-languages variant for every language without
  its own. A send in a language uses that language's variant, else the all-languages one, else the
  variant in the organisation's default language, else the first in `sk`, `cs`, `en`, then code
  order.
- Its texts are a dictionary every variant reads as `t.<key>`. A text is taken in the send's
  language, else the organisation's default language, else `en`, else the first translation there
  is, else empty. A missing translation never fails a send.
- A built-in template comes first in the list, has no `id` and one all-languages variant without a
  subject, and cannot be written. Copy it to change it.

## Fields

### id

[`UUID`](/chameleoon-max/type/uuid)

The template's MAX id. Null for a built-in template.

### code

`String!`

The template's code, which identifies it: lowercase words joined by `-`.

### name

`String!`

The template's display name.

### builtIn

`Boolean!`

Whether this is a MAX built-in template.

### resourceKind

[`EmailTemplateResourceKind!`](/chameleoon-max/type/email-template-resource-kind)

The kind of record the template is written for.

### syntax

[`EmailTemplateSyntax!`](/chameleoon-max/type/email-template-syntax)

How the template is written, fixed for its whole life. Built-in templates are `JSON`.

### variants

[`[EmailTemplateVariant!]!`](/chameleoon-max/type/email-template-variant)

The subject and bodies per language: the all-languages variant first, then `sk`, `cs`, `en`,
then the rest by code.

- A plain list, not a connection: one variant per language the template is written in.
- A `JSON` template has exactly one, the all-languages variant. Its languages are its
  translations.
- Priced as 26 variants (one per language of the locales catalogue, plus the all-languages
  one), however many it holds.
- Costs 26 points plus 26 × one variant's selection.

### languages

`[String!]!`

The languages that have a variant of their own, in `sk`, `cs`, `en` order, then the rest by
code. Priced as 25 languages (the locales catalogue), however many it holds.

Costs 25 points.

### allLanguages

`Boolean!`

Whether the template has the all-languages variant.

### texts

[`EmailTemplateTextConnection!`](/chameleoon-max/type/email-template-text-connection)

Arguments:

- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

The dictionary every variant reads as `t.<key>`, by key. A template has at most 200 keys.

- A connection, paged with `first`/`after` or `last`/`before`, at most 250 a page.
- Its cursors belong to this template's texts and are refused anywhere else.
- A page costs 2 + first (or last) × the cost of one node.

### defaultTo

[`EmailTemplateRecipient`](/chameleoon-max/type/email-template-recipient)

Who a send goes to when it names no recipient. Null when there is no default.

### defaultCc

`[String!]!`

The addresses every send copies in `cc` when it names no `cc`.

Priced as 50 addresses, however many it holds.

Costs 50 points.

### defaultBcc

`[String!]!`

The addresses every send copies in `bcc` when it names no `bcc`.

Priced as 50 addresses, however many it holds.

Costs 50 points.

### defaultAttachments

[`[EmailTemplateAttachment!]!`](/chameleoon-max/type/email-template-attachment)

What a send attaches when it names no attachments.

Priced as 2 attachments, however many it holds.

Costs 2 points.

### copiedFrom

`String`

The code of the template this one was copied from. Null when it is not a copy.

### version

`Int!`

The template's version. Send it back on a change; the change is refused when somebody saved
first. `0` for a built-in template.

## Used by

- [`convertEmailTemplateToHtml`](/chameleoon-max/mutation/convert-email-template-to-html) (mutation)
- [`copyEmailTemplate`](/chameleoon-max/mutation/copy-email-template) (mutation)
- [`createEmailTemplate`](/chameleoon-max/mutation/create-email-template) (mutation)
- [`removeEmailTemplateVariant`](/chameleoon-max/mutation/remove-email-template-variant) (mutation)
- [`saveEmailTemplateDesign`](/chameleoon-max/mutation/save-email-template-design) (mutation)
- [`setEmailTemplateTexts`](/chameleoon-max/mutation/set-email-template-texts) (mutation)
- [`setEmailTemplateVariant`](/chameleoon-max/mutation/set-email-template-variant) (mutation)
- [`updateEmailTemplate`](/chameleoon-max/mutation/update-email-template) (mutation)
- [`emailTemplate`](/chameleoon-max/query/email-template) (query)
- [`EmailTemplateConnection`](/chameleoon-max/type/email-template-connection)
- [`EmailTemplateEdge`](/chameleoon-max/type/email-template-edge)
