> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Refresh Metrics

> Manually trigger recalculation of system metrics from raw data. This operation analyzes system activity logs and regenerates aggregated metrics. Useful for ensuring metrics are up-to-date or after system maintenance. By default the refresh runs synchronously and returns the refreshed metrics. Pass background=true to run the refresh in the background instead: the endpoint returns 202 Accepted immediately and GET /metrics can be polled for results. If a background refresh is already in progress for the target database, returns status 'already_running' without starting a new one.



## OpenAPI

````yaml /reference-api/openapi.yaml post /metrics/refresh
openapi: 3.1.0
info:
  title: Agno API Reference
  description: The all-in-one, private, secure agent platform that runs in your cloud.
  version: 3.0.4
servers: []
security: []
paths:
  /metrics/refresh:
    post:
      tags:
        - Metrics
      summary: Refresh Metrics
      description: >-
        Manually trigger recalculation of system metrics from raw data. This
        operation analyzes system activity logs and regenerates aggregated
        metrics. Useful for ensuring metrics are up-to-date or after system
        maintenance. By default the refresh runs synchronously and returns the
        refreshed metrics. Pass background=true to run the refresh in the
        background instead: the endpoint returns 202 Accepted immediately and
        GET /metrics can be polled for results. If a background refresh is
        already in progress for the target database, returns status
        'already_running' without starting a new one.
      operationId: refresh_metrics
      parameters:
        - name: db_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Database ID to use for metrics calculation
            title: Db Id
          description: Database ID to use for metrics calculation
        - name: table
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Table to use for metrics calculation
            title: Table
          description: Table to use for metrics calculation
        - name: user_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Return only this user's metrics. Ignored for non-admin callers
            title: User Id
          description: Return only this user's metrics. Ignored for non-admin callers
        - name: background
          in: query
          required: false
          schema:
            type: boolean
            description: Run the refresh in the background and return 202 immediately
            default: false
            title: Background
          description: Run the refresh in the background and return 202 immediately
      responses:
        '200':
          description: Metrics refreshed successfully
          content:
            application/json:
              schema:
                anyOf:
                  - type: array
                    items:
                      $ref: '#/components/schemas/DayAggregatedMetrics'
                  - $ref: '#/components/schemas/MetricsRefreshResponse'
                title: Response Refresh Metrics
              example:
                - id: 2025-08-12_daily
                  agent_runs_count: 2
                  agent_sessions_count: 2
                  team_runs_count: 0
                  team_sessions_count: 0
                  workflow_runs_count: 0
                  workflow_sessions_count: 0
                  users_count: 1
                  token_metrics:
                    input_tokens: 256
                    output_tokens: 441
                    total_tokens: 697
                  model_metrics:
                    - model_id: gpt-5.5
                      model_provider: OpenAI
                      count: 2
                  date: '2025-08-12T00:00:00Z'
                  created_at: '2025-08-12T08:01:47Z'
                  updated_at: '2025-08-12T08:01:47Z'
        '202':
          description: Background refresh started
          content:
            application/json:
              example:
                status: started
                message: Metrics refresh started in background
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthenticatedResponse'
        '403':
          description: 'Insufficient permissions. Required scope(s): metrics:write'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '500':
          description: Failed to refresh metrics
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
      security:
        - {}
        - HTTPBearer: []
components:
  schemas:
    DayAggregatedMetrics:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier for the metrics record
        agent_runs_count:
          type: integer
          minimum: 0
          title: Agent Runs Count
          description: Total number of agent runs
        agent_sessions_count:
          type: integer
          minimum: 0
          title: Agent Sessions Count
          description: Total number of agent sessions
        team_runs_count:
          type: integer
          minimum: 0
          title: Team Runs Count
          description: Total number of team runs
        team_sessions_count:
          type: integer
          minimum: 0
          title: Team Sessions Count
          description: Total number of team sessions
        workflow_runs_count:
          type: integer
          minimum: 0
          title: Workflow Runs Count
          description: Total number of workflow runs
        workflow_sessions_count:
          type: integer
          minimum: 0
          title: Workflow Sessions Count
          description: Total number of workflow sessions
        users_count:
          type: integer
          minimum: 0
          title: Users Count
          description: Total number of unique users
        token_metrics:
          additionalProperties: true
          type: object
          title: Token Metrics
          description: Token usage metrics (input, output, cached, etc.)
        model_metrics:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Model Metrics
          description: Metrics grouped by model (model_id, provider, count)
        date:
          type: string
          format: date-time
          title: Date
          description: Date for which these metrics are aggregated
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when metrics were created
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Timestamp when metrics were last updated
      type: object
      required:
        - id
        - agent_runs_count
        - agent_sessions_count
        - team_runs_count
        - team_sessions_count
        - workflow_runs_count
        - workflow_sessions_count
        - users_count
        - token_metrics
        - model_metrics
        - date
        - created_at
        - updated_at
      title: DayAggregatedMetrics
      description: Aggregated metrics for a given day
    MetricsRefreshResponse:
      properties:
        status:
          type: string
          title: Status
          description: Status of the refresh request
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
          description: Additional details
      type: object
      required:
        - status
      title: MetricsRefreshResponse
    BadRequestResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: BadRequestResponse
      example:
        detail: Bad request
    UnauthenticatedResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: UnauthenticatedResponse
      example:
        detail: Unauthenticated access
    NotFoundResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: NotFoundResponse
      example:
        detail: Not found
    ValidationErrorResponse:
      properties:
        detail:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/ValidationErrorDetail'
              type: array
          title: Detail
          description: >-
            A single message for an explicitly raised 422, or a list of
            field-level errors for a request-validation failure
      type: object
      required:
        - detail
      title: ValidationErrorResponse
      description: >-
        422 body. Two runtime shapes share this status code, and the same
        endpoint can

        return either, so ``detail`` is typed as their union:


        - FastAPI's request-validation handler emits a **list** of field-level
        errors (built-in
          coercion errors and custom-validator ``ValueError``s alike).
        - A route that raises ``HTTPException(status_code=422, detail="...")``
        for a semantic
          check (e.g. an invalid cron expression) emits a **string** through the HTTPException
          handler.
      example:
        detail:
          - loc:
              - body
              - endpoint
            msg: Value error, Endpoint must be a path, not a full URL
            type: value_error
    InternalServerErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: InternalServerErrorResponse
      example:
        detail: Internal server error
    ValidationErrorDetail:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Loc
          description: Path to the offending field, e.g. ['body', 'endpoint']
        msg:
          type: string
          title: Msg
          description: Human-readable error message
        type:
          type: string
          title: Type
          description: Error type identifier, e.g. 'value_error' or 'missing'
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationErrorDetail
      description: >-
        One field-level error inside a 422 body, matching FastAPI's default
        shape.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

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