# List metrics

URL: https://docs.dixa.io/openapi/dixa-api/beta/intelligence/getintelligencemetrics

List the metrics you can query, with the filters and aggregates of each metric and the records it is based on. Use the metric `id` with Query conversation metric, Query agent metric or Query AI agent metric.

## GET /beta/intelligence/metrics

- Server: https://dev.dixa.io
- Auth: `Authorization: <API token>` header

### Request example

```bash
curl -X GET 'https://dev.dixa.io/beta/intelligence/metrics?pageLimit=50' \
  -H 'Authorization: <API token>'
```

### Response examples

#### 200 The list of metrics

Every metric:

```json
{
  "data": [
    {
      "id": "closedConversations",
      "name": "Closed conversations",
      "category": "conversations",
      "description": "The number of conversations closed in the selected period",
      "deprecated": false,
      "primaryFilters": [
        "period",
        "conversationIds"
      ],
      "filters": [
        {
          "attribute": "agent",
          "aliases": [
            "agentId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The agent (AI or human) assigned to the conversation"
        },
        {
          "attribute": "queue",
          "aliases": [
            "queueId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The queue the conversation was routed to"
        },
        {
          "attribute": "team",
          "aliases": [
            "teamId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The team the conversation was assigned to"
        },
        {
          "attribute": "tag",
          "aliases": [
            "tagId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne",
            "IsAll"
          ],
          "defaultOperator": "IsOne",
          "description": "A tag attached to the conversation"
        },
        {
          "attribute": "channel",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The channel the conversation came in on"
        },
        {
          "attribute": "initialDirection",
          "aliases": [
            "direction"
          ],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The initial direction of the conversation"
        },
        {
          "attribute": "contactPoint",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The contact point the conversation arrived through"
        }
      ],
      "aggregates": [
        {
          "name": "count",
          "type": "Integer",
          "defaultIncluded": true,
          "description": "The number of conversations closed in the period, including those closed by deactivated agents"
        }
      ],
      "relatedRecordIds": [
        "closedConversations"
      ]
    },
    {
      "id": "responseTime",
      "name": "Response time",
      "category": "conversations",
      "description": "The time conversations waited for a reply after an end user reached out",
      "definition": "Measures each completed interval as the milliseconds between an end user reaching out and the conversation being replied to. On asynchronous channels (e.g. Email, Contact form) an interval starts with an end user message and ends on the ensuing agent reply; when several end user messages arrive before a reply, the first of them starts the interval. On synchronous channels it starts when the end user reaches out and ends when they are connected to an agent (Phone) or receive the first outbound reply (e.g. Dixa Messenger). A conversation can contribute any number of intervals within the period.",
      "deprecated": false,
      "primaryFilters": [
        "period",
        "conversationIds"
      ],
      "filters": [
        {
          "attribute": "agent",
          "aliases": [
            "agentId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The agent (AI or human) assigned to the conversation"
        },
        {
          "attribute": "queue",
          "aliases": [
            "queueId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The queue the conversation was routed to"
        },
        {
          "attribute": "team",
          "aliases": [
            "teamId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The team the conversation was assigned to"
        },
        {
          "attribute": "tag",
          "aliases": [
            "tagId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne",
            "IsAll"
          ],
          "defaultOperator": "IsOne",
          "description": "A tag attached to the conversation"
        },
        {
          "attribute": "channel",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The channel the conversation came in on"
        },
        {
          "attribute": "initialDirection",
          "aliases": [
            "direction"
          ],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The initial direction of the conversation"
        },
        {
          "attribute": "contactPoint",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The contact point the conversation arrived through"
        }
      ],
      "aggregates": [
        {
          "name": "count",
          "type": "Integer",
          "defaultIncluded": true,
          "description": "The number of completed response-time intervals"
        },
        {
          "name": "min",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The lowest of the completed response-time intervals"
        },
        {
          "name": "max",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The highest of the completed response-time intervals"
        },
        {
          "name": "sum",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The total of the completed response-time intervals"
        },
        {
          "name": "average",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The mean of the completed response-time intervals"
        },
        {
          "name": "stdDev",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The standard deviation of the completed response-time intervals"
        }
      ],
      "relatedRecordIds": [
        "responseTime"
      ]
    }
  ]
}
```

Filtered by category:

```json
{
  "data": [
    {
      "id": "agentPresenceDuration",
      "name": "Agent presence duration",
      "category": "agents",
      "description": "How long agents spent working and away in the selected period",
      "definition": "Sums each agent's presence intervals, clipped to the selected period, grouped into working time (with per-media-type availability) and away time (broken down by custom away status). Durations are raw milliseconds.",
      "deprecated": false,
      "primaryFilters": [
        "period"
      ],
      "filters": [
        {
          "attribute": "agent",
          "aliases": [
            "agentId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The agent (AI or human) assigned to the conversation"
        }
      ],
      "aggregates": [
        {
          "name": "working",
          "type": "Object",
          "defaultIncluded": true,
          "description": "Total working duration in milliseconds and, under `availability`, the working duration per media type (email, chat, message, speak)"
        },
        {
          "name": "away",
          "type": "Object",
          "defaultIncluded": true,
          "description": "Total away duration in milliseconds and, under `byStatus`, the away duration per custom away status"
        }
      ],
      "relatedRecordIds": [
        "agentPresenceDuration"
      ]
    }
  ]
}
```

