# updateEmailTemplate mutation


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

Updates the template's head: its name, resource kind and defaults. Call it with the `version`
you read. A field you omit keeps its value, and a field sent as null is cleared.

- Requires the `emailTemplate.manage` permission. Changing `defaultCc` or `defaultBcc` also
  requires the `email.read` permission (otherwise `FORBIDDEN_ROLE`).
- `CONFLICT` with reason `TEMPLATE_CHANGED` when somebody saved the template after you read it.
  Read it again.

## Arguments

- `input`: [`UpdateEmailTemplateInput!`](/chameleoon-max/type/update-email-template-input) · required

## Returns

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

## Example

**Mutation**

```graphql
mutation updateEmailTemplate($input: UpdateEmailTemplateInput!) {
  updateEmailTemplate(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
  }
}
```

**Response**

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