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

# Get usage

> Returns metered usage and actual charges for a period, as totals and as a time series (hourly for `24h`, daily otherwise).

Requires the `billing:GetBillingUsage` permission.



## OpenAPI

````yaml /api-reference/openapi/billing.json get /billing/v1/usage
openapi: 3.0.3
info:
  title: Mount Thor Billing API
  version: 15089fd70390
  description: >-
    Read your billing account, funds, credits, prices, usage, costs and
    invoices. Amounts are exact: `units` whole currency units plus `nanos`
    billionths, never floating point.
servers:
  - url: https://customer-api.mountthor.com
security:
  - bearerAuth: []
paths:
  /billing/v1/usage:
    get:
      summary: Get usage
      description: >-
        Returns metered usage and actual charges for a period, as totals and as
        a time series (hourly for `24h`, daily otherwise).


        Requires the `billing:GetBillingUsage` permission.
      operationId: CustomerBillingService_GetBillingUsage
      parameters:
        - name: period
          in: query
          description: >-
            `24h`, `7d`, `month` (the current calendar month), or a past month
            as `YYYY-MM`.
          schema:
            type: string
          required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetBillingUsageResponse'
        '400':
          description: The request is invalid, for example an unknown query parameter.
          headers:
            mt-error-slug:
              description: A stable, machine-readable error identifier, when one applies.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            The credential is missing, invalid or expired. The response has no
            body.
          headers:
            mt-error-slug:
              description: A stable, machine-readable error identifier, when one applies.
              schema:
                type: string
        '403':
          description: >-
            The credential does not allow this operation. When a permission is
            missing, `requiredAction` names it; otherwise the body may be empty.
          headers:
            mt-error-slug:
              description: A stable, machine-readable error identifier, when one applies.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GetBillingUsageResponse:
      type: object
      properties:
        period_start:
          type: string
          description: >-
            Start of the period covered (inclusive). The period ends at
            `period_end`, never later than now.
          format: date-time
        period_end:
          type: string
          format: date-time
        requested:
          type: string
          description: >-
            The canonicalized requested period (`24h`, `7d`, `month`, or
            `YYYY-MM`).
        bucket:
          type: string
          description: 'Bucket grain of `buckets`: `hour` or `day`.'
        summary:
          type: array
          items:
            $ref: '#/components/schemas/UsageMeterTotal'
          description: Window totals per meter, meter-ordered.
        buckets:
          type: array
          items:
            $ref: '#/components/schemas/UsageBucket'
          description: >-
            The time series, oldest first. Buckets with no usage AND no spend
            are omitted.
        spend:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: >-
            Actual charges in the period: every paid compute window that started
            in it. A window's whole amount counts in the bucket where it
            started.
        spend_items:
          type: array
          items:
            $ref: '#/components/schemas/SpendLineItem'
          description: >-
            Window-level itemization of `spend`, ordered by (resource_kind,
            resource_class). The per-bucket breakdowns are on each
            `UsageBucket`.
        pending_holds:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: >-
            Funds set aside for compute windows that have started but are not
            final, across all time rather than just this period. They are
            already deducted from your available funds.
    Error:
      type: object
      properties:
        code:
          type: integer
          description: A numeric status code.
        message:
          type: string
          description: A human-readable explanation.
        reason:
          type: string
          description: On a 403 from a missing permission, `permission_denied`.
        requiredAction:
          type: string
          description: >-
            On a 403 from a missing permission, the permission the request
            needs.
    UsageMeterTotal:
      type: object
      properties:
        meter:
          type: string
        quantity:
          type: string
      description: Total quantity for one meter (e.g. `compute.vm.m4-24g.machine_seconds`).
    UsageBucket:
      type: object
      properties:
        start:
          type: string
          description: Inclusive start of the bucket (UTC hour or UTC day).
          format: date-time
        totals:
          type: array
          items:
            $ref: '#/components/schemas/UsageMeterTotal'
          description: Per-meter totals inside the bucket, meter-ordered.
        spend:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: >-
            Actual charges attributed to this bucket. See
            `GetBillingUsageResponse.spend` for the attribution rule.
        spend_items:
          type: array
          items:
            $ref: '#/components/schemas/SpendLineItem'
          description: >-
            What those charges were for, ordered by (resource_kind,
            resource_class).
      description: One time bucket of the usage series.
    Money:
      type: object
      properties:
        currency_code:
          type: string
          description: ISO-4217 currency code, e.g. "USD".
        units:
          type: string
          description: Whole units of the amount. May be negative.
        nanos:
          type: integer
          description: >-
            Fractional units in nanos (10^-9). For a positive amount, nanos is
            in [0, 999999999]; units and nanos must share sign.
          format: int32
      description: >-
        Money — an exact monetary amount. Never use floating point for money;
        this mirrors the google.type.Money shape (units + nanos + ISO-4217
        currency).
    SpendLineItem:
      type: object
      properties:
        resource_kind:
          type: string
          description: >-
            `host` — a paid physical-host lease window. Billing prices per
            machine CLASS, which prices both the VM-backed and bare-metal forms
            of that class, so a window carries no bm/vm dimension.
        resource_class:
          type: string
          description: >-
            The machine class charged, for example `m4-24g`. Empty for windows
            too old to attribute.
        windows:
          type: string
          description: Paid 24-hour windows aggregated into this line.
        machine_hours:
          type: string
          description: >-
            Billable machine-hours: the sum of the reserved quantities (24 per
            window).
        machines:
          type: string
          description: Distinct machines contributing to this line.
        unit_price:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: >-
            The effective price per machine-hour, `amount` divided by
            `machine_hours`. Shown for reference.
        amount:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: Sum of the original quoted amounts of the aggregated windows.
      description: >-
        Charges for one machine class. Compute is charged in 24-hour windows;
        `amount` is what was quoted when each window started.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <credential>` to
        https://customer-api.mountthor.com. People use the session that `mthr
        login` stores (a token starting `mt_session_`, valid for up to 12
        hours). Automation uses a service-account credential (starting
        `mt_sa_v1_`, valid for 90 days) from Create credential. Each operation
        names the permission it needs. Service accounts hold permissions through
        custom roles, and some operations refuse them; those operations say so.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.