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

# Get usage

> Workspace usage for a range of UTC days (every role).

Totals, a daily series and a group-by table. Compute and storage are
sums of ledger lines (stored lines for rolled-up days, metered live
for the rest); AI spend and OOM kills come from the flight recorder
and are null/absent when it is not connected (`recorder`). Totals
equal the sum of the series, of the groups and of the CSV rows, and
`zode cost` prints these totals.



## OpenAPI

````yaml /api-reference/openapi.yaml get /v1/usage
openapi: 3.1.0
info:
  title: Zode API
  version: 0.1.0
  description: Sandboxes for coding agents. Every route takes an API key as a bearer token.
servers:
  - url: https://api.zode.dev
security:
  - bearerAuth: []
tags:
  - name: Sandboxes
  - name: Commands
  - name: Browser and desktop
  - name: Snapshots
  - name: Images
  - name: Environments
  - name: Flight recorder
  - name: Attestation
  - name: Agents
  - name: Proxying
  - name: Webhooks
  - name: OpenTelemetry
  - name: Alerts
  - name: CI
  - name: Usage and billing
  - name: Workspace
  - name: Platform
paths:
  /v1/usage:
    get:
      tags:
        - Usage and billing
      summary: Get usage
      description: |-
        Workspace usage for a range of UTC days (every role).

        Totals, a daily series and a group-by table. Compute and storage are
        sums of ledger lines (stored lines for rolled-up days, metered live
        for the rest); AI spend and OOM kills come from the flight recorder
        and are null/absent when it is not connected (`recorder`). Totals
        equal the sum of the series, of the groups and of the CSV rows, and
        `zode cost` prints these totals.
      operationId: getUsage
      parameters:
        - $ref: '#/components/parameters/UsageFrom'
        - $ref: '#/components/parameters/UsageTo'
        - $ref: '#/components/parameters/UsageGroupBy'
      responses:
        '200':
          description: Usage
          content:
            application/json:
              schema:
                type: object
                required:
                  - from
                  - to
                  - as_of
                  - group_by
                  - totals
                  - series
                  - groups
                  - ai_by_model
                  - ai_billed
                  - recorder
                  - price_versions
                properties:
                  from:
                    type: string
                    format: date
                  to:
                    type: string
                    format: date
                  as_of:
                    type: string
                    format: date-time
                    description: The range end, clipped to now.
                  group_by:
                    type: string
                    enum:
                      - repo
                      - branch
                      - pr
                      - member
                      - sandbox
                      - model
                  totals:
                    type: object
                    properties:
                      billable_micros:
                        type: integer
                        format: int64
                      compute_micros:
                        type: integer
                        format: int64
                      storage_micros:
                        type: integer
                        format: int64
                      static_ip_micros:
                        type: integer
                        format: int64
                      ai_micros:
                        type: integer
                        format: int64
                        description: Shown, not billed.
                      ai_calls:
                        type: integer
                        format: int64
                      sandbox_hours:
                        type: number
                      vcpu_hours:
                        type: number
                      peak_concurrent:
                        type: integer
                      forks:
                        type: integer
                      fork_p95_ms:
                        type:
                          - integer
                          - 'null'
                        format: int64
                        description: >-
                          Creating to running of forks in the range; null with
                          no samples.
                      fork_samples:
                        type: integer
                      oom_kills:
                        type:
                          - integer
                          - 'null'
                        format: int64
                        description: Null when the recorder is off or failed.
                      breaker_trips:
                        type: integer
                      caps_reached:
                        type: integer
                  series:
                    type: array
                    description: One entry per day of the range, zeros included.
                    items:
                      type: object
                      properties:
                        day:
                          type: string
                          format: date
                        billable_micros:
                          type: integer
                          format: int64
                        compute_micros:
                          type: integer
                          format: int64
                        storage_micros:
                          type: integer
                          format: int64
                        static_ip_micros:
                          type: integer
                          format: int64
                        ai_micros:
                          type: integer
                          format: int64
                        ai_calls:
                          type: integer
                          format: int64
                        sandbox_hours:
                          type: number
                        peak_concurrent:
                          type: integer
                        forks:
                          type: integer
                  groups:
                    type: array
                    description: >-
                      Most expensive first. Key "" is unattributed usage (no
                      repo, branch or PR; by model, compute and storage).
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                        label:
                          type: string
                        billable_micros:
                          type: integer
                          format: int64
                        compute_micros:
                          type: integer
                          format: int64
                        storage_micros:
                          type: integer
                          format: int64
                        static_ip_micros:
                          type: integer
                          format: int64
                        ai_micros:
                          type: integer
                          format: int64
                        ai_calls:
                          type: integer
                          format: int64
                        sandbox_hours:
                          type: number
                  ai_by_model:
                    type: array
                    items:
                      type: object
                      properties:
                        provider:
                          type: string
                        model:
                          type: string
                        calls:
                          type: integer
                          format: int64
                        cost_micros:
                          type: integer
                          format: int64
                  ai_billed:
                    type: boolean
                  recorder:
                    type: string
                    enum:
                      - 'on'
                      - 'off'
                      - error
                  price_versions:
                    type: array
                    items:
                      type: string
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Error'
components:
  parameters:
    UsageFrom:
      name: from
      in: query
      description: First UTC day (YYYY-MM-DD). Default 29 days before `to`.
      schema:
        type: string
        format: date
    UsageTo:
      name: to
      in: query
      description: >-
        Last UTC day, inclusive (YYYY-MM-DD). Default today. At most 92 days in
        all.
      schema:
        type: string
        format: date
    UsageGroupBy:
      name: group_by
      in: query
      schema:
        type: string
        enum:
          - repo
          - branch
          - pr
          - member
          - sandbox
          - model
        default: repo
  responses:
    Error:
      description: Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              examples:
                - not_found
                - rate_limited
                - plan_required
              description: |
                Stable machine code; branch on it rather than on `message`.
                Deliberately not a closed enum: new codes are added over time,
                so treat an unknown code by its HTTP status. The codes in use,
                by status (a few appear under two):

                - 400: `bad_request` (malformed JSON or unknown field),
                  `invalid_request`, `bad_signature`, `confirm_required`,
                  `default_environment`, `email_not_allowed`,
                  `endpoint_required`, `invalid_code`, `invalid_email`,
                  `invalid_image`, `invalid_name`, `invalid_nonce`,
                  `invalid_state`, `invalid_token`, `not_admin`,
                  `order_mismatch`, `org_required`, `owner_cannot_leave`,
                  `password_too_long`, `password_too_short`,
                  `personal_workspace`, `same_email`, `secret_unsupported`,
                  `self`, `too_many`, `unknown_channel`,
                  `unknown_environment`, `unknown_installation`,
                  `url_not_allowed`, `use_transfer`
                - 401: `unauthorized`, `invalid_credentials`, `bad_signature`
                - 402: `plan_required` (the plan does not include it),
                  `credit_exhausted` (no credit left and no card on file)
                - 403: `forbidden` (the role may not), `token_scope`, `csrf`,
                  `cors`, `email_unverified`, `installation_not_yours`,
                  `no_user`, `not_yours`, `subscriptions_off`,
                  `wrong_account`, `wrong_password`
                - 404: `not_found`, `code_not_found`, `invalid_invite`,
                  `not_configured`, `unknown_node`, `unknown_org`,
                  `unknown_sandbox`
                - 409: `invalid_state` (wrong sandbox status),
                  `concurrency_limit` (plan's running-sandbox cap),
                  `daily_cap_reached` (workspace daily spend cap),
                  `limit_reached`, `name_taken`, `node_full`, `not_running`,
                  `browser_off`, `desktop_off`, `already_deleted`,
                  `already_linked`, `already_member`, `already_on_plan`,
                  `billing_not_open`, `checkout_required`,
                  `code_not_applicable`, `code_redeemed`, `code_taken`,
                  `endpoint_disabled`, `installation_taken`,
                  `invite_pending`, `last_method`, `no_sandbox`,
                  `not_placed`, `not_waiting`, `sandboxes_running`,
                  `sole_owner`, `too_many_keys`, `trial_unavailable`,
                  `trial_used`
                - 410: `expired`, `used`, `expired_token`, `expired_invite`,
                  `code_expired`, `code_used_up`
                - 413: `too_large`
                - 415: `unsupported_media_type`
                - 429: `rate_limited` (see the RateLimited response),
                  `too_many_viewers` (desktop viewers)
                - 500: `internal`
                - 501 (this server or host cannot do it yet):
                  `feature_unavailable`, `attach_unavailable`,
                  `exec_unavailable`, `snapshots_unavailable`,
                  `images_unavailable`, `recorder_unavailable`,
                  `attestation_unavailable`
                - 502: `node_error`, `host_unreachable`, `key_destroy_failed`,
                  `provider_error`, `github_error`, `recorder_error`
                - 503: `no_capacity`, `unhealthy`, `alerts_unavailable`,
                  `auth_unavailable`, `ci_unavailable`, `email_unavailable`,
                  `ingest_unavailable`, `secrets_unavailable`,
                  `webhook_not_ready`

                The device-flow code and token endpoints answer 400 in the
                RFC 6749/8628 shape instead (OAuthError).
            message:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: zode_tok_<64 hex chars>
      description: >-
        An API key (`zode_tok_...`). Create one in the console under API keys
        (https://console.zode.dev/tokens), or with `zode login`.

````

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