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

# Get Segment Analytics

> Get aggregated analytics for a specific segment including sentiment, safety metrics, topics, keywords, and an LLM-generated summary.

**Requires Growth+ plan or higher.**

Rate limited based on your plan's `maxAnalysesPerHour`. Cached results (less than 2 hours old) do not consume rate limit points.



## OpenAPI

````yaml https://www.greenflash.ai/api/openapi get /segments/{segmentId}/analytics
openapi: 3.1.0
info:
  title: Greenflash API Reference
  version: 1.0.0
  description: >-
    Greenflash endpoints for capturing interactions, managing prompts, and
    identifying users.
servers:
  - url: https://www.greenflash.ai/api/v1
    description: Greenflash API v1
security: []
tags:
  - name: Interactions
    description: Capture interactions between users and AI
  - name: Business Events
    description: Capture business events
  - name: Analytics
    description: Understand chat and agentic interactions analyses
  - name: Inbox
    description: Review flagged conversations
  - name: Segments
    description: Manage user segments
  - name: Prompts
    description: Manage prompts
  - name: Chat
    description: Stream chat and agentic conversations
  - name: Models
    description: Manage AI models
  - name: Products
    description: Manage products
  - name: Users
    description: Manage users
  - name: Organizations
    description: Manage organizations
paths:
  /segments/{segmentId}/analytics:
    get:
      tags:
        - Analytics
        - Segments
      summary: Get Segment Analytics
      description: >-
        Get aggregated analytics for a specific segment including sentiment,
        safety metrics, topics, keywords, and an LLM-generated summary.


        **Requires Growth+ plan or higher.**


        Rate limited based on your plan's `maxAnalysesPerHour`. Cached results
        (less than 2 hours old) do not consume rate limit points.
      parameters:
        - schema:
            type: string
            format: uuid
            description: The segment ID to get analytics for.
          required: true
          description: The segment ID to get analytics for.
          name: segmentId
          in: path
        - schema:
            type: string
            format: uuid
            description: Filter analytics by product ID.
          required: false
          description: Filter analytics by product ID.
          name: productId
          in: query
        - schema:
            type: string
            format: uuid
            description: Filter analytics by version ID.
          required: false
          description: Filter analytics by version ID.
          name: versionId
          in: query
      responses:
        '200':
          description: Segment analytics retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSegmentAnalyticsResponse'
              example:
                averageUserSentiment:
                  label: positive
                  score: 0.35
                averageChangeInUserSentiment:
                  label: stable
                  score: 0.02
                averageFrustration:
                  label: low
                  score: 0.15
                averageStruggle:
                  label: low
                  score: 0.12
                averageCommercialIntent:
                  label: high
                  score: 0.68
                averageConversationQualityIndex: 8.1
                averageConversationRating: 4.5
                topics:
                  - name: pricing plans
                    count: 120
                  - name: feature requests
                    count: 95
                  - name: integrations
                    count: 73
                topicGroups:
                  - name: Product & Pricing
                    count: 215
                  - name: Technical
                    count: 148
                keywords:
                  - name: enterprise
                    count: 89
                  - name: API
                    count: 76
                  - name: upgrade
                    count: 54
                summary:
                  overview: >-
                    Power users show strong engagement and positive sentiment.
                    Key interests are pricing plans and integrations.
                  recommendations:
                    - >-
                      Consider offering enterprise-tier API access to this
                      segment.
                    - >-
                      Feature request volume is high — prioritize integration
                      docs.
                hallucinationCount:
                  total: 3
                  percentage: 0.4
                jailbreakCount:
                  total: 0
                  percentage: 0
                userBiasCount:
                  total: 1
                  percentage: 0.1
                modelBiasCount:
                  total: 0
                  percentage: 0
                userToxicityCount:
                  total: 2
                  percentage: 0.3
                modelToxicityCount:
                  total: 0
                  percentage: 0
                totalConversations: 780
                participantCount: 234
        '403':
          description: Requires paid plan
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for get segment analytics operations.
              example:
                success: false
                error: This endpoint requires a Growth plan or higher
        '404':
          description: Segment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for get segment analytics operations.
              example:
                success: false
                error: Segment not found
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for get segment analytics operations.
              example:
                success: false
                error: >-
                  Rate limit exceeded for analytics requests. Please try again
                  later.
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for get segment analytics operations.
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Greenflash from 'greenflash';


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


            const getSegmentAnalyticsResponse = await
            client.segments.getSegmentAnalytics(
              '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
            );


            console.log(getSegmentAnalyticsResponse.averageChangeInUserSentiment);
        - lang: Python
          source: >-
            import os

            from greenflash import Greenflash


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

            get_segment_analytics_response =
            client.segments.get_segment_analytics(
                segment_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )

            print(get_segment_analytics_response.average_change_in_user_sentiment)
