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

# Get answer stats

> How often customer messages led to a knowledge search, how many searches came back empty or failed, the most returned sources and live sources no search returned. Default range: the last 30 days. Playground conversations are left out.



## OpenAPI

````yaml /api-reference/openapi.json get /v1/agents/{agentId}/answer-stats
openapi: 3.0.0
info:
  title: Totebot Public API
  description: >-
    Manage your agents (settings, instructions, widget, skills, actions, MCP
    connections, integrations), their knowledge, test questions, the help desk,
    customers and your team from code, read conversations and analytics, and
    analyse which knowledge each answer used.


    Authenticate with a Bearer token: a team API key (`tb_live_…`, created by a
    team owner in Team settings → API keys) or a legacy per-agent key.

    New keys can only read. Write access is opt-in per area (`agents:write`,
    `plugins:write`, `knowledge:write`, `conversations:write`, `helpdesk:write`,
    `team:write`, `members:write`, `chat:write`, `customers:delete`,
    `quality:write`, `experiments:write`, `sales:write`). Provider cost in USD
    needs the opt-in `billing:read` scope. A key may also be limited to some
    agents.

    Routes that act on one agent take it from the `agentId` path parameter or,
    on the older `/v1/<resource>` routes, from the `X-Agent-Id` header.

    Write routes accept an `Idempotency-Key` header. Over the rate limit you get
    429 with `Retry-After`. Errors share one shape: `{ status: "error", error: {
    code, message, details } }`.

    Not available through the API, on purpose: billing and plan changes,
    deleting the team, creating or changing API keys, and OAuth connect flows.


    This spec is public at https://api.totebot.ai/v1/openapi.json (and .yaml).
  version: '2.0'
  contact: {}
servers:
  - url: https://api.totebot.ai
