> ## Documentation Index
> Fetch the complete documentation index at: https://docs.convocore.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Custom Metric

> Create a new custom metric for tracking agent-specific data

## Overview

Creates a new custom metric that can be tracked during agent conversations. Metrics enable you to measure and analyze specific data points relevant to your business.

## Metric Types

### Number

For quantifiable metrics like ratings, counts, or durations.

```json theme={null}
{
  "metric": {
    "key": "customer_satisfaction",
    "description": "Customer satisfaction rating (1-10)",
    "type": "number"
  }
}
```

### Boolean

For yes/no questions or binary states.

```json theme={null}
{
  "metric": {
    "key": "issue_resolved",
    "description": "Whether the customer's issue was resolved",
    "type": "boolean"
  }
}
```

### Enum

For predefined categorical options.

```json theme={null}
{
  "metric": {
    "key": "sentiment",
    "description": "Customer sentiment analysis",
    "type": "enum",
    "options": ["positive", "negative", "neutral"]
  }
}
```

<Warning>
  Enum type metrics **must** include an `options` array with at least one value.
</Warning>

### String

For open-ended text responses.

```json theme={null}
{
  "metric": {
    "key": "feedback",
    "description": "Customer feedback comments",
    "type": "string"
  }
}
```

## Key Guidelines

<Note>
  * Metric keys must be **unique** per agent
  * Keys should be descriptive (e.g., `customer_satisfaction` not `cs`)
  * Keys are **case-sensitive**
  * Maximum key length: 100 characters
</Note>

## Common Use Cases

* **NPS Score**: Track Net Promoter Score
* **Resolution Time**: Measure average time to resolve issues
* **Sentiment Analysis**: Categorize conversation sentiment
* **Lead Quality**: Score lead quality (1-5)
* **Product Interest**: Track which products customers ask about

<Tip>
  After creating a metric, your agent will automatically start tracking it during conversations where the information is available.
</Tip>


## OpenAPI

````yaml POST /agents/{agentId}/custom-metrics
openapi: 3.0.3
info:
  title: Convocore OpenAPI
  description: Full API reference for Convocore
  version: 1.0.4
servers:
  - url: https://eu-gcp-api.vg-stuff.com/v3
    description: EU Node.js API server
  - url: https://na-gcp-api.vg-stuff.com/v3
    description: NA Node.js API server
security: []
paths:
  /agents/{agentId}/custom-metrics:
    post:
      tags:
        - Custom Metrics
      summary: Create a new custom metric
      description: >-
        Creates a new custom metric for an agent. The metric can be of type
        'number', 'boolean', 'enum', or 'string'. For 'enum' type, you must
        provide options.
      operationId: customMetrics-createMetric
      parameters:
        - name: agentId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the agent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                metric:
                  type: object
                  properties:
                    key:
                      type: string
                      minLength: 1
                      maxLength: 100
                      description: >-
                        Unique key for the metric (e.g.,
                        'customer_satisfaction')
                    description:
                      type: string
                      maxLength: 500
                      description: Description of what this metric measures
                    type:
                      type: string
                      enum:
                        - number
                        - boolean
                        - enum
                        - string
                      description: 'Type of metric: ''number'', ''boolean'', ''enum'', or ''string'''
                    options:
                      type: array
                      items:
                        type: string
                      description: 'Required for ''enum'' type: list of possible values'
                    isSystem:
                      type: boolean
                      description: 'Whether this is a system metric (default: false)'
                  required:
                    - key
                    - description
                    - type
                  additionalProperties: false
              required:
                - metric
              additionalProperties: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  metricId:
                    type: string
                  metric:
                    type: object
                    properties:
                      id:
                        type: string
                      key:
                        type: string
                      description:
                        type: string
                      isSystem:
                        type: boolean
                      type:
                        type: string
                        enum:
                          - number
                          - boolean
                          - enum
                          - string
                      options:
                        type: array
                        items:
                          type: string
                      createdAtUNIX:
                        type: number
                      updatedAtUNIX:
                        type: number
                    required:
                      - id
                      - key
                      - description
                      - type
                    additionalProperties: false
                required:
                  - success
                  - message
                  - metricId
                  - metric
                additionalProperties: false
        default:
          $ref: '#/components/responses/error'
      security:
        - Authorization: []
components:
  responses:
    error:
      description: Error response
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
              code:
                type: string
              issues:
                type: array
                items:
                  type: object
                  properties:
                    message:
                      type: string
                  required:
                    - message
                  additionalProperties: false
            required:
              - message
              - code
            additionalProperties: false
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer

````