## What the conditions of SLA policies and mail routes can test (desk:admin)

`GET /api/desk/v1/conditions/catalog`

Module: Desk · operationId: `getConditionCatalog` · Tag: Automation · Auth: access token (`Authorization: Bearer <accessToken>`)

The conditions of desk's settings are bool expressions in the flow language over `trigger.data` – the language of an automation trigger's `filter` (ADR 0044). `item` describes `trigger.data` of a condition about a ticket (the `match` of an SLA policy): the ticket's event payload, the schema of desk's ticket events. `mail` describes it for the condition of a mail source route: the facts of the received mail. Each comes with its JSON schema and the fields for a condition editor – `path` (the expression reads `trigger.data.<path>`), `type` (string, number, boolean, list, datetime), `label` (de, en) and, where the field has a known set, `values` (the tenant's keys and names; one field per custom field as `fields.<key>`). `functions` are the functions an expression may call. A condition is checked when it is saved: one that does not compile, reads a field the schema does not have or yields no true/false is 400 `invalid` on `match` / `routes[n].condition` with the message.

### Responses

- **200** The catalogue (`application/json`)
- **403** Error (`application/json`)

Fields of the 200 answer:

- `functions` (array of string, required): Functions an expression may call
- `item` (ConditionSubject, required)
  - `fields` (array of object, required): Fields a condition can test
    - `label` (object, required): Label of the field
      - `de` (string, required): German label
      - `en` (string, required): English label
    - `path` (string, required): Field below `trigger.data` (`priority`, `fields.risiko`)
    - `type` (string, required): Value type of the field (one of `string`, `number`, `boolean`, `list`, `datetime`)
    - `values` (array of object): The values to choose from, when the field has a known set
      - `label` (object, required): Label of the value
        - `de` (string, required): German label
        - `en` (string, required): English label
      - `value` (string, required): A value the field can have
  - `schema` (object, required): JSON schema of `trigger.data`
- `mail` (ConditionSubject, required)
  - `fields` (array of object, required): Fields a condition can test
    - `label` (object, required): Label of the field
      - `de` (string, required): German label
      - `en` (string, required): English label
    - `path` (string, required): Field below `trigger.data` (`priority`, `fields.risiko`)
    - `type` (string, required): Value type of the field (one of `string`, `number`, `boolean`, `list`, `datetime`)
    - `values` (array of object): The values to choose from, when the field has a known set
      - `label` (object, required): Label of the value
        - `de` (string, required): German label
        - `en` (string, required): English label
      - `value` (string, required): A value the field can have
  - `schema` (object, required): JSON schema of `trigger.data`

Example 200 answer:

```json
{
  "functions": [
    "len",
    "any",
    "all",
    "contains",
    "hasPrefix",
    "lower",
    "now"
  ],
  "item": {
    "fields": [
      {
        "label": {
          "de": "Bereich",
          "en": "Space"
        },
        "path": "spaceKey",
        "type": "string",
        "values": [
          {
            "label": {
              "de": "Support",
              "en": "Support"
            },
            "value": "SUP"
          },
          {
            "label": {
              "de": "Kundenprojekte",
              "en": "Kundenprojekte"
            },
            "value": "PRJ"
          }
        ]
      },
      {
        "label": {
          "de": "Priorität",
          "en": "Priority"
        },
        "path": "priority",
        "type": "string",
        "values": [
          {
            "label": {
              "de": "Kritisch",
              "en": "Kritisch"
            },
            "value": "kritisch"
          },
          {
            "label": {
              "de": "Hoch",
              "en": "Hoch"
            },
            "value": "hoch"
          }
        ]
      },
      {
        "label": {
          "de": "Labels",
          "en": "Labels"
        },
        "path": "labels",
        "type": "list"
      },
      {
        "label": {
          "de": "Betroffenes System",
          "en": "Betroffenes System"
        },
        "path": "fields.betroffenes_system",
        "type": "string"
      }
    ],
    "schema": {
      "properties": {
        "labels": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "priority": {
          "type": "string"
        },
        "spaceKey": {
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "mail": {
    "fields": [
      {
        "label": {
          "de": "Absender-Domain",
          "en": "Sender domain"
        },
        "path": "fromDomain",
        "type": "string"
      },
      {
        "label": {
          "de": "Betreff",
          "en": "Subject"
        },
        "path": "subject",
        "type": "string"
      },
      {
        "label": {
          "de": "Mit Anhang",
          "en": "Has attachments"
        },
        "path": "hasAttachments",
        "type": "boolean"
      }
    ],
    "schema": {
      "properties": {
        "from": {
          "type": "string"
        },
        "fromDomain": {
          "type": "string"
        },
        "subject": {
          "type": "string"
        }
      },
      "type": "object"
    }
  }
}
```

### Example request

```bash
curl -X GET 'https://api.mbcom.cloud/api/desk/v1/conditions/catalog' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
