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

# Per-agent usage for a period

> One row per non-private agent with what it delivered (key metric counts, and the average or total for measured metrics), how much it was used (triggers & chats, with a daily series) and what it cost (credits), each alongside the same figure for the period of equal length immediately before. The period is the last `days` days (default 30) or a fixed `startDate`–`endDate`. This is the data behind the Usage › Agent usage table in the portal, and what its JSON export contains.



## OpenAPI

````yaml /api-reference/workspace-api.json get /workspaceapi/agent-usage
openapi: 3.1.0
info:
  title: Abundly Workspace API
  description: >-
    Workspace-level and per-agent data and administration. GET endpoints need a
    workspace API key (wk_) with the Workspace read API scope; POST endpoints
    need the Workspace write API scope. The write endpoints are batch operations
    mirroring the Workspace Manager capability: ids travel in the JSON body,
    each id gets its own result, and per-id failures still return HTTP 200.


    Private agents are listed by /workspaceapi/agents but return 403 on every
    per-agent GET, so enumerate from /workspaceapi/agents?includeOverview=true
    rather than iterating agent ids. Write endpoints can target private agents.
  version: 1.0.0
servers:
  - url: https://service.abundly.ai
    description: Shared platform
  - url: https://{tenant}.service.abundly.ai
    description: Dedicated deployment
    variables:
      tenant:
        default: your-tenant
security:
  - workspaceApiKey: []
paths:
  /workspaceapi/agent-usage:
    get:
      summary: Per-agent usage for a period
      description: >-
        One row per non-private agent with what it delivered (key metric counts,
        and the average or total for measured metrics), how much it was used
        (triggers & chats, with a daily series) and what it cost (credits), each
        alongside the same figure for the period of equal length immediately
        before. The period is the last `days` days (default 30) or a fixed
        `startDate`–`endDate`. This is the data behind the Usage › Agent usage
        table in the portal, and what its JSON export contains.
      operationId: agent-usage
      parameters:
        - name: days
          in: query
          required: false
          description: >-
            Lookback in days ending at endDate. Default 30. Ignored when
            startDate is given.
          schema:
            type: integer
            minimum: 1
            maximum: 365
        - name: startDate
          in: query
          required: false
          description: ISO timestamp for a fixed period instead of a lookback.
          schema:
            type: string
        - name: endDate
          in: query
          required: false
          description: ISO timestamp. Default now.
          schema:
            type: string
      responses:
        '200':
          description: Success. Empty result sets are also 200.
          content:
            application/json:
              schema:
                description: >-
                  Per-agent usage for a period: what each agent delivered (key
                  metrics), how much it was used and what it cost. Private
                  agents are excluded.
                type: object
                properties:
                  period:
                    type: object
                    properties:
                      startDate:
                        description: ISO 8601 timestamp.
                        type: string
                      endDate:
                        description: ISO 8601 timestamp.
                        type: string
                      previousStartDate:
                        description: ISO 8601 timestamp.
                        type: string
                      previousEndDate:
                        description: ISO 8601 timestamp.
                        type: string
                    required:
                      - startDate
                      - endDate
                      - previousStartDate
                      - previousEndDate
                    additionalProperties: false
                  rows:
                    type: array
                    items:
                      description: >-
                        One agent in the period. Previous-period values are raw;
                        apply your own trend rule.
                      type: object
                      properties:
                        agentId:
                          type: string
                        name:
                          type: string
                        imageUrl:
                          type: string
                        teamId:
                          type: string
                        phase:
                          description: >-
                            "production" or "sandbox"; absent when the workspace
                            has lifecycle phases switched off.
                          type: string
                        criticality:
                          description: >-
                            critical, high, medium or low; absent when not
                            rated.
                          type: string
                        description:
                          type: string
                        valueStatement:
                          type: string
                        tags:
                          type: array
                          items:
                            type: string
                        adminUserIds:
                          description: 'Users with Admin access on the agent: its owners.'
                          type: array
                          items:
                            type: string
                        createdAt:
                          description: ISO 8601 timestamp.
                          type: string
                        keyMetrics:
                          type: array
                          items:
                            type: object
                            properties:
                              name:
                                type: string
                              measurement:
                                type: object
                                properties:
                                  unit:
                                    type: string
                                  aggregation:
                                    type: string
                                required:
                                  - unit
                                  - aggregation
                                additionalProperties: {}
                              count:
                                description: Records in the period.
                                type: number
                              previousCount:
                                description: >-
                                  Records in the period of equal length
                                  immediately before.
                                type: number
                              aggregate:
                                description: >-
                                  Average or total per the definition, measured
                                  metrics only.
                                type: number
                              previousAggregate:
                                type: number
                              valueCount:
                                type: number
                              daily:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    date:
                                      type: string
                                    count:
                                      type: number
                                    valueSum:
                                      type: number
                                  required:
                                    - date
                                    - count
                                    - valueSum
                                  additionalProperties: {}
                            required:
                              - name
                              - count
                              - previousCount
                              - valueCount
                              - daily
                            additionalProperties: {}
                        activity:
                          type: object
                          properties:
                            count:
                              description: Triggers & chats in the period.
                              type: number
                            previousCount:
                              type: number
                            daily:
                              description: One point per UTC day.
                              type: array
                              items:
                                type: object
                                properties:
                                  date:
                                    type: string
                                  count:
                                    type: number
                                required:
                                  - date
                                  - count
                                additionalProperties: {}
                          required:
                            - count
                            - previousCount
                            - daily
                          additionalProperties: {}
                        credits:
                          type: object
                          properties:
                            used:
                              description: >-
                                Credits consumed by LLM and tool usage in the
                                period.
                              type: number
                            previousUsed:
                              type: number
                          required:
                            - used
                            - previousUsed
                          additionalProperties: {}
                      required:
                        - agentId
                        - name
                        - adminUserIds
                        - keyMetrics
                        - activity
                        - credits
                      additionalProperties: {}
                required:
                  - period
                  - rows
                additionalProperties: false
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Error'
        '404':
          $ref: '#/components/responses/Error'
components:
  responses:
    Error:
      description: >-
        Error. Every failure on this API returns JSON with a single `error`
        field.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                description: >-
                  Human-readable message. Every error on this API uses this
                  shape.
                type: string
            required:
              - error
            additionalProperties: false
  securitySchemes:
    workspaceApiKey:
      type: http
      scheme: bearer
      description: >-
        Workspace API key (wk_). GET endpoints require the Workspace read API
        scope, POST endpoints the Workspace write API scope.

````