# createTag mutation


`createTag` 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 tag. Call it to set up the tags an integration puts on records, such as one per order
status in a shop.

- `code` is derived from the name when left out. Lowercase letters, digits and hyphens, at most
  63 characters; unique among live tags.
- `group` puts the tag in the group with that code; the tag then takes the group's agendas.
- `agendas` default to sales orders, purchase orders and the three invoice registers.

#### Permissions

Requires the `tag.manage` permission.

#### Errors

- `VALIDATION` on `input.name` or `input.code` when blank, malformed or already used by a live
  tag; on `input.agendas` when empty.
- `NOT_FOUND` when no tag group has the code in `input.group`.
- `CONFLICT` with reason `TAG_GROUP_CONFLICT` cannot happen here: a new tag is on no record.

## Arguments

- `input`: [`CreateTagInput!`](/chameleoon-max/type/create-tag-input) · required

## Returns

[`Tag!`](/chameleoon-max/type/tag)

## Example

**Mutation**

```graphql
mutation createTag($input: CreateTagInput!) {
  createTag(input: $input) {
    code
    name
    description
    archived
    agendas
    group {
      code
      name
      exclusive
      automationOnly
      archived
      description
    }
    colour
    icon
    sortOrder
  }
}
```

**Variables**

```json
{
  "input": {
    "name": "example"
  }
}
```

**Response**

```json
{
  "data": {
    "createTag": {
      "code": "example",
      "name": "example",
      "description": "example",
      "archived": true,
      "agendas": [
        "SALES_ORDER"
      ],
      "group": {
        "code": "example",
        "name": "example",
        "exclusive": true,
        "automationOnly": true,
        "archived": true,
        "description": "example"
      },
      "colour": "SLATE",
      "icon": "TAG",
      "sortOrder": 1
    }
  }
}
```

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