# Get This Month's Usage

`GET /v1/billing/usage`

This month's usage per meter and GPU type: used, included, overage and
its dollars; the month's overage; every metered price (``gpu_hours`` per
GPU type); and what the organization stores now.

- Base URL: `https://api.qualia.dev`
- Authentication: an API key in the `X-API-Key` header, or `Authorization: Bearer …`

## Responses

- `200` Successful Response: `application/json` `BillingUsage`
- `401` Invalid or missing API key: `application/json` `ErrorResponse`
- `403` The key lacks credits:read or is restricted to workspaces: `application/json` `ErrorResponse`
- `404` Billing is off on this deployment: `application/json` `ErrorResponse`

## Schemas

```yaml
BillingUsage:
  properties:
    account_id:
      type: string
    period_start:
      type: string
      format: date
    period_end:
      type: string
      format: date
    meters:
      items:
        $ref: "#/components/schemas/UsageMeter"
      type: array
    overage_usd:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
    prices:
      items:
        $ref: "#/components/schemas/UsagePrice"
      type: array
    stored_gb:
      description: What the account stores now
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      type:
        - string
        - "null"
    credit_applied_usd:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      description: What the sign-up credit paid this month; overage_usd is after it
      default: "0"
    credit:
      description: The sign-up credit left, as on GET /v1/billing
      nullable: true
      allOf:
        - $ref: "#/components/schemas/BillingCredit"
  type: object
  required:
    - account_id
    - period_start
    - period_end
    - meters
    - overage_usd
    - prices
  title: BillingUsage
  description: This month's usage per meter, its overage and every metered price.
UsageMeter:
  properties:
    meter:
      type: string
    gpu_type:
      type: string
      default: ""
    unit:
      type: string
    used:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
    included:
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      type:
        - string
        - "null"
    overage:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
    billable_overage:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
    unit_price_usd:
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      type:
        - string
        - "null"
    overage_usd:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
    credit_quantity:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      description: Of billable_overage, what the sign-up credit paid; the invoice line leaves it out
      default: "0"
    carried_in:
      items:
        $ref: "#/components/schemas/UsageCarry"
      type: array
  type: object
  required:
    - meter
    - unit
    - used
    - included
    - overage
    - billable_overage
    - overage_usd
  title: UsageMeter
  description: One meter (and GPU type) this month. Hours, except storage (GB).
UsageCarry:
  properties:
    source_period:
      type: string
      format: date
    quantity:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
  type: object
  required:
    - source_period
    - quantity
  title: UsageCarry
UsagePrice:
  properties:
    meter:
      type: string
    gpu_type:
      type: string
      default: ""
    unit:
      type: string
    unit_price_usd:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
  type: object
  required:
    - meter
    - unit
    - unit_price_usd
  title: UsagePrice
  description: "One metered price: a GPU type's per GPU-hour, a check's per hour."
BillingCredit:
  properties:
    granted_usd:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      description: "What was granted: $20"
    remaining_usd:
      type: string
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      description: What is left now; above 0
    expires_at:
      type: string
      format: date-time
      description: Unused credit lapses then
  type: object
  required:
    - granted_usd
    - remaining_usd
    - expires_at
  title: BillingCredit
  description: |-
    A personal account's one-time $20 sign-up credit: paid usage at list
    price for 30 days, before any card overage.
ErrorResponse:
  properties:
    detail:
      type: string
      description: Error message describing what went wrong
  type: object
  required:
    - detail
  title: ErrorResponse
  description: Standard error response.
```
