Capy usage API

The usage API from Capy — 1 operation(s) for usage.

OpenAPI Specification

capy-usage-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Capy automations usage API
  version: 1.0.0
servers:
- url: https://capy.ai/api
security:
- bearerAuth: []
tags:
- name: usage
paths:
  /v1/usage:
    get:
      operationId: getUsage
      summary: Get usage
      description: Get organization usage totals, user breakdowns, and the paginated thread activity timeline shown in the usage dashboard. Monetary amounts are decimal US dollar numbers.
      tags:
      - usage
      security:
      - bearerAuth: []
      parameters:
      - name: orgId
        in: query
        required: true
        schema:
          type: string
          minLength: 1
      - name: from
        in: query
        required: true
        schema:
          type: string
          format: date-time
          pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
      - name: to
        in: query
        required: true
        schema:
          type: string
          format: date-time
          pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
      - name: routed
        in: query
        required: false
        schema:
          default: paid
          type: string
          enum:
          - paid
          - no_cost
          - oss
          - external_copilot
          - external_codex
          - external_byok
          - external_azure
          - external_unknown
          - external_xai
          - all
      - name: userId
        in: query
        required: false
        schema:
          type: string
          minLength: 1
      - name: projectIds
        in: query
        required: false
        schema:
          type: string
          description: Comma-separated project IDs to include.
      - name: agentType
        in: query
        required: false
        schema:
          type: string
          enum:
          - build
          - captain
          - review
          description: Filter usage to build, captain, or review activity.
      - name: sortBy
        in: query
        required: false
        schema:
          type: string
          enum:
          - lastActivity
          - cost
          - name
          - diff
          - owner
      - name: sortDirection
        in: query
        required: false
        schema:
          type: string
          enum:
          - asc
          - desc
      - name: page
        in: query
        required: false
        schema:
          default: 1
          type: integer
          minimum: 1
          maximum: 9007199254740991
      - name: pageSize
        in: query
        required: false
        schema:
          default: 20
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  responses:
    InternalError:
      description: Internal error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    UsageResponse:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        orgId:
          type: string
        from:
          type: string
        to:
          type: string
        currency:
          type: string
          const: USD
        routed:
          type: string
          enum:
          - paid
          - no_cost
          - oss
          - external_copilot
          - external_codex
          - external_byok
          - external_azure
          - external_unknown
          - external_xai
          - all
        totals:
          type: object
          properties:
            llmDollars:
              type: number
            vmDollars:
              type: number
            totalDollars:
              type: number
          required:
          - llmDollars
          - vmDollars
          - totalDollars
          additionalProperties: false
        users:
          type: array
          items:
            type: object
            properties:
              llmDollars:
                type: number
              vmDollars:
                type: number
              totalDollars:
                type: number
              userId:
                type: string
              userType:
                type: string
                enum:
                - human
                - service_user
              name:
                anyOf:
                - type: string
                - type: 'null'
              email:
                anyOf:
                - type: string
                - type: 'null'
              imageUrl:
                anyOf:
                - type: string
                - type: 'null'
              isServiceUser:
                type: boolean
            required:
            - llmDollars
            - vmDollars
            - totalDollars
            - userId
            - userType
            - name
            - email
            - imageUrl
            - isServiceUser
            additionalProperties: false
        items:
          type: array
          items:
            type: object
            properties:
              llmDollars:
                type: number
              vmDollars:
                type: number
              totalDollars:
                type: number
              jamId:
                type: string
              jamTitle:
                anyOf:
                - type: string
                - type: 'null'
              jamStatus:
                anyOf:
                - type: string
                - type: 'null'
              jamAgentType:
                anyOf:
                - type: string
                - type: 'null'
              jamProjectId:
                anyOf:
                - type: string
                - type: 'null'
              jamCreatedAt:
                anyOf:
                - type: string
                - type: 'null'
              jamUpdatedAt:
                anyOf:
                - type: string
                - type: 'null'
              userId:
                type: string
              userType:
                type: string
                enum:
                - human
                - service_user
              userName:
                anyOf:
                - type: string
                - type: 'null'
              userEmail:
                anyOf:
                - type: string
                - type: 'null'
              userImageUrl:
                anyOf:
                - type: string
                - type: 'null'
              isServiceUser:
                type: boolean
              taskId:
                anyOf:
                - type: string
                - type: 'null'
              taskProjectId:
                anyOf:
                - type: string
                - type: 'null'
              taskNumber:
                anyOf:
                - type: integer
                  minimum: -9007199254740991
                  maximum: 9007199254740991
                - type: 'null'
              taskTitle:
                anyOf:
                - type: string
                - type: 'null'
              lastActivityAt:
                type: string
              modelCount:
                type: integer
                minimum: -9007199254740991
                maximum: 9007199254740991
              diffSummaryByMode:
                anyOf:
                - type: object
                  properties:
                    uncommitted:
                      type: object
                      properties:
                        additions:
                          type: number
                        deletions:
                          type: number
                        hasChanges:
                          type: boolean
                        generatedAt:
                          type: string
                        baselineRef:
                          type: string
                        fileCount:
                          type: number
                        changedFiles:
                          type: array
                          items:
                            type: string
                      required:
                      - additions
                      - deletions
                      - hasChanges
                      - generatedAt
                      - baselineRef
                      additionalProperties: false
                    pr:
                      type: object
                      properties:
                        additions:
                          type: number
                        deletions:
                          type: number
                        hasChanges:
                          type: boolean
                        generatedAt:
                          type: string
                        baselineRef:
                          type: string
                        fileCount:
                          type: number
                        changedFiles:
                          type: array
                          items:
                            type: string
                      required:
                      - additions
                      - deletions
                      - hasChanges
                      - generatedAt
                      - baselineRef
                      additionalProperties: false
                    run:
                      type: object
                      properties:
                        additions:
                          type: number
                        deletions:
                          type: number
                        hasChanges:
                          type: boolean
                        generatedAt:
                          type: string
                        baselineRef:
                          type: string
                        fileCount:
                          type: number
                        changedFiles:
                          type: array
                          items:
                            type: string
                      required:
                      - additions
                      - deletions
                      - hasChanges
                      - generatedAt
                      - baselineRef
                      additionalProperties: false
                  additionalProperties: false
                - type: 'null'
              routedSource:
                type: string
                enum:
                - paid
                - no_cost
                - oss
                - external_copilot
                - external_codex
                - external_byok
                - external_azure
                - external_unknown
                - external_xai
              routedSpendDollars:
                anyOf:
                - type: object
                  propertyNames:
                    type: string
                    enum:
                    - paid
                    - no_cost
                    - oss
                    - external_copilot
                    - external_codex
                    - external_byok
                    - external_azure
                    - external_unknown
                    - external_xai
                  additionalProperties:
                    type: number
                - type: 'null'
            required:
            - llmDollars
            - vmDollars
            - totalDollars
            - jamId
            - jamTitle
            - jamStatus
            - jamAgentType
            - jamProjectId
            - jamCreatedAt
            - jamUpdatedAt
            - userId
            - userType
            - userName
            - userEmail
            - userImageUrl
            - isServiceUser
            - taskId
            - taskProjectId
            - taskNumber
            - taskTitle
            - lastActivityAt
            - modelCount
            - diffSummaryByMode
            - routedSource
            - routedSpendDollars
            additionalProperties: false
        total:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        page:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        pageSize:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        totalPages:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
      - orgId
      - from
      - to
      - currency
      - routed
      - totals
      - users
      - items
      - total
      - page
      - pageSize
      - totalPages
      additionalProperties: false
    ErrorResponse:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details: {}
          required:
          - code
          - message
          additionalProperties: false
      required:
      - error
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API token (capy_xxxx). Generate at capy.ai/settings/tokens