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

# Get Organization Usage

> Org-wide token usage, one row per Claude API call.

Returns every billed TokenUsage event attributable to this org —
covers tasks created by any member in any project the org owns.
Source-of-truth for org membership is Project.organization_id
(TokenUsage.organization_id is now populated on write but historical
rows may still be NULL, so we join through Project).

Per-event, not aggregated: each row's `id` is the TokenUsage UUID,
and once billed_cost_usd is set the row is immutable. Consumers
(rt_connector_codecobra) can convert each row to an analytic line
exactly once and never have to reconcile sums on re-imports —
reporting dashboards live elsewhere.

Skips rows whose billed_cost_usd is still NULL: those represent
Claude calls whose Odoo pricing webhook hasn't replied yet.
Returning them with cost=0 would force the customer to reconcile
later; better to surface them only once they're billable. The
next poll picks them up because billed_cost_usd's update bumps
updated_at, and updated_at drives the watermark.

Owner/admin only.



## OpenAPI

````yaml /openapi.json get /api/organizations/{org_id}/usage
openapi: 3.1.0
info:
  description: >-
    Public CodeCobra API. Authenticate by sending a personal API key in the
    `Authorization: Bearer <key>` header. Generate keys from Settings → API keys
    in the CodeCobra dashboard.
  title: CodeCobra Public API
  version: 1.0.0
servers: []
security: []
paths:
  /api/organizations/{org_id}/usage:
    get:
      tags:
        - public
      summary: Get Organization Usage
      description: |-
        Org-wide token usage, one row per Claude API call.

        Returns every billed TokenUsage event attributable to this org —
        covers tasks created by any member in any project the org owns.
        Source-of-truth for org membership is Project.organization_id
        (TokenUsage.organization_id is now populated on write but historical
        rows may still be NULL, so we join through Project).

        Per-event, not aggregated: each row's `id` is the TokenUsage UUID,
        and once billed_cost_usd is set the row is immutable. Consumers
        (rt_connector_codecobra) can convert each row to an analytic line
        exactly once and never have to reconcile sums on re-imports —
        reporting dashboards live elsewhere.

        Skips rows whose billed_cost_usd is still NULL: those represent
        Claude calls whose Odoo pricing webhook hasn't replied yet.
        Returning them with cost=0 would force the customer to reconcile
        later; better to surface them only once they're billable. The
        next poll picks them up because billed_cost_usd's update bumps
        updated_at, and updated_at drives the watermark.

        Owner/admin only.
      operationId: get_organization_usage_api_organizations__org_id__usage_get
      parameters:
        - in: path
          name: org_id
          required: true
          schema:
            format: uuid
            title: Org Id
            type: string
        - in: query
          name: days
          required: false
          schema:
            default: 30
            title: Days
            type: integer
        - in: query
          name: since
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Since
      responses:
        '200':
          content:
            application/json:
              schema: {}
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - HTTPBearer: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http

````