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

# Get Metrics

> Returns usage and user-provided feedback data. This information can be used for data-driven improvements and optimization.



## OpenAPI

````yaml api-reference/openapi.json get /agents/{agent_id}/metrics
openapi: 3.1.0
info:
  title: Endpoints
  version: '1.0'
servers:
  - url: https://api.contextual.ai/v1
security:
  - BearerAuth: []
paths:
  /agents/{agent_id}/metrics:
    get:
      tags:
        - /agents/{id}/query
      summary: Get Metrics
      description: >-
        Returns usage and user-provided feedback data. This information can be
        used for data-driven improvements and optimization.
      operationId: Get_Metrics_agents__agent_id__metrics_get
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            description: Agent ID of the agent to get metrics for
            title: Agent Id
          description: Agent ID of the agent to get metrics for
        - name: conversation_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
              format: uuid
            description: Filter messages by conversation ids.
            title: Conversation Ids
          description: Filter messages by conversation ids.
        - name: user_emails
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            description: Filter messages by users.
            title: User Emails
          description: Filter messages by users.
        - name: created_after
          in: query
          required: false
          schema:
            type: string
            format: date-time
            description: Filters messages that are created after the specified timestamp.
            title: Created After
          description: Filters messages that are created after the specified timestamp.
        - name: created_before
          in: query
          required: false
          schema:
            type: string
            format: date-time
            description: >-
              Filters messages that are created before specified timestamp. If
              both `created_after` and `created_before` are not provided, then
              `created_before` will be set to the current time and
              `created_after` will be set to the `created_before` - 2 days. If
              only `created_after` is provided, then `created_before` will be
              set to the `created_after` + 2 days. If only `created_before` is
              provided, then `created_after` will be set to the `created_before`
              - 2 days. If both `created_after` and `created_before` are
              provided, and the difference between them is more than 2 days,
              then `created_after` will be set to the `created_before` - 2 days.
            title: Created Before
          description: >-
            Filters messages that are created before specified timestamp. If
            both `created_after` and `created_before` are not provided, then
            `created_before` will be set to the current time and `created_after`
            will be set to the `created_before` - 2 days. If only
            `created_after` is provided, then `created_before` will be set to
            the `created_after` + 2 days. If only `created_before` is provided,
            then `created_after` will be set to the `created_before` - 2 days.
            If both `created_after` and `created_before` are provided, and the
            difference between them is more than 2 days, then `created_after`
            will be set to the `created_before` - 2 days.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 1000
            description: Limits the number of messages to return.
            default: 100
            title: Limit
          description: Limits the number of messages to return.
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            description: Offset for pagination.
            default: 0
            title: Offset
          description: Offset for pagination.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    MetricsResponse:
      properties:
        messages:
          items: {}
          type: array
          title: Messages
          description: List of messages.
          default: []
        total_count:
          type: integer
          title: Total Count
          description: Total number of messages.
        next_offset:
          type: integer
          title: Next Offset
          description: >-
            Offset for the next page. If there are no more messages to get, then
            this is not set.
      type: object
      required:
        - total_count
      title: MetricsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````