# convertEmailTemplateToHtml mutation


`convertEmailTemplateToHtml` is a GraphQL mutation of the Chameleoon MAX API. Send it as `POST https://max-api.chameleoon.sk/api/v1/graphql` with your API key, see [Chameleoon MAX](/chameleoon-max).

Creates a new `HTML` template from a `JSON` one. Call it when you want to edit the HTML by
hand. The `JSON` template stays as it is.

- The new template's one all-languages variant is the design rendered to HTML and text, with
  the `JSON` variant's subject.
- The texts, defaults and resource kind are copied.
- Requires the `emailTemplate.manage` permission.
- `VALIDATION` (field `from`) with reason `NOT_JSON` when the template is not a `JSON` one,
  built-in templates included.

## Arguments

- `input`: [`ConvertEmailTemplateToHtmlInput!`](/chameleoon-max/type/convert-email-template-to-html-input) · required

## Returns

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

## Example

**Mutation**

```graphql
mutation convertEmailTemplateToHtml($input: ConvertEmailTemplateToHtmlInput!) {
  convertEmailTemplateToHtml(input: $input) {
    id
    code
    name
    builtIn
    resourceKind
    syntax
    variants {
      language
      subject
      htmlBody
      textBody
      design
    }
    languages
    allLanguages
    texts(first: 10) {
      totalCount
    }
    defaultTo
    defaultCc
    defaultBcc
    defaultAttachments
    copiedFrom
    version
  }
}
```

**Variables**

```json
{
  "input": {
    "from": "example",
    "code": "example",
    "name": "example"
  }
}
```

**Response**

```json
{
  "data": {
    "convertEmailTemplateToHtml": {
      "id": "00000000-0000-4000-8000-000000000001",
      "code": "example",
      "name": "example",
      "builtIn": true,
      "resourceKind": "NONE",
      "syntax": "HTML",
      "variants": [
        {
          "language": "example",
          "subject": "example",
          "htmlBody": "example",
          "textBody": "example",
          "design": {}
        }
      ],
      "languages": [
        "example"
      ],
      "allLanguages": true,
      "texts": {
        "totalCount": 1
      },
      "defaultTo": "CUSTOMER",
      "defaultCc": [
        "example"
      ],
      "defaultBcc": [
        "example"
      ],
      "defaultAttachments": [
        "ORDER_INVOICE_PDF"
      ],
      "copiedFrom": "example",
      "version": 1
    }
  }
}
```

Values are illustrative: replace IDs and codes with your own before you send the call.
