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

# Aggregate Conversation Insights

> Aggregate conversation insights by specified fields



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/ai/analytics.yml get /ai/conversations/conversation-insights/aggregates
openapi: 3.1.0
info:
  title: Telnyx AI Conversations API
  version: 2.0.0
  description: AI conversation management, insights, and insight groups.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /ai/conversations/conversation-insights/aggregates:
    get:
      tags:
        - Conversations
      summary: Aggregate Conversation Insights
      description: Aggregate conversation insights by specified fields
      operationId: aggregate_conversation_insights
      parameters:
        - name: group_by
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            description: >-
              Fields to group by (can be comma-separated or multiple
              parameters). Prefix a field with 'metadata.' (e.g.
              'metadata.assistant_id') to group by the conversation's metadata
              instead of the insight result.


              Common fields used for over-time charts:

              - `score` — Group by the insight's score value (e.g. for Agent
              Instruction Following, User Satisfaction).

              - `metadata.assistant_id` — Group by the assistant that handled
              the conversation.

              - `metadata.assistant_version_id` — Group by the assistant
              version, useful for comparing performance across versions in the
              portal's 'Insights Over Time' chart.

              - `metadata.telnyx_conversation_channel` — Group by conversation
              channel (phone_call, web_chat, etc.).
            title: Group By
          description: >-
            Fields to group by (can be comma-separated or multiple parameters).
            Prefix a field with 'metadata.' (e.g. 'metadata.assistant_id') to
            group by the conversation's metadata instead of the insight result.


            Common fields used for over-time charts:

            - `score` — Group by the insight's score value (e.g. for Agent
            Instruction Following, User Satisfaction).

            - `metadata.assistant_id` — Group by the assistant that handled the
            conversation.

            - `metadata.assistant_version_id` — Group by the assistant version,
            useful for comparing performance across versions in the portal's
            'Insights Over Time' chart.

            - `metadata.telnyx_conversation_channel` — Group by conversation
            channel (phone_call, web_chat, etc.).
        - name: show
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            description: >-
              Fields to include in the result (can be comma-separated or
              multiple parameters). Supports the same 'metadata.<key>' prefix as
              group_by. Each returned row will contain the grouped field values
              plus a `record_count` indicating how many conversation insights
              match that combination.
            title: Show
          description: >-
            Fields to include in the result (can be comma-separated or multiple
            parameters). Supports the same 'metadata.<key>' prefix as group_by.
            Each returned row will contain the grouped field values plus a
            `record_count` indicating how many conversation insights match that
            combination.
        - name: insight_id
          in: query
          required: false
          schema:
            type: string
            format: uuid
            description: >-
              Optional insight ID to filter conversation insights. Only insights
              matching this ID will be included in the aggregation.
            title: Insight Id
          description: >-
            Optional insight ID to filter conversation insights. Only insights
            matching this ID will be included in the aggregation.
        - name: created_at
          in: query
          required: false
          schema:
            type: string
            description: >-
              Filter by creation datetime to scope the aggregation window.
              Supports range operators (e.g.,
              `created_at=gte.2025-01-01T00:00:00Z` for the start of the range,
              `created_at=lt.2025-01-02T00:00:00Z` for the end). To build
              per-day time series (as the portal does for the 'Insights Over
              Time' chart), issue one request per day bounded by
              `created_at=gte.<day_start>` and `created_at=lt.<next_day_start>`.
            title: Created At
          description: >-
            Filter by creation datetime to scope the aggregation window.
            Supports range operators (e.g.,
            `created_at=gte.2025-01-01T00:00:00Z` for the start of the range,
            `created_at=lt.2025-01-02T00:00:00Z` for the end). To build per-day
            time series (as the portal does for the 'Insights Over Time' chart),
            issue one request per day bounded by `created_at=gte.<day_start>`
            and `created_at=lt.<next_day_start>`.
        - name: metadata.assistant_id
          in: query
          required: false
          schema:
            type: string
            description: >-
              Filter by assistant ID (e.g.,
              `metadata.assistant_id=eq.<assistant_id>`). When provided, only
              conversation insights for the specified assistant are aggregated.
              Used by the portal to scope the 'Insights Over Time' chart to a
              single assistant.
            title: Metadata Assistant Id
          description: >-
            Filter by assistant ID (e.g.,
            `metadata.assistant_id=eq.<assistant_id>`). When provided, only
            conversation insights for the specified assistant are aggregated.
            Used by the portal to scope the 'Insights Over Time' chart to a
            single assistant.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationInsightAggregateResp'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            const response = await
            client.ai.conversations.conversationInsights.retrieveAggregates();


            console.log(response.data);
        - lang: Python
          source: >-
            import os

            from telnyx import Telnyx


            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )

            response =
            client.ai.conversations.conversation_insights.retrieve_aggregates()

            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.AI.Conversations.ConversationInsights.GetAggregates(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    ConversationInsightAggregateResp response = client.ai()conversations()conversationInsights()retrieveAggregates();
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            response =
            telnyx.ai.conversations.conversation_insights.retrieve_aggregates


            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->ai->conversations->conversationInsights->retrieveAggregates();

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:conversations:conversation-insights retrieve-aggregates \
              --api-key 'My API Key'
components:
  schemas:
    ConversationInsightAggregateResp:
      properties:
        data:
          items:
            additionalProperties: true
            type: object
            description: >-
              An aggregation row. Contains the grouped field values (keyed by
              the group_by field names) and a `record_count` integer. For
              example, when grouping by `score`, each row has a `score` value
              and a `record_count` of conversations with that score. When also
              splitting by `metadata.assistant_version_id`, each row includes
              both `score` and `metadata.assistant_version_id` plus their
              combined `record_count`.
            properties:
              record_count:
                type: integer
                description: >-
                  Number of conversation insights that match this combination of
                  grouped field values.
            required:
              - record_count
          type: array
          title: Data
          description: >-
            Aggregation result rows. Each row contains the grouped field values
            and a `record_count`.
      type: object
      required:
        - data
      title: ConversationInsightAggregateResp
      description: >-
        Aggregated conversation insight counts grouped by the specified fields.
        Each item in `data` contains the grouped field values and a
        `record_count` indicating how many conversation insights match that
        combination.
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    ValidationError:
      title: ValidationError
      required:
        - loc
        - msg
        - type
      type: object
      properties:
        loc:
          title: Location
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````