# Get metric

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

Get a metric by id.

## GET /beta/intelligence/metrics/{metricId}

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

### Request example

```bash
curl -X GET 'https://dev.dixa.io/beta/intelligence/metrics/{metricId}' \
  -H 'Authorization: <API token>'
```

### Response examples

#### 200 The metric

Event count:

```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"
    ]
  }
}
```

Duration statistics:

```json
{
  "data": {
    "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"
    ]
  }
}
```

Structured aggregates:

```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"
    ]
  }
}
```

Conditional counts:

```json
{
  "data": {
    "id": "aiAgentFeedback",
    "name": "AI agent feedback",
    "category": "aiagents",
    "description": "The number of AI agent answers end users rated in the selected period, in total and per score",
    "definition": "Counts the thumbs ratings end users gave an AI agent's answer, split into thumbs up and thumbs down.",
    "deprecated": false,
    "primaryFilters": [
      "period"
    ],
    "filters": [
      {
        "attribute": "queue",
        "aliases": [
          "queueId"
        ],
        "type": "Uuid",
        "operators": [
          "IsEmpty",
          "IsNotEmpty",
          "IsOne",
          "IsNotOne"
        ],
        "defaultOperator": "IsOne",
        "description": "The queue the conversation was routed 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"
      },
      {
        "attribute": "conversation",
        "aliases": [
          "conversationId",
          "csid"
        ],
        "type": "Integer",
        "operators": [
          "IsOne",
          "IsNotOne",
          "GreaterThan",
          "GreaterThanOrEqual",
          "LessThan",
          "LessThanOrEqual"
        ],
        "defaultOperator": "IsOne",
        "description": "The conversation"
      },
      {
        "attribute": "aiAgent",
        "aliases": [
          "aiAgentId"
        ],
        "type": "String",
        "operators": [
          "IsEmpty",
          "IsNotEmpty",
          "IsOne",
          "IsNotOne"
        ],
        "defaultOperator": "IsOne",
        "description": "The AI agent"
      }
    ],
    "aggregates": [
      {
        "name": "count",
        "type": "Integer",
        "defaultIncluded": true,
        "description": "The number of rated answers in the period"
      },
      {
        "name": "thumbsUp",
        "type": "Integer",
        "defaultIncluded": true,
        "description": "The number of answers rated thumbs up"
      },
      {
        "name": "thumbsDown",
        "type": "Integer",
        "defaultIncluded": true,
        "description": "The number of answers rated thumbs down"
      }
    ],
    "relatedRecordIds": [
      "aiAgentFeedback"
    ]
  }
}
```

#### 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/{metricId}:
    get:
      tags:
        - Intelligence
      summary: Get metric
      description: Get a metric by id.
      operationId: getIntelligenceMetricsMetricid
      parameters:
        - name: metricId
          in: path
          description: The metric id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: The metric
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntelligenceMetric"
        "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:
    IntelligenceMetric:
      title: IntelligenceMetric
      type: object
      required:
        - data
      properties:
        data:
          $ref: "#/components/schemas/MetricCatalogueEntry"
    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
    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
```
