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

# What the credential's workspace used, from its Attempts' starts and finishes:
 summed per SKU over each window of the period and each `group_by` dimension, running work
 counted through now.

> cf. AWS Cost Explorer GetCostAndUsage (TimePeriod, Granularity, GroupBy, Filter); OpenMeter's
 meter query (from, to, windowSize, groupBy); AIP-136.



## OpenAPI

````yaml /http-api-reference/openapi.json post /outerproduct.usage.v1alpha.UsageService/QueryUsage
openapi: 3.1.0
info:
  title: OuterProduct Control Plane API
  description: >-
    Control-plane Connect RPCs over HTTP with ProtoJSON request and response
    bodies.
  version: v1alpha
servers:
  - url: https://api.outerproduct.com
security:
  - bearerAuth: []
tags:
  - name: ApiKey
    description: >-
      Manages the API keys of the session's workspace. Each key acts as its
      creator; every member
       lists them, and only their creator or the workspace owner revokes them.
       External sign-in is required; personal and execution tokens cannot manage keys.
  - name: Image
    description: >-
      The image registry: OCI distribution over its storage, whose formats are
      its own. The
       control plane serves it to users, admitting each only to their workspace's repository, and
       forwards to the OCI registry. Manifests and blobs are addressed by digest and never
       replaced; tags name manifests.
  - name: Run
    description: >-
      Submits and observes product Runs, their Calls, and the Calls' Attempts.
      Every Run
       owns one rooted Call tree.
  - name: Event
    description: >-
      What happened on the deployment, kept as an append-only log: each service
      records the events
       it declares, the cases of `payload`, from which usage is derived. An event is never changed.
       Only the deployment itself writes; a credential's holder reads its workspace's.
  - name: ImageBuilder
    description: >-
      Builds Images from image specs, and runs their install steps, each adding
      layers to its
       parent image, and package builds, each one pinned package's layer on its base, which
       install steps merge rather than install. The control plane serves `SubmitImageBuild`
       and `WaitImageBuild` to users, and forwards them to the scheduler's, which imports each
       image spec's base through the OCI registry, places each install step and package build on a
       node that builds, and tags the image it built in its workspace's repository. Those nodes
       serve the steps to the scheduler, by the scheduler's certificate, and run each in the
       sandbox the scheduler placed it in.
  - name: PaymentProcessor
    description: >-
      Where the credential's workspace pays: the payment processor's hosted
      pages. Credit is the only
       thing sold.
  - name: Policy
    description: >-
      Resource access policies evaluated by the application's Cedar authorizer.
      A policy belongs to
       the workspace of the credential that created it and governs only that workspace and what it
       owns; deployment-wide grants belong to the operator's policy.
  - name: Secret
  - name: Usage
    description: >-
      What a workspace has used and what it has left: its prepaid balance,
      topped up through the
       payment processor and spent by its usage.
  - name: User
    description: / User crud service
  - name: Volume
  - name: Workspace
    description: >-
      The workspace a request's credential is bound to, and its members. A
      session starts bound
       to its user's workspace and may switch to another the user belongs to; an API key stays bound
       to the workspace it was created in. Requests act in the bound workspace.
