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

# Per-agent analytics

> Agent comparison analytics: run counts, success rate, total cost, average tokens over the range.



## OpenAPI

````yaml /api-reference/openapi.json get /api/metrics/analytics/agents
openapi: 3.1.0
info:
  title: Tedro API
  version: 1.0.0
  description: REST API for the Tedro communication operations platform.
servers:
  - url: https://api.tedro.io
    description: Production
security:
  - sessionCookie: []
    workspaceId: []
paths:
  /api/metrics/analytics/agents:
    get:
      tags:
        - Metrics
      summary: Per-agent analytics
      description: >-
        Agent comparison analytics: run counts, success rate, total cost,
        average tokens over the range.
      parameters:
        - schema:
            type: string
            enum:
              - 24h
              - 7d
              - 30d
              - custom
            description: Preset range. Use "custom" with from/to for explicit windows.
          required: false
          description: Preset range. Use "custom" with from/to for explicit windows.
          name: range
          in: query
        - schema:
            type: string
            description: ISO 8601 datetime (required when range=custom)
          required: false
          description: ISO 8601 datetime (required when range=custom)
          name: from
          in: query
        - schema:
            type: string
            description: ISO 8601 datetime (required when range=custom)
          required: false
          description: ISO 8601 datetime (required when range=custom)
          name: to
          in: query
      responses:
        '200':
          description: Agent analytics rows
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricsAgentsAnalyticsResponse'
        '400':
          description: Bad Request - invalid or missing parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: Unauthorized - missing or invalid session cookie
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - insufficient role (admin required)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - sessionCookie: []
          workspaceId: []
components:
  schemas:
    MetricsAgentsAnalyticsResponse:
      type: object
      properties:
        agents:
          type: array
          items:
            $ref: '#/components/schemas/AgentAnalyticsRow'
      required:
        - agents
      description: Per-agent run counts, success rate, and cost totals for the range
    ValidationErrorResponse:
      type: object
      properties:
        error:
          type: string
        details:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
            required:
              - path
              - message
      required:
        - error
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    AgentAnalyticsRow:
      type: object
      properties:
        agentId:
          type:
            - string
            - 'null'
          format: uuid
        name:
          type: string
        totalRuns:
          type: integer
        succeeded:
          type: integer
        failed:
          type: integer
        successRate:
          type: integer
        totalCost:
          type: number
        avgTokens:
          type: integer
      required:
        - agentId
        - name
        - totalRuns
        - succeeded
        - failed
        - successRate
        - totalCost
        - avgTokens
  securitySchemes:
    sessionCookie:
      type: apiKey
      in: cookie
      name: better-auth.session_token
      description: Session cookie set by Better Auth on sign-in.
    workspaceId:
      type: apiKey
      in: header
      name: x-workspace-id
      description: Workspace UUID. Required on all /api/* endpoints.

````