components:
  schemas:
    GetSegmentAnalyticsResponse:
      type: object
      properties:
        averageUserSentiment:
          type: object
          properties:
            label:
              type: string
            score:
              type: number
          required:
            - label
            - score
          description: Average sentiment across all conversations.
        averageChangeInUserSentiment:
          type: object
          properties:
            label:
              type: string
            score:
              type: number
          required:
            - label
            - score
          description: Average change in user sentiment.
        averageFrustration:
          type: object
          properties:
            score:
              type: number
            label:
              type: string
          required:
            - score
            - label
          description: Average frustration level.
        averageStruggle:
          type: object
          properties:
            score:
              type: number
            label:
              type: string
          required:
            - score
            - label
          description: Average struggle level.
        averageCommercialIntent:
          type: object
          properties:
            score:
              type: number
            label:
              type: string
          required:
            - score
            - label
          description: Average commercial intent.
        averageConversationQualityIndex:
          type:
            - number
            - 'null'
          description: Average conversation quality index.
        averageConversationRating:
          type:
            - number
            - 'null'
          description: Average conversation rating.
        topics:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              count:
                type: number
            required:
              - name
              - count
          description: Topics discussed across conversations.
        topicGroups:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              count:
                type: number
            required:
              - name
              - count
          description: Topic groups across conversations.
        keywords:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              count:
                type: number
            required:
              - name
              - count
          description: Keywords extracted from conversations.
        summary:
          type:
            - object
            - 'null'
          additionalProperties: {}
          description: LLM-generated summary of the segment.
        hallucinationCount:
          type: object
          properties:
            total:
              type: number
            percentage:
              type: number
          required:
            - total
            - percentage
          description: Number of hallucinations detected.
        jailbreakCount:
          type: object
          properties:
            total:
              type: number
            percentage:
              type: number
          required:
            - total
            - percentage
          description: Number of jailbreak attempts detected.
        userBiasCount:
          type: object
          properties:
            total:
              type: number
            percentage:
              type: number
          required:
            - total
            - percentage
          description: Number of user bias detections.
        modelBiasCount:
          type: object
          properties:
            total:
              type: number
            percentage:
              type: number
          required:
            - total
            - percentage
          description: Number of model bias detections.
        userToxicityCount:
          type: object
          properties:
            total:
              type: number
            percentage:
              type: number
          required:
            - total
            - percentage
          description: Number of user toxicity detections.
        modelToxicityCount:
          type: object
          properties:
            total:
              type: number
            percentage:
              type: number
          required:
            - total
            - percentage
          description: Number of model toxicity detections.
        totalConversations:
          type: number
          description: Total number of conversations in the segment.
        participantCount:
          type: number
          description: Total number of participants in the segment.
      required:
        - averageUserSentiment
        - averageChangeInUserSentiment
        - averageFrustration
        - averageStruggle
        - averageCommercialIntent
        - topics
        - topicGroups
        - keywords
        - summary
        - hallucinationCount
        - jailbreakCount
        - userBiasCount
        - modelBiasCount
        - userToxicityCount
        - modelToxicityCount
        - totalConversations
        - participantCount
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````