## Which policy applies to an item and when its targets would be due (desk:admin)

`POST /api/desk/v1/sla/policies/test`

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

### Request body

`application/json` (required)

- `itemId` (string, required)

Example:

```json
{
  "itemId": "#1"
}
```

### Responses

- **200** Result (`application/json`)

Fields of the 200 answer:

- `checked` (array of object): Every policy in order with the result of its match
  - `enabled` (boolean, required)
  - `key` (string, required)
  - `match` (string, required): The policy's match expression
  - `matched` (boolean, required)
  - `name` (string, required)
  - `error` (string): Why the match could not be evaluated for the item (such a policy does not apply)
- `policy` (SLAPolicy)
  - `key` (string, required): Key of the policy, unique in the tenant
  - `name` (string, required): Name of the policy
  - `targets` (array of object, required): Targets of the policy
    - `minutes` (integer, required): Target in minutes
    - `target` (string, required): What is measured (one of `first_response`, `resolution`, `next_response`)
    - `byPriority` (object): Minutes per priority key
    - `escalations` (array of object): Levels of the target: when a clock reaches `percent` of it, desk writes the event `desk.sla.escalated` with the level – what happens then is an automation's or a flow's (a level has no actions of its own).
      - `id` (string, required): Key-like id
      - `percent` (integer, required): Share of the target at which the level is reached (max 1000)
      - `name` (string): Name of the level (at most 120 characters), in the event as `escalation.name`
    - `mode` (string): business: service hours of the calendar; wall: wall-clock time (one of `business`, `wall`)
    - `warnPercent` (integer): Share of the target at which the clock warns (default `80`)
  - `archived` (boolean): Archived: the policy is kept for existing data but no longer offered in pickers
  - `calendar` (string): Calendar key; empty = the default calendar
  - `description` (string): Description of the policy
  - `enabled` (boolean): Disabled policies never match
  - `id` (string, read-only): Id of the policy
  - `match` (string): The tickets the policy applies to: a bool expression in the flow language over `trigger.data`, the ticket's event payload (`GET /conditions/catalog`, `item`) – the first enabled policy whose match holds applies. Empty: every ticket. One that cannot be evaluated for a ticket does not hold (logged). (max length 4000)
  - `position` (integer, read-only): Matching order (the first enabled policy that matches applies)
  - `reevaluateOn` (array of string): Item fields whose change re-matches the policy and recalculates running clocks (e.g. priority)
  - `version` (integer): Version of the policy; send it back on change (409 version_conflict when it is outdated)
- `targets` (array of SLAClock)
  - `breachedAt` (string (date-time), nullable): When the target was breached
  - `cycle` (integer): Cycle of the target on the item (a target can run more than once)
  - `dueAt` (string (date-time), nullable): When the target is due
  - `itemId` (string): Item of the clock
  - `metAt` (string (date-time), nullable): When the target was met
  - `mode` (string): business: counts service hours; wall: counts wall-clock time
  - `percent` (integer): Share of the target used (percent)
  - `policyKey` (string): Policy the clock started with
  - `startedAt` (string (date-time)): When the clock started
  - `state` (string): State of the clock (one of `running`, `paused`, `met`, `stopped`)
  - `target` (string): Target the clock measures
  - `targetMinutes` (integer): Target in minutes
  - `usedMinutes` (integer): Minutes used so far
  - `warnAt` (string (date-time), nullable): When the warning is due
  - `warnedAt` (string (date-time), nullable): When the warning was written

Example 200 answer:

```json
{
  "checked": [
    {
      "enabled": true,
      "key": "vip",
      "match": "\"vip\" in trigger.data.labels",
      "matched": false,
      "name": "VIP-Kunden"
    },
    {
      "enabled": true,
      "key": "standard",
      "match": "trigger.data.spaceKey == \"SUP\"",
      "matched": true,
      "name": "Standard"
    }
  ],
  "policy": {
    "enabled": true,
    "id": "9d6e7f8a-0b1c-4d2e-9f4a-6b7c8d9e0f01",
    "key": "standard",
    "match": "trigger.data.spaceKey == \"SUP\"",
    "name": "Standard",
    "targets": [
      {
        "byPriority": {
          "hoch": 480
        },
        "minutes": 1440,
        "mode": "business",
        "target": "resolution"
      }
    ],
    "version": 2
  },
  "targets": [
    {
      "cycle": 1,
      "dueAt": "2026-11-17T11:12:00Z",
      "itemId": "4a1b2c3d-5e6f-4a7b-8c9d-1e2f3a4b5c01",
      "metAt": "2026-11-17T07:20:04Z",
      "mode": "business",
      "percent": 3,
      "policyKey": "standard",
      "startedAt": "2026-11-17T07:12:00Z",
      "state": "met",
      "target": "first_response",
      "targetMinutes": 240,
      "usedMinutes": 8
    },
    {
      "cycle": 1,
      "dueAt": "2026-11-17T15:12:00Z",
      "itemId": "4a1b2c3d-5e6f-4a7b-8c9d-1e2f3a4b5c01",
      "mode": "business",
      "percent": 21,
      "policyKey": "standard",
      "startedAt": "2026-11-17T07:12:00Z",
      "state": "running",
      "target": "resolution",
      "targetMinutes": 480,
      "usedMinutes": 103,
      "warnAt": "2026-11-17T13:36:00Z"
    }
  ]
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/desk/v1/sla/policies/test' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"itemId":"#1"}'
```
