# Get the Plan

`GET /v1/billing`

The organization's plan this month, as Billing shows it: the plan, its
interval and status, whether a card is on file (``billable``), the spend
cap and whether paid work was refused, and the plan catalogue. ``card`` is
shown to owners only.

- 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` `BillingPlan`
- `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
BillingPlan:
  properties:
    account_id:
      type: string
    plan:
      type: string
      enum:
        - free
        - team
        - team5x
        - enterprise
    billing_interval:
      nullable: true
      type: string
      enum:
        - month
        - year
    plan_status:
      nullable: true
      type: string
      enum:
        - pending
        - active
        - past_due
        - canceled
    usage_status:
      nullable: true
      type: string
      enum:
        - pending
        - active
        - past_due
        - canceled
    allowance_plan:
      type: string
      enum:
        - free
        - team
        - team5x
        - enterprise
      description: Whose allowance applies this month
    billable:
      type: boolean
      description: "Usage over the allowance can be billed: a card is on file"
    spend_cap_usd:
      description: The month's cap on overage dollars; null is none
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      type:
        - string
        - "null"
    spend_cap_settable:
      type: boolean
    suspended:
      type: boolean
      description: New paid work was refused this month
    suspended_reason:
      description: needs_card, credit_used or spend_cap_reached
      type:
        - string
        - "null"
    period_start:
      type: string
      format: date
    period_end:
      type: string
      format: date
    cancel_at:
      format: date-time
      type:
        - string
        - "null"
    scheduled_change:
      nullable: true
      allOf:
        - $ref: "#/components/schemas/ScheduledPlanChange"
    plans:
      items:
        $ref: "#/components/schemas/PlanOffer"
      type: array
    card:
      description: Shown to the organization's owners only
      nullable: true
      allOf:
        - $ref: "#/components/schemas/BillingCard"
    credit:
      description: The sign-up credit left; null with none, once used and once expired
      nullable: true
      allOf:
        - $ref: "#/components/schemas/BillingCredit"
  type: object
  required:
    - account_id
    - plan
    - allowance_plan
    - billable
    - spend_cap_usd
    - spend_cap_settable
    - suspended
    - period_start
    - period_end
  title: BillingPlan
  description: The organization's plan this month.
ScheduledPlanChange:
  properties:
    plan:
      type: string
      enum:
        - team
        - team5x
    interval:
      type: string
      enum:
        - month
        - year
    at:
      type: string
      format: date-time
  type: object
  required:
    - plan
    - interval
    - at
  title: ScheduledPlanChange
  description: A downgrade or shorter interval that takes effect at the period end.
PlanOffer:
  properties:
    plan:
      type: string
      enum:
        - free
        - team
        - team5x
        - enterprise
    interval:
      description: None on Free and Enterprise
      nullable: true
      type: string
      enum:
        - month
        - year
    amount_usd:
      description: The price per interval; none on Free and Enterprise
      pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
      type:
        - string
        - "null"
    included:
      additionalProperties:
        pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
        type:
          - string
          - "null"
      type: object
      description: "Monthly allowance per meter: storage in GB, the rest hours"
  type: object
  required:
    - plan
    - included
  title: PlanOffer
  description: One plan of the catalogue and its monthly allowance.
BillingCard:
  properties:
    brand:
      type: string
    last4:
      type: string
    exp_month:
      type: integer
    exp_year:
      type: integer
  type: object
  required:
    - brand
    - last4
    - exp_month
    - exp_year
  title: BillingCard
  description: "The card on file: brand, last four digits and expiry."
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.
```