First page of two:

```json
{
  "data": [
    {
      "id": "closedConversations",
      "name": "Closed conversations",
      "category": "conversations",
      "description": "The number of conversations closed in the selected period",
      "deprecated": false,
      "primaryFilters": [
        "period",
        "conversationIds"
      ],
      "filters": [
        {
          "attribute": "agent",
          "aliases": [
            "agentId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The agent (AI or human) assigned to the conversation"
        },
        {
          "attribute": "queue",
          "aliases": [
            "queueId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The queue the conversation was routed to"
        },
        {
          "attribute": "team",
          "aliases": [
            "teamId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The team the conversation was assigned to"
        },
        {
          "attribute": "tag",
          "aliases": [
            "tagId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne",
            "IsAll"
          ],
          "defaultOperator": "IsOne",
          "description": "A tag attached to the conversation"
        },
        {
          "attribute": "channel",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The channel the conversation came in on"
        },
        {
          "attribute": "initialDirection",
          "aliases": [
            "direction"
          ],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The initial direction of the conversation"
        },
        {
          "attribute": "contactPoint",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The contact point the conversation arrived through"
        }
      ],
      "aggregates": [
        {
          "name": "count",
          "type": "Integer",
          "defaultIncluded": true,
          "description": "The number of conversations closed in the period, including those closed by deactivated agents"
        }
      ],
      "relatedRecordIds": [
        "closedConversations"
      ]
    },
    {
      "id": "responseTime",
      "name": "Response time",
      "category": "conversations",
      "description": "The time conversations waited for a reply after an end user reached out",
      "definition": "Measures each completed interval as the milliseconds between an end user reaching out and the conversation being replied to. On asynchronous channels (e.g. Email, Contact form) an interval starts with an end user message and ends on the ensuing agent reply; when several end user messages arrive before a reply, the first of them starts the interval. On synchronous channels it starts when the end user reaches out and ends when they are connected to an agent (Phone) or receive the first outbound reply (e.g. Dixa Messenger). A conversation can contribute any number of intervals within the period.",
      "deprecated": false,
      "primaryFilters": [
        "period",
        "conversationIds"
      ],
      "filters": [
        {
          "attribute": "agent",
          "aliases": [
            "agentId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The agent (AI or human) assigned to the conversation"
        },
        {
          "attribute": "queue",
          "aliases": [
            "queueId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The queue the conversation was routed to"
        },
        {
          "attribute": "team",
          "aliases": [
            "teamId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The team the conversation was assigned to"
        },
        {
          "attribute": "tag",
          "aliases": [
            "tagId"
          ],
          "type": "Uuid",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne",
            "IsAll"
          ],
          "defaultOperator": "IsOne",
          "description": "A tag attached to the conversation"
        },
        {
          "attribute": "channel",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The channel the conversation came in on"
        },
        {
          "attribute": "initialDirection",
          "aliases": [
            "direction"
          ],
          "type": "String",
          "operators": [
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The initial direction of the conversation"
        },
        {
          "attribute": "contactPoint",
          "aliases": [],
          "type": "String",
          "operators": [
            "IsEmpty",
            "IsNotEmpty",
            "IsOne",
            "IsNotOne"
          ],
          "defaultOperator": "IsOne",
          "description": "The contact point the conversation arrived through"
        }
      ],
      "aggregates": [
        {
          "name": "count",
          "type": "Integer",
          "defaultIncluded": true,
          "description": "The number of completed response-time intervals"
        },
        {
          "name": "min",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The lowest of the completed response-time intervals"
        },
        {
          "name": "max",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The highest of the completed response-time intervals"
        },
        {
          "name": "sum",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The total of the completed response-time intervals"
        },
        {
          "name": "average",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The mean of the completed response-time intervals"
        },
        {
          "name": "stdDev",
          "type": "Number",
          "unit": "milliseconds",
          "defaultIncluded": true,
          "description": "The standard deviation of the completed response-time intervals"
        }
      ],
      "relatedRecordIds": [
        "responseTime"
      ]
    }
  ],
  "meta": {
    "next": "/beta/intelligence/metrics?pageKey=eyJvZmZzZXQiOjIsImxpbWl0IjoyfQ&pageLimit=2"
  }
}
```

#### 400

```json
{
  "message": "Decoding failure in request"
}
```

#### 404 An entity in this request could not be found

```json
{
  "message": "The requested resource could not be found"
}
```

#### 500 Internal failure during request processing

```json
{
  "message": "There was an internal server error while processing the request"
}
```

## OpenAPI definition

The operation and the schemas used, from the full spec at https://docs.dixa.io/openapi-specs/dixa-beta.yaml. Request and response examples are above.

```yaml
openapi: 3.0.3
info:
  title: Dixa API
  version: beta
servers:
  - url: https://dev.dixa.io
security:
  - ApiKeyAuth: []
paths:
  /beta/intelligence/metrics:
    get:
      tags:
        - Intelligence
      summary: List metrics
      description: List the metrics you can query, with the filters and aggregates of
        each metric and the records it is based on. Use the metric `id` with
        Query conversation metric, Query agent metric or Query AI agent metric.
      operationId: getIntelligenceMetrics
      parameters:
        - name: category
          in: query
          description: Only list metrics in this category. If not provided, all metrics
            are listed.
          required: false
          schema:
            type: string
            enum:
              - conversations
              - agents
              - aiagents
        - name: pageKey
          in: query
          description: The key of the page to fetch. To page through the results, call the
            link in `meta.next` or `meta.previous` of the previous response,
            which already carries this key.
          required: false
          schema:
            type: string
        - name: pageLimit
          in: query
          description: The number of entries per page, up to 1000. Defaults to 50, or to
            the page size of `pageKey` when one is given.
          required: false
          schema:
            default: 50
            type: integer
            format: int32
      responses:
        "200":
          description: The list of metrics
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntelligenceMetricCatalogue"
        "400":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequest"
        "404":
          description: An entity in this request could not be found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NotFound"
        "500":
          description: Internal failure during request processing
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ServerError"
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    IntelligenceMetricCatalogue:
      title: IntelligenceMetricCatalogue
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MetricCatalogueEntry"
        meta:
          $ref: "#/components/schemas/PaginationLinks"
    MetricCatalogueEntry:
      title: MetricCatalogueEntry
      description: A metric and how to query it
      type: object
      required:
        - id
        - name
        - category
        - description
        - deprecated
      properties:
        id:
          description: The metric id, used in the URL when you query the metric
          type: string
        name:
          description: The display name
          type: string
        category:
          description: "`conversations`, `agents` or `aiagents`. Decides which endpoint
            you query the metric with"
          type: string
        description:
          description: A short description of the metric
          type: string
        definition:
          description: How the metric is calculated, if documented
          type: string
        deprecated:
          description: Whether the metric will be removed. A deprecated metric can still
            be queried
          type: boolean
        primaryFilters:
          description: "The keys the `primaryFilter` of a query supports: `period`,
            `conversationIds` or both"
          type: array
          items:
            type: string
        filters:
          description: The filters the metric supports
          type: array
          items:
            $ref: "#/components/schemas/FilterDescriptor"
        aggregates:
          description: The values the metric returns
          type: array
          items:
            $ref: "#/components/schemas/MetricAggregate"
        relatedRecordIds:
          description: The records the metric is based on
          type: array
          items:
            type: string
    FilterDescriptor:
      title: FilterDescriptor
      description: A filter the metric or record supports
      type: object
      required:
        - attribute
        - type
        - defaultOperator
        - description
      properties:
        attribute:
          description: The value to use as a filter's `attribute`
          type: string
        aliases:
          description: Other names you can use for the attribute. Responses always use
            `attribute`
          type: array
          items:
            type: string
        type:
          description: The type of the filter values
          type: string
          enum:
            - String
            - Integer
            - Number
            - Boolean
            - Uuid
            - Timestamp
            - Entity
            - List
            - Object
        operators:
          description: The operators the attribute supports
          type: array
          items:
            type: string
            enum:
              - IsEmpty
              - IsNotEmpty
              - IsOne
              - IsNotOne
              - IsAll
              - GreaterThan
              - GreaterThanOrEqual
              - LessThan
              - LessThanOrEqual
        defaultOperator:
          description: The operator used when a filter has no `operator`
          type: string
          enum:
            - IsEmpty
            - IsNotEmpty
            - IsOne
            - IsNotOne
            - IsAll
            - GreaterThan
            - GreaterThanOrEqual
            - LessThan
            - LessThanOrEqual
        description:
          description: A description of the filter
          type: string
    MetricAggregate:
      title: MetricAggregate
      description: A value the metric returns
      type: object
      required:
        - name
        - type
        - defaultIncluded
        - description
      properties:
        name:
          description: The key of the value in the response
          type: string
        type:
          description: The type of the value
          type: string
          enum:
            - String
            - Integer
            - Number
            - Boolean
            - Uuid
            - Timestamp
            - Entity
            - List
            - Object
        unit:
          description: The unit of the value, such as milliseconds. Not set when the value
            has no unit
          type: string
        defaultIncluded:
          description: Whether the value is returned by default. All values are currently
            returned
          type: boolean
        description:
          description: A description of the value
          type: string
    PaginationLinks:
      title: PaginationLinks
      type: object
      properties:
        previous:
          description: url
          type: string
        next:
          description: url
          type: string
    BadRequest:
      title: BadRequest
      type: object
      required:
        - message
      properties:
        message:
          type: string
    NotFound:
      title: NotFound
      type: object
      required:
        - message
      properties:
        message:
          type: string
    ServerError:
      title: ServerError
      type: object
      required:
        - message
      properties:
        message:
          type: string
```
