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

# Org Analytics — Costs

> Time-binned credits and USD spend across an org, grouped by product surface.



## OpenAPI

````yaml GET /orgs/{org_id}/analytics/costs
openapi: 3.1.0
info:
  title: Timbal Platform API
  description: Public API documentation for the Timbal platform
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.timbal.ai
    description: Production
  - url: https://api.dev.timbal.ai
    description: Development
security: []
tags:
  - name: ace
    description: Action Control Engine (ACE) operations
  - name: analytics
    description: Org and project analytics
  - name: billing
    description: Subscriptions, usage, and payment-related operations
  - name: content
    description: Re-sign stored content URLs
  - name: files
    description: File operations
  - name: iam
    description: IAM — actions, roles, users, and authorization introspection
  - name: k2
    description: Knowledge Bases v2 operations
  - name: orgs
    description: Organization operations
  - name: projects
    description: Project operations
  - name: runs
    description: Execution operations
  - name: templates
    description: Public project template catalog
  - name: users
    description: Authenticated user profile
paths:
  /orgs/{org_id}/analytics/costs:
    get:
      tags:
        - analytics
      description: >-
        Time-binned credits and USD spend across an org, grouped by product
        surface.
      operationId: handler
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: group_by
          in: query
          description: Bucket size for aggregation (`minute`, `hour`, or `day`).
          required: false
          schema:
            $ref: '#/components/schemas/BinSize'
        - name: from
          in: query
          description: >-
            Inclusive range start (epoch milliseconds). Defaults: 1h / 1d / 30d
            before `to` by `group_by`.
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int64
        - name: to
          in: query
          description: Exclusive range end (epoch milliseconds). Defaults to now.
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int64
        - name: user_id
          in: query
          description: Restrict to spend attributed to a specific user.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: project_id
          in: query
          description: >-
            Restrict to spend attributed to a single project. Omit for org-wide
            totals.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: resource_type
          in: query
          description: >-
            Restrict to one product surface (e.g. `composer`, `app_run`,
            `kb_query`,

            `kb_file_parsing`); `legacy` selects spend recorded before source

            attribution existed.
          required: false
          schema:
            type:
              - string
              - 'null'
      responses:
        '200':
          description: Costs analytics
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgAnalyticsCostsBody'
        '400':
          description: Bad request
        '403':
          description: Forbidden
        '500':
          description: Error
      security:
        - bearer_auth: []
components:
  schemas:
    BinSize:
      type: string
      enum:
        - minute
        - hour
        - day
    OrgAnalyticsCostsBody:
      type: object
      required:
        - group_by
        - from
        - to
        - bins
      properties:
        bins:
          type: array
          items:
            $ref: '#/components/schemas/SourceBin'
        from:
          type: integer
          format: int64
        group_by:
          $ref: '#/components/schemas/BinSize'
        to:
          type: integer
          format: int64
    SourceBin:
      type: object
      required:
        - interval_starts_at
        - interval_ends_at
        - sources
      properties:
        interval_ends_at:
          type: integer
          format: int64
        interval_starts_at:
          type: integer
          format: int64
        sources:
          type: array
          items:
            $ref: '#/components/schemas/SourceCosts'
    SourceCosts:
      type: object
      description: |-
        Spend for one product surface (`resource_type` on the credit ledger)
        within a bin, with the per-cost-type breakdown nested.
      required:
        - resource_type
        - credits
        - costs
      properties:
        costs:
          type: array
          items:
            $ref: '#/components/schemas/SourceCost'
        credits:
          type: number
          format: double
        resource_type:
          type: string
          description: |-
            Product surface that produced the spend (`app_run`, `composer`,
            `kb_query`, `kb_file_parsing`, `kb_file_embedding`, `transcription`,
            `message`, `ace_run`, `org_api_request`, `project_api_request`), or
            `legacy` for rows recorded before source attribution existed.
        usd:
          type:
            - number
            - 'null'
          format: double
          description: |-
            Dollar spend. `null` for credits-only surfaces (`composer`, `kb_*`),
            which are priced in credits.
    SourceCost:
      type: object
      description: |-
        One cost type's spend within a source group. Unlike [`Cost`], `usd` is
        nullable: credits-only surfaces never expose a dollar figure.
      required:
        - id
        - name
        - unit
        - credits
      properties:
        credits:
          type: number
          format: double
        id:
          type: integer
          format: int64
        name:
          type: string
        unit:
          type: string
          description: |-
            Metered unit (`tokens`, `seconds`, ...) for surfaces with a dollar
            price; `credits` for credits-only surfaces.
        usd:
          type:
            - number
            - 'null'
          format: double
          description: |-
            Dollar spend. `null` for credits-only surfaces (`composer`, `kb_*`),
            which are priced in credits.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: >-
        Timbal API key. Obtain your API key from the Timbal platform settings.
        See [Authentication](/api-reference/authentication) for more
        information.

````