security: []
tags: []
paths:
  /v1/agents/{agentId}/answer-stats:
    get:
      tags:
        - Analysis
      summary: Get answer stats
      description: >-
        How often customer messages led to a knowledge search, how many searches
        came back empty or failed, the most returned sources and live sources no
        search returned. Default range: the last 30 days. Playground
        conversations are left out.
      operationId: PublicApiAnalysisController_answerStats
      parameters:
        - name: from
          required: false
          in: query
          description: Start date (ISO 8601)
          schema:
            format: date-time
            example: '2024-01-01T00:00:00.000Z'
            type: string
        - name: to
          required: false
          in: query
          description: End date (ISO 8601)
          schema:
            format: date-time
            example: '2024-12-31T23:59:59.999Z'
            type: string
        - name: agentId
          required: true
          in: path
          schema: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnswerStatsDto'
        '400':
          description: Invalid request, or rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '401':
          description: Missing, invalid, revoked or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '403':
          description: >-
            The plan lacks the feature, or the key lacks a scope
            (`error.details.missingScopes`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '404':
          description: Not found, or not an agent this key can access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
      security:
        - api-key: []
components:
  schemas:
    AnswerStatsDto:
      type: object
      properties:
        from:
          type: string
          format: date-time
        to:
          type: string
          format: date-time
        retentionDays:
          type: number
          description: >-
            Playground (PREVIEW) conversations are left out. Retrieval data is
            kept for this many days.
          example: 90
        retrievalDataAvailable:
          type: boolean
          description: >-
            False when the range starts before the retention cutoff and no
            retrieval events remain for it. Search-derived fields are then null,
            not 0.
        retrievalDataFrom:
          type: string
          nullable: true
          format: date-time
          description: >-
            Start of the period the search metrics cover: `from`, or the
            retention cutoff when `from` is older. Null when
            retrievalDataAvailable is false.
        retrievalNote:
          type: string
          nullable: true
          description: >-
            Explains how retention limits the search metrics for this range;
            null when it does not.
        turns:
          $ref: '#/components/schemas/TurnCountsDto'
        searches:
          nullable: true
          description: Null when retrievalDataAvailable is false.
          allOf:
            - $ref: '#/components/schemas/SearchCountsDto'
        topSources:
          description: Most returned sources, up to 20.
          type: array
          items:
            $ref: '#/components/schemas/SourceUsageDto'
        neverReturnedSources:
          nullable: true
          description: >-
            Live sources (not product-synced) that no search returned in the
            range, oldest first, up to 50. Null when retrievalDataAvailable is
            false.
          allOf:
            - $ref: '#/components/schemas/UnusedSourcesDto'
      required:
        - from
        - to
        - retentionDays
        - retrievalDataAvailable
        - retrievalDataFrom
        - retrievalNote
        - turns
        - searches
        - topSources
        - neverReturnedSources
    ApiErrorDto:
      type: object
      properties:
        status:
          type: string
          example: error
        error:
          $ref: '#/components/schemas/ApiErrorBodyDto'
        path:
          type: string
          example: /v1/agents/clx123
        timestamp:
          type: string
          example: '2026-11-24T10:00:00.000Z'
      required:
        - status
        - error
        - path
        - timestamp
    TurnCountsDto:
      type: object
      properties:
        customerMessages:
          type: number
        botReplies:
          type: number
        withRetrieval:
          type: number
          nullable: true
          description: >-
            Customer messages for which at least one knowledge search,
            pre-search or product search ran. Null when retrievalDataAvailable
            is false.
        withoutRetrieval:
          type: number
          nullable: true
          description: >-
            Customer messages since retrievalDataFrom without any search. Null
            when retrievalDataAvailable is false.
        retrievalShare:
          type: number
          nullable: true
          description: >-
            withRetrieval / customer messages since retrievalDataFrom. Null when
            there were none, or when retrievalDataAvailable is false.
      required:
        - customerMessages
        - botReplies
        - withRetrieval
        - withoutRetrieval
        - retrievalShare
    SearchCountsDto:
      type: object
      properties:
        total:
          type: number
        empty:
          type: number
        failed:
          type: number
        emptyShare:
          type: number
          nullable: true
        byOrigin:
          type: array
          items:
            $ref: '#/components/schemas/OriginCountsDto'
      required:
        - total
        - empty
        - failed
        - emptyShare
        - byOrigin
    SourceUsageDto:
      type: object
      properties:
        sourceId:
          type: string
        title:
          type: string
          nullable: true
        type:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/KnowledgeSourceType'
        timesReturned:
          type: number
          description: Searches that returned this source.
      required:
        - sourceId
        - title
        - type
        - timesReturned
    UnusedSourcesDto:
      type: object
      properties:
        total:
          type: number
        items:
          type: array
          items:
            $ref: '#/components/schemas/UnusedSourceDto'
      required:
        - total
        - items
    ApiErrorBodyDto:
      type: object
      properties:
        code:
          type: string
          example: NotFoundException
        message:
          type: string
          example: Agent not found
        details:
          type: object
          description: >-
            Extra fields, e.g. `missingScopes` on 403 or `secondsRemaining` on a
            training cooldown.
          additionalProperties: true
      required:
        - code
        - message
    OriginCountsDto:
      type: object
      properties:
        origin:
          allOf:
            - $ref: '#/components/schemas/RetrievalOrigin'
        searches:
          type: number
        empty:
          type: number
        failed:
          type: number
      required:
        - origin
        - searches
        - empty
        - failed
    KnowledgeSourceType:
      type: string
      enum:
        - DOC
        - QA
        - LINK
        - TEXT
        - SITEMAP
        - NOTION
    UnusedSourceDto:
      type: object
      properties:
        sourceId:
          type: string
        title:
          type: string
          nullable: true
        type:
          allOf:
            - $ref: '#/components/schemas/KnowledgeSourceType'
        createdAt:
          type: string
          format: date-time
      required:
        - sourceId
        - title
        - type
        - createdAt
    RetrievalOrigin:
      type: string
      enum:
        - TOOL
        - PREFETCH
        - PRODUCT_FINDER
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.