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

# Get statistics

> Aggregated call metrics grouped by user or team, over processed recordings. `groupBy` is required. Optionally scope by date range, teams, emails, AI template, and tags. Unknown emails are returned in `errors[]` rather than failing the request.



## OpenAPI

````yaml /openapi.json get /v1/stats
openapi: 3.1.0
info:
  title: Sales Ask API
  version: 1.0.0
  description: >-
    Public API for integrating with Sales Ask. Authenticate every request using
    your organization API key in the x-api-key header. To generate an API key,
    call POST /organizations/:organizationId/api-key while authenticated as an
    organization admin.
servers:
  - url: https://integrations.salesask.com
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /v1/stats:
    get:
      tags:
        - Stats
      summary: Get statistics
      description: >-
        Aggregated call metrics grouped by user or team, over processed
        recordings. `groupBy` is required. Optionally scope by date range,
        teams, emails, AI template, and tags. Unknown emails are returned in
        `errors[]` rather than failing the request.
      operationId: getStats
      parameters:
        - name: groupBy
          in: query
          required: true
          schema:
            type: string
            enum:
              - user
              - team
          description: How to group the results. Required.
        - name: fromDate
          in: query
          schema:
            type: string
            format: date-time
          description: Include recordings created on or after this date (ISO 8601).
        - name: toDate
          in: query
          schema:
            type: string
            format: date-time
          description: >-
            Include recordings created on or before this date. YYYY-MM-DD is
            treated as through end of that UTC day.
        - name: teamIds
          in: query
          schema:
            type: string
          description: Comma-separated team IDs to restrict to. Discover via GET /v1/teams.
        - name: emails
          in: query
          schema:
            type: string
          description: >-
            Comma-separated user emails (case-insensitive). Intersected with
            teamIds when both are given. Unknown emails are reported in
            errors[].
        - name: aiTemplateId
          in: query
          schema:
            type: string
          description: Only include recordings using this AI template.
        - name: tagId
          in: query
          schema:
            type: string
          description: Legacy single-tag filter.
        - name: tags
          in: query
          schema:
            type: string
          description: Comma-separated tag IDs to include (OR semantics).
        - name: excludeTags
          in: query
          schema:
            type: string
          description: Comma-separated tag IDs to exclude.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  stats:
                    type: array
                    description: >-
                      One entry per group. Items are UserStat when groupBy=user,
                      TeamStat when groupBy=team.
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/UserStat'
                        - $ref: '#/components/schemas/TeamStat'
                  errors:
                    type: array
                    description: Non-fatal per-input errors (e.g. unknown emails).
                    items:
                      $ref: '#/components/schemas/StatsError'
        '400':
          description: Invalid request (e.g. groupBy missing/invalid, or invalid team ids)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    UserStat:
      allOf:
        - $ref: '#/components/schemas/Statistics'
        - type: object
          properties:
            email:
              type: string
              description: User email (identifies the group when groupBy=user).
            name:
              type: string
              nullable: true
              description: User display name.
    TeamStat:
      allOf:
        - $ref: '#/components/schemas/Statistics'
        - type: object
          properties:
            teamId:
              type: string
              description: Team id (identifies the group when groupBy=team).
            name:
              type: string
              nullable: true
              description: Team name.
    StatsError:
      type: object
      properties:
        type:
          type: string
          example: email_not_found
          description: Error kind, e.g. 'email_not_found'.
        value:
          type: string
          description: The offending input value that was dropped.
    Error:
      type: object
      properties:
        message:
          type: string
    Statistics:
      type: object
      description: >-
        Aggregated call metrics for a single group (user or team). Only
        processed recordings in range are counted.
      properties:
        totalRecordings:
          type: integer
          description: Number of processed recordings in this group.
        recordingsClosed:
          type: integer
          description: Recordings marked as a closed/won outcome.
        avgRecordingDuration:
          type: number
          description: Average recording duration (ms).
        avgTalkTime:
          type: number
          description: Average sales-rep talk time (ms).
        avgTalkRatio:
          type: number
          description: Average rep talk ratio (0-1).
        avgWaitedToTalkAvg:
          type: number
          description: Average time before the rep started talking (ms).
        avgTalkSpeed:
          type: number
          description: Average rep talk speed (words per minute).
        avgConversationSwitches:
          type: number
          description: Average number of speaker switches per recording.
        avgSwitchesPerMinute:
          type: number
          description: Average speaker switches per minute.
        avgQuestionsAsked:
          type: number
          description: Average questions asked by the rep.
        avgProcessScore:
          type: number
          description: Average sales-process adherence score.
        recordingsWithProcess:
          type: integer
          description: Recordings that had a process evaluation.
        recordingsWithCoaching:
          type: integer
          description: Recordings that produced coaching.
        recordingsWithActions:
          type: integer
          description: Recordings that produced action items.
        totalActionItems:
          type: integer
          description: Total action items across the group.
        reviewedCount:
          type: integer
          description: Recordings that were played back / reviewed.
        totalReviews:
          type: integer
          description: Total review/playback sessions.
        totalReviewMs:
          type: number
          description: Total review/playback time (ms).
        avgReviewMs:
          type: number
          description: Average review/playback time per reviewed recording (ms).
        recordingsByTag:
          type: object
          additionalProperties:
            type: integer
          description: Recording counts keyed by tag id.
        total:
          type: object
          description: Running totals used to derive the averages above.
        processQuestionBreakdown:
          type: array
          description: Per-question process adherence breakdown.
          items:
            type: object
            properties:
              questionId:
                type: string
                nullable: true
              question:
                type: string
              percentage:
                type: number
                description: Percent of recordings answering 'yes' (0-100).
              yesCount:
                type: integer
              totalCount:
                type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````