> ## 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 Billing History

> Unified billing history across personal + every workspace the caller
can see.

Query param ``workspace`` (optional):
  * absent / "" / "all"  — return personal rows + every org the user is
    owner/admin of, each tagged with ``organization_id`` (null on personal
    rows).
  * "personal"           — personal rows only.
  * <org-uuid>           — that org only; 403 if the user isn't an
    owner/admin of it.

Every row carries ``organization_id`` so the client can label/filter by
workspace without a second round-trip.

Sources merged per scope:
  * Stripe.Invoice.list on the caller's Stripe customer — surfaces
    personal top-ups + org top-ups the caller triggered (org cards live
    on the attacher's personal Stripe customer, with seacobra_org_id in
    metadata so we bucket them correctly).
  * Odoo monthly usage invoices, queried per scope (user_id or
    organization_id).
  * BalanceTransaction credit_grant / adjustment rows (local fallback for
    admin grants).



## OpenAPI

````yaml /openapi.json get /api/billing/history
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/billing/history:
    get:
      tags:
        - public
      summary: Get Billing History
      description: |-
        Unified billing history across personal + every workspace the caller
        can see.

        Query param ``workspace`` (optional):
          * absent / "" / "all"  — return personal rows + every org the user is
            owner/admin of, each tagged with ``organization_id`` (null on personal
            rows).
          * "personal"           — personal rows only.
          * <org-uuid>           — that org only; 403 if the user isn't an
            owner/admin of it.

        Every row carries ``organization_id`` so the client can label/filter by
        workspace without a second round-trip.

        Sources merged per scope:
          * Stripe.Invoice.list on the caller's Stripe customer — surfaces
            personal top-ups + org top-ups the caller triggered (org cards live
            on the attacher's personal Stripe customer, with seacobra_org_id in
            metadata so we bucket them correctly).
          * Odoo monthly usage invoices, queried per scope (user_id or
            organization_id).
          * BalanceTransaction credit_grant / adjustment rows (local fallback for
            admin grants).
      operationId: get_billing_history_api_billing_history_get
      parameters:
        - in: query
          name: workspace
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Workspace
        - in: query
          name: limit
          required: false
          schema:
            default: 50
            title: Limit
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/InvoiceHistoryItem'
                title: Response Get Billing History Api Billing History Get
                type: array
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - HTTPBearer: []
components:
  schemas:
    InvoiceHistoryItem:
      properties:
        amount:
          title: Amount
          type: number
        amount_due:
          default: 0
          title: Amount Due
          type: number
        billing_period:
          anyOf:
            - type: string
            - type: 'null'
          title: Billing Period
        date:
          title: Date
          type: string
        due_date:
          anyOf:
            - type: string
            - type: 'null'
          title: Due Date
        has_pdf:
          default: true
          title: Has Pdf
          type: boolean
        id:
          title: Id
          type: string
        invoice_type:
          title: Invoice Type
          type: string
        move_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Move Type
        organization_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Organization Id
        payable:
          default: false
          title: Payable
          type: boolean
        payment_state:
          anyOf:
            - type: string
            - type: 'null'
          title: Payment State
        portal_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Portal Url
        status:
          title: Status
          type: string
      required:
        - id
        - date
        - invoice_type
        - status
        - amount
      title: InvoiceHistoryItem
      type: object
    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

````