paths:
  /outerproduct.usage.v1alpha.UsageService/QueryUsage:
    post:
      tags:
        - Usage
      summary: >-
        What the credential's workspace used, from its Attempts' starts and
        finishes:
         summed per SKU over each window of the period and each `group_by` dimension, running work
         counted through now.
      description: >-
        cf. AWS Cost Explorer GetCostAndUsage (TimePeriod, Granularity, GroupBy,
        Filter); OpenMeter's
         meter query (from, to, windowSize, groupBy); AIP-136.
      operationId: outerproduct.usage.v1alpha.UsageService.QueryUsage
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          required: true
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/outerproduct.usage.v1alpha.QueryUsageRequest
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/outerproduct.usage.v1alpha.QueryUsageResponse
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
components:
  schemas:
    connect-protocol-version:
      type: number
      examples:
        - 1
      title: Connect-Protocol-Version
      description: Define the version of the Connect protocol
      const: 1
    connect-timeout-header:
      type: number
      examples:
        - 1000
      title: Connect-Timeout-Ms
      description: Define the timeout, in ms
    outerproduct.usage.v1alpha.QueryUsageRequest:
      type: object
      properties:
        startTime:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: start_time
          description: >-
            Usage that started at or after `start_time` and before `end_time`.
            Usage is cut at every
             hour, so a period of whole hours takes whole hours.
        endTime:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: end_time
        granularity:
          allOf:
            - $ref: '#/components/schemas/outerproduct.usage.v1alpha.Granularity'
          title: granularity
          description: >-
            The windows the period is cut into; unspecified sums the whole
            period as one.
        groupBy:
          type: array
          items:
            $ref: '#/components/schemas/outerproduct.usage.v1alpha.UsageDimension'
          title: group_by
          description: What each window's usage is further summed by, besides its SKU.
        filter:
          allOf:
            - $ref: '#/components/schemas/outerproduct.usage.v1alpha.UsageFilter'
          title: filter
          description: Only usage matching every set list.
      title: QueryUsageRequest
      additionalProperties: false
      description: >-
        cf. AWS Cost Explorer GetCostAndUsage (TimePeriod, Granularity, GroupBy,
        Filter).
    outerproduct.usage.v1alpha.QueryUsageResponse:
      type: object
      properties:
        usages:
          type: array
          items:
            $ref: '#/components/schemas/outerproduct.usage.v1alpha.Usage'
          title: usages
          description: By window, then SKU, then the grouped dimensions.
      title: QueryUsageResponse
      additionalProperties: false
      description: cf. AWS Cost Explorer GetCostAndUsage `ResultsByTime`.
    connect.error:
      type: object
      properties:
        code:
          type: string
          examples:
            - not_found
          enum:
            - canceled
            - unknown
            - invalid_argument
            - deadline_exceeded
            - not_found
            - already_exists
            - permission_denied
            - resource_exhausted
            - failed_precondition
            - aborted
            - out_of_range
            - unimplemented
            - internal
            - unavailable
            - data_loss
            - unauthenticated
          description: >-
            The status code, which should be an enum value of
            [google.rpc.Code][google.rpc.Code].
        message:
          type: string
          description: >-
            A developer-facing error message, which should be in English. Any
            user-facing error message should be localized and sent in the
            [google.rpc.Status.details][google.rpc.Status.details] field, or
            localized by the client.
        details:
          type: array
          items:
            $ref: '#/components/schemas/connect.error_details.Any'
          description: >-
            A list of messages that carry the error details. There is no limit
            on the number of messages.
      title: Connect Error
      additionalProperties: true
      description: >-
        Error type returned by Connect:
        https://connectrpc.com/docs/go/errors/#http-representation
    google.protobuf.Timestamp:
      type: string
      examples:
        - '2023-01-15T01:30:15.01Z'
        - '2024-12-25T12:00:00Z'
      format: date-time
      description: >-
        A point in time in RFC 3339 format, with up to nanosecond precision.
        Output uses UTC (`Z`); input may use an offset from UTC.
    outerproduct.usage.v1alpha.Granularity:
      type: string
      title: Granularity
      enum:
        - GRANULARITY_UNSPECIFIED
        - GRANULARITY_HOURLY
        - GRANULARITY_DAILY
        - GRANULARITY_MONTHLY
      description: |-
        Whole UTC hours, days or months.

         cf. AWS Cost Explorer `Granularity`; OpenMeter `windowSize`.
    outerproduct.usage.v1alpha.UsageDimension:
      type: string
      title: UsageDimension
      enum:
        - USAGE_DIMENSION_UNSPECIFIED
        - USAGE_DIMENSION_SUBJECT
        - USAGE_DIMENSION_PRINCIPAL
        - USAGE_DIMENSION_RESOURCE
      description: |-
        A fact of usage it may be summed by, besides its SKU and window.

         cf. AWS Cost Explorer `GroupBy` dimension keys; Cloud Billing's export columns.
    outerproduct.usage.v1alpha.UsageFilter:
      type: object
      properties:
        skus:
          type: array
          items:
            type: string
          title: skus
        subjects:
          type: array
          items:
            type: string
          title: subjects
        principals:
          type: array
          items:
            type: string
          title: principals
        resources:
          type: array
          items:
            type: string
          title: resources
      title: UsageFilter
      additionalProperties: false
      description: |-
        Each list matches any of its values; an empty list matches all.

         cf. AWS Cost Explorer `Expression.Dimensions`.
    outerproduct.usage.v1alpha.Usage:
      type: object
      properties:
        sku:
          type: string
          title: sku
        startTime:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: start_time
          description: The window, or the whole period, cut to the period asked for.
        endTime:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: end_time
        subject:
          type: string
          title: subject
          description: |-
            The Attempt, when grouped by it.

             cf. Cloud Billing's usage export `resource.name`.
        principal:
          type: string
          title: principal
          description: |-
            Whom it ran for, when grouped by it.

             cf. OTel `enduser.id`.
        quantity:
          type: string
          title: quantity
          format: int64
          description: In the SKU's unit.
        resource:
          type: string
          title: resource
          description: |-
            The Run, when grouped by it.

             cf. AWS Cost and Usage Report `lineItem/ResourceId`.
      title: Usage
      additionalProperties: false
      description: >-
        What the workspace used of one SKU in one window, summed over whatever
        is not grouped by.

         cf. Cloud Billing's usage export: `sku`, `usage_start_time`, `usage_end_time`, `usage.amount`.
    connect.error_details.Any:
      type: object
      properties:
        type:
          type: string
          description: >-
            A URL that acts as a globally unique identifier for the type of the
            serialized message. For example:
            `type.googleapis.com/google.rpc.ErrorInfo`.
        value:
          type: string
          format: binary
          description: >-
            The Protobuf message, serialized as bytes and base64-encoded. The
            specific message type is identified by the `type` field.
        debug:
          type: object
          title: Debug
          additionalProperties: true
          description: >-
            Deserialized error detail payload. The 'type' field indicates the
            schema. This field is for easier debugging and should not be relied
            upon for application logic.
      additionalProperties: true
      description: >-
        Contains an arbitrary serialized message along with a @type that
        describes the type of the serialized message, with an additional debug
        field for ConnectRPC error details.
  securitySchemes:
    bearerAuth:
      type: http
      description: A user session token or personal API key.
      scheme: bearer

````

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