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

# Aggregate transactions

> Aggregate the org's debits for ``category``, grouped by ``group_by``.

Example: ``?category=vms&group_by=hardware_profile`` returns one row per
hardware profile with total spend + count. The set of valid ``group_by``
values depends on the category — invalid combinations return 400.



## OpenAPI

````yaml /api-reference/openapi.json get /api/v2/external/orgs/{slug}/transactions/aggregate
openapi: 3.1.0
info:
  title: Lyceum Cloud Execution API
  version: 0.1.0
servers: []
security: []
paths:
  /api/v2/external/orgs/{slug}/transactions/aggregate:
    get:
      tags:
        - Billing
      summary: Aggregate transactions
      description: |-
        Aggregate the org's debits for ``category``, grouped by ``group_by``.

        Example: ``?category=vms&group_by=hardware_profile`` returns one row per
        hardware profile with total spend + count. The set of valid ``group_by``
        values depends on the category — invalid combinations return 400.
      operationId: >-
        aggregate_org_transactions_api_v2_external_orgs__slug__transactions_aggregate_get
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            type: string
            title: Slug
        - name: category
          in: query
          required: true
          schema:
            $ref: '#/components/schemas/TransactionCategory'
        - name: group_by
          in: query
          required: true
          schema:
            type: string
            title: Group By
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgTransactionsAggregateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    TransactionCategory:
      type: string
      enum:
        - vms
        - executions
        - inference_prompt_tokens
        - inference_completion_tokens
        - serverless_inference_prompt_tokens
        - serverless_inference_completion_tokens
      title: TransactionCategory
      description: |-
        Public-facing transaction categories.

        Each value maps to a Croesus meter slug internally (see
        ``service.transaction_category_to_meter``). The indirection lets us
        rename or reshape Croesus meters without breaking the public API.
    OrgTransactionsAggregateResponse:
      properties:
        category:
          $ref: '#/components/schemas/TransactionCategory'
        aggregates:
          items:
            $ref: '#/components/schemas/OrgTransactionAggregate'
          type: array
          title: Aggregates
      type: object
      required:
        - category
        - aggregates
      title: OrgTransactionsAggregateResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    OrgTransactionAggregate:
      properties:
        group_by_value:
          type: string
          title: Group By Value
        count:
          type: integer
          title: Count
        total_amount:
          type: string
          title: Total Amount
          description: Decimal string. Do not cast to float.
        first_created_at:
          type: string
          format: date-time
          title: First Created At
        last_created_at:
          type: string
          format: date-time
          title: Last Created At
      type: object
      required:
        - group_by_value
        - count
        - total_amount
        - first_created_at
        - last_created_at
      title: OrgTransactionAggregate
      description: One group in an aggregate response — totals over a metadata key.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````