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

# Metered usage over a window



## OpenAPI

````yaml /api-reference/billing.json get /api/billing/usage
openapi: 3.1.0
info:
  title: truscan billing
  version: 1.0.0
  description: >-
    Credits, metering and top-ups. Money is counted in MICRO-DOLLARS (millionths
    of a dollar) as integers everywhere, so $7.00 per 1,000 requests is exactly
    7,000 micros per request. Floats drift, and a billing system that drifts
    gets disputed. Every amount is accompanied by a pre-formatted display string
    so no client reimplements money formatting. All responses use the {success,
    result, message} envelope except health and the webhook.
servers:
  - url: https://api.truscan.co
    description: Production
security: []
paths:
  /api/billing/usage:
    get:
      summary: Metered usage over a window
      parameters:
        - name: days
          in: query
          schema:
            type: integer
            default: 30
            maximum: 365
        - name: limit
          in: query
          schema:
            type: integer
            default: 100
            maximum: 500
      responses:
        '200':
          description: Usage report
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  result:
                    $ref: '#/components/schemas/UsageReport'
        '401':
          $ref: '#/components/responses/Failure'
components:
  schemas:
    UsageReport:
      type: object
      properties:
        since:
          type: string
          format: date-time
        total_micros:
          type: integer
        total_display:
          type: string
        by_operation:
          type: array
          items:
            type: object
            properties:
              operation:
                $ref: '#/components/schemas/Operation'
              units:
                type: integer
              cost_micros:
                type: integer
        entries:
          type: array
          items:
            $ref: '#/components/schemas/UsageEntry'
    Operation:
      type: string
      enum:
        - search
        - content
        - answer
    UsageEntry:
      type: object
      properties:
        id:
          type: integer
        operation:
          $ref: '#/components/schemas/Operation'
        tier:
          type: string
        units:
          type: integer
        extra_results:
          type: integer
        cost_micros:
          type: integer
        created_at:
          type: string
          format: date-time
    Failure:
      type: object
      properties:
        success:
          type: boolean
          const: false
        message:
          type: string
          description: Written for a person.
        result:
          type: object
          properties:
            code:
              type: string
              enum:
                - insufficient_credits
                - payments_unavailable
                - invalid_amount
                - unauthorized
                - validation_failed
                - internal_error
                - upstream_unavailable
  responses:
    Failure:
      description: >-
        The envelope with success false. result carries the machine-readable
        code and nothing else.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Failure'

````