# saveEmailTemplateDesign mutation


`saveEmailTemplateDesign` 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).

Saves the design of a `JSON` template's one all-languages variant and replaces its whole
dictionary, in one change. Call it with the `version` you read. The variant keeps its subject.

- Requires the `emailTemplate.manage` permission.
- A `language` is refused with `VALIDATION` (field `language`) and reason `JSON_ONE_VARIANT`,
  because a `JSON` template's languages are its translations.
- An `HTML` template is refused with `VALIDATION` (field `design`) and reason
  `SYNTAX_MISMATCH`.
- `CONFLICT` with reason `TEMPLATE_CHANGED` when somebody saved the template after you read it.

## Arguments

- `input`: [`SaveEmailTemplateDesignInput!`](/chameleoon-max/type/save-email-template-design-input) · required

## Returns

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

## Example

**Mutation**

```graphql
mutation saveEmailTemplateDesign($input: SaveEmailTemplateDesignInput!) {
  saveEmailTemplateDesign(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": {
    "code": "example",
    "version": 1,
    "design": {},
    "texts": [
      {
        "key": "example",
        "translations": [
          {
            "language": "example",
            "value": "example"
          }
        ]
      }
    ]
  }
}
```

**Response**

```json
{
  "data": {
    "saveEmailTemplateDesign": {
      "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.
