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

> ## Agent Instructions
> Unkey is two separate products. Compute builds, deploys, and runs apps behind a gateway. API Management issues API keys, enforces rate limits, manages identities and permissions, and reports usage. Say which product a page belongs to; a reader can use either without the other.
> Every Unkey API endpoint is an HTTP POST to https://api.unkey.com/v2/{service}.{procedure} with a root key in the Authorization: Bearer header. Root keys are workspace scoped.
> Error codes have the form err:{system}:{category}:{specific} and each has a page at /errors/{system}/{category}/{specific}.
> The word environment means production or preview in Compute. Rate limiting has four meanings on this site; the glossary lists them.

# Get workspace usage

> Get the usage of your workspace for one calendar month (UTC): billable API
operations, compute usage per environment, and active keys per app.

Use this to track usage during the month or to look back at a past
month. The response has no prices. Your invoice is the source of truth.
Compute usage can be up to 15 minutes late, and it can change for up to 7
days.

Send `{}` for the current month to date, or
`{"period": {"year": 2026, "month": 9}}` for a full past month. The month
must start within the last 90 days.

**Required Permissions**

Your root key must have this permission:
- `unkey:v1:<workspace_id>:usage#read`




## OpenAPI

````yaml https://spec.speakeasy.com/unkey/unkey/openapi-json-with-code-samples post /v2/workspace.getUsage
openapi: 3.1.0
info:
  description: >-
    Unkey's API provides programmatic access for all resources within our
    platform.



    ### Authentication

    #

    This API accepts HTTP Bearer credentials. Public integrations use root keys.
    Dashboard-originated requests use a short-lived dashboard proxy JWT minted
    by the dashboard server. Most endpoints require permissions associated with
    the authenticated principal. When making public API requests, include your
    root key in the `Authorization` header:

    ```

    Authorization: Bearer unkey_xxxxxxxxxxx

    ```


    All responses follow a consistent envelope structure that separates
    operational metadata from actual data. This design provides several
    benefits:

    - Debugging: Every response includes a unique requestId for tracing issues

    - Consistency: Predictable response format across all endpoints

    - Extensibility: Easy to add new metadata without breaking existing
    integrations

    - Error Handling: Unified error format with actionable information


    ### Success Response Format:

    ```json

    {
      "meta": {
        "requestId": "req_123456"
      },
      "data": {
        // Actual response data here
      }
    }

    ```


    The meta object contains operational information:

    - `requestId`: Unique identifier for this request (essential for support)


    The data object contains the actual response data specific to each endpoint.


    ### Paginated Response Format:

    ```json

    {
      "meta": {
        "requestId": "req_123456"
      },
      "data": [
        // Array of results
      ],
      "pagination": {
        "cursor": "next_page_token",
        "hasMore": true
      }
    }

    ```


    The pagination object appears on list endpoints and contains:

    - `cursor`: Token for requesting the next page

    - `hasMore`: Whether more results are available


    ### Error Response Format:

    ```json

    {
      "meta": {
        "requestId": "req_2c9a0jf23l4k567"
      },
      "error": {
        "detail": "The resource you are attempting to modify is protected and cannot be changed",
        "status": 403,
        "title": "Forbidden",
        "type": "https://unkey.com/docs/errors/unkey/application/protected_resource"
      }
    }

    ```


    Error responses include comprehensive diagnostic information:

    - `title`: Human-readable error summary

    - `detail`: Specific description of what went wrong

    - `status`: HTTP status code

    - `type`: Link to error documentation

    - `errors`: Array of validation errors (for 400 responses)


    This structure ensures you always have the context needed to debug issues
    and take corrective action.
  title: Unkey API
  version: 2.0.0
servers:
  - url: https://api.unkey.com
security:
  - bearer: []
tags:
  - description: Analytics query operations
    name: analytics
  - description: API management operations
    name: apis
  - description: App management operations
    name: apps
  - description: Deployment operations
    name: deploy
  - description: Deployment operations
    name: deployments
  - description: Custom domain operations
    name: domains
  - description: Environment management operations
    name: environments
  - description: Identity management operations
    name: identities
  - description: API key management operations
    name: keys
  - description: Health check operations
    name: liveness
  - description: Log listing operations
    name: logs
  - description: Permission and role management operations
    name: permissions
  - description: Gateway policy operations
    name: gateway
  - description: Customer Portal session management
    name: portal
  - description: Rate limiting operations
    name: ratelimit
  - description: GitHub App installation operations
    name: github
  - description: Workspace limits and usage operations
    name: workspace
  - description: CLI device login
    name: cli
paths:
  /v2/workspace.getUsage:
    post:
      tags:
        - workspace
      summary: Get workspace usage
      description: >
        Get the usage of your workspace for one calendar month (UTC): billable
        API

        operations, compute usage per environment, and active keys per app.


        Use this to track usage during the month or to look back at a past

        month. The response has no prices. Your invoice is the source of truth.

        Compute usage can be up to 15 minutes late, and it can change for up to
        7

        days.


        Send `{}` for the current month to date, or

        `{"period": {"year": 2026, "month": 9}}` for a full past month. The
        month

        must start within the last 90 days.


        **Required Permissions**


        Your root key must have this permission:

        - `unkey:v1:<workspace_id>:usage#read`
      operationId: workspace.getUsage
      requestBody:
        content:
          application/json:
            examples:
              currentMonth:
                summary: Current month to date
                value: {}
              pastMonth:
                summary: A past month
                value:
                  period:
                    month: 9
                    year: 2026
            schema:
              $ref: '#/components/schemas/V2WorkspaceGetUsageRequestBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                currentMonth:
                  description: Usage so far this month, ending at the time of the request
                  summary: Current month to date
                  value:
                    data:
                      breakdowns:
                        byApp:
                          - app:
                              id: app_1234abcd
                              name: API
                            gateway:
                              activeKeys: 12
                            project:
                              id: proj_1234abcd
                              name: Payments
                        byEnvironment:
                          - app:
                              id: app_1234abcd
                              name: API
                            compute:
                              cpuSeconds: 5400.5
                              egressGiB: 1.4
                              memoryGiBHours: 96.2
                              storageGiBHours: 0
                            environment:
                              id: env_1234abcd
                              slug: production
                            project:
                              id: proj_1234abcd
                              name: Payments
                      period:
                        end: 1790946000000
                        start: 1790812800000
                      totals:
                        api:
                          ratelimits: 2000
                          verifications: 40000
                        compute:
                          cpuSeconds: 5400.5
                          egressGiB: 1.4
                          memoryGiBHours: 96.2
                          storageGiBHours: 0
                        gateway:
                          activeKeys: 12
                    meta:
                      requestId: req_1234abcd
                deletedApp:
                  description: >-
                    The app and its environment were deleted after they ran, so
                    their names are omitted. The last row has keys without an
                    app id
                  summary: Usage of a deleted app
                  value:
                    data:
                      breakdowns:
                        byApp:
                          - app:
                              id: app_5678efgh
                            gateway:
                              activeKeys: 3
                          - gateway:
                              activeKeys: 1
                        byEnvironment:
                          - app:
                              id: app_5678efgh
                            compute:
                              cpuSeconds: 900
                              egressGiB: 0.2
                              memoryGiBHours: 12.5
                              storageGiBHours: 0
                            environment:
                              id: env_5678efgh
                            project:
                              id: proj_1234abcd
                              name: Payments
                      period:
                        end: 1790812800000
                        start: 1788220800000
                      totals:
                        api:
                          ratelimits: 0
                          verifications: 0
                        compute:
                          cpuSeconds: 900
                          egressGiB: 0.2
                          memoryGiBHours: 12.5
                          storageGiBHours: 0
                        gateway:
                          activeKeys: 4
                    meta:
                      requestId: req_1234abcd
                emptyMonth:
                  description: >-
                    Nothing ran and no keys were verified, so totals are zero
                    and the lists are empty
                  summary: No usage
                  value:
                    data:
                      breakdowns:
                        byApp: []
                        byEnvironment: []
                      period:
                        end: 1790946000000
                        start: 1790812800000
                      totals:
                        api:
                          ratelimits: 0
                          verifications: 0
                        compute:
                          cpuSeconds: 0
                          egressGiB: 0
                          memoryGiBHours: 0
                          storageGiBHours: 0
                        gateway:
                          activeKeys: 0
                    meta:
                      requestId: req_1234abcd
                pastMonth:
                  description: The full month of September 2026
                  summary: A past month
                  value:
                    data:
                      breakdowns:
                        byApp:
                          - app:
                              id: app_1234abcd
                              name: API
                            gateway:
                              activeKeys: 30
                            project:
                              id: proj_1234abcd
                              name: Payments
                        byEnvironment:
                          - app:
                              id: app_1234abcd
                              name: API
                            compute:
                              cpuSeconds: 16200
                              egressGiB: 4.2
                              memoryGiBHours: 288.6
                              storageGiBHours: 0
                            environment:
                              id: env_1234abcd
                              slug: production
                            project:
                              id: proj_1234abcd
                              name: Payments
                      period:
                        end: 1790812800000
                        start: 1788220800000
                      totals:
                        api:
                          ratelimits: 8000
                          verifications: 120000
                        compute:
                          cpuSeconds: 16200
                          egressGiB: 4.2
                          memoryGiBHours: 288.6
                          storageGiBHours: 0
                        gateway:
                          activeKeys: 30
                    meta:
                      requestId: req_1234abcd
              schema:
                $ref: '#/components/schemas/V2WorkspaceGetUsageResponseBody'
          description: |
            The workspace usage for the requested month.
        '400':
          content:
            application/json:
              examples:
                futureMonth:
                  summary: Month in the future
                  value:
                    error:
                      detail: >-
                        'period' 2026-11 is in the future. The latest month is
                        2026-10.
                      status: 400
                      title: Bad Request
                      type: >-
                        https://unkey.com/docs/errors/unkey/application/invalid_input
                    meta:
                      requestId: req_1234abcd
                invalidMonth:
                  summary: Month out of range
                  value:
                    error:
                      detail: >-
                        POST request body for '/v2/workspace.getUsage' failed to
                        validate schema
                      errors:
                        - location: /properties/period/$ref/properties/month/maximum
                          message: 'maximum: got 13, want 12'
                      status: 400
                      title: Bad Request
                      type: >-
                        https://unkey.com/docs/errors/unkey/application/invalid_input
                    meta:
                      requestId: req_1234abcd
                monthTooOld:
                  summary: Month older than the compute usage retention
                  value:
                    error:
                      detail: >-
                        'period' 2026-07 starts more than 90 days ago. Compute
                        usage is kept for 90 days, so the earliest month is
                        2026-08.
                      status: 400
                      title: Bad Request
                      type: >-
                        https://unkey.com/docs/errors/unkey/application/invalid_input
                    meta:
                      requestId: req_1234abcd
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
          description: Bad request
        '401':
          content:
            application/json:
              examples:
                invalidRootKey:
                  summary: Invalid root key
                  value:
                    error:
                      detail: >-
                        The provided root key is invalid. We could not find the
                        requested key.
                      status: 401
                      title: Unauthorized
                      type: >-
                        https://unkey.com/docs/errors/unkey/authentication/key_not_found
                    meta:
                      requestId: req_1234abcd
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              examples:
                missingPermission:
                  summary: Missing required permission
                  value:
                    error:
                      detail: 'Missing permission: ''unkey:v1:ws_1234abcd:usage#read'''
                      status: 403
                      title: Insufficient Permissions
                      type: >-
                        https://unkey.com/docs/errors/unkey/authorization/insufficient_permissions
                    meta:
                      requestId: req_1234abcd
              schema:
                $ref: '#/components/schemas/ForbiddenErrorResponse'
          description: >-
            Forbidden - Insufficient permissions (requires
            `unkey:v1:<workspace_id>:usage#read`)
        '429':
          content:
            application/problem+json:
              examples:
                workspaceRateLimited:
                  summary: Workspace rate limit exceeded
                  value:
                    error:
                      detail: >-
                        This workspace has exceeded its API rate limit of
                        1000/1m0s. Please try again later.
                      status: 429
                      title: Too Many Requests
                      type: >-
                        https://unkey.com/docs/errors/user/too_many_requests/workspace_rate_limited
                    meta:
                      requestId: req_1234abcd
              schema:
                $ref: '#/components/schemas/TooManyRequestsErrorResponse'
          description: Too Many Requests
        '500':
          content:
            application/json:
              examples:
                usageUnavailable:
                  summary: Usage could not be read
                  value:
                    error:
                      detail: Failed to read the workspace's usage.
                      status: 500
                      title: Internal Server Error
                      type: >-
                        https://unkey.com/docs/errors/unkey/application/service_unavailable
                    meta:
                      requestId: req_1234abcd
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
          description: Internal server error
      security:
        - bearer: []
      x-codeSamples:
        - lang: go
          label: Go (SDK)
          source: "package main\n\nimport(\n\t\"context\"\n\t\"os\"\n\tunkey \"github.com/unkeyed/sdks/api/go/v3\"\n\t\"github.com/unkeyed/sdks/api/go/v3/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := unkey.New(\n        unkey.WithSecurity(os.Getenv(\"UNKEY_ROOT_KEY\")),\n    )\n\n    res, err := s.Workspace.GetUsage(ctx, components.V2WorkspaceGetUsageRequestBody{})\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.V2WorkspaceGetUsageResponseBody != nil {\n        // handle response\n    }\n}"
        - lang: python
          label: Python (SDK)
          source: |-
            from unkey.py import Unkey


            with Unkey(
                root_key="<YOUR_BEARER_TOKEN_HERE>",
            ) as unkey:

                res = unkey.workspace.get_usage(period={
                    "year": 2026,
                    "month": 9,
                })

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Unkey } from "@unkey/api";

            const unkey = new Unkey({
              rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
            });

            async function run() {
              const result = await unkey.workspace.getUsage({});

              console.log(result);
            }

            run();
components:
  schemas:
    V2WorkspaceGetUsageRequestBody:
      type: object
      properties:
        period:
          $ref: '#/components/schemas/V2WorkspaceGetUsageRequestPeriod'
      additionalProperties: false
    V2WorkspaceGetUsageResponseBody:
      type: object
      required:
        - meta
        - data
      properties:
        meta:
          $ref: '#/components/schemas/Meta'
        data:
          $ref: '#/components/schemas/V2WorkspaceGetUsageResponseData'
      additionalProperties: false
    BadRequestErrorResponse:
      type: object
      required:
        - meta
        - error
      properties:
        meta:
          $ref: '#/components/schemas/Meta'
        error:
          $ref: '#/components/schemas/BadRequestErrorDetails'
      description: >-
        Error response for invalid requests that cannot be processed due to
        client-side errors. This typically occurs when request parameters are
        missing, malformed, or fail validation rules. The response includes
        detailed information about the specific errors in the request, including
        the location of each error and suggestions for fixing it. When receiving
        this error, check the 'errors' array in the response for specific
        validation issues that need to be addressed before retrying.
    UnauthorizedErrorResponse:
      type: object
      required:
        - meta
        - error
      properties:
        meta:
          $ref: '#/components/schemas/Meta'
        error:
          $ref: '#/components/schemas/BaseError'
      description: >-
        Error response when authentication has failed or credentials are
        missing. This occurs when:

        - No authentication token is provided in the request

        - The provided token is invalid, expired, or malformed

        - The token format doesn't match expected patterns


        To resolve this error, ensure you're including a valid root key in the
        Authorization header.
    ForbiddenErrorResponse:
      type: object
      required:
        - meta
        - error
      properties:
        meta:
          $ref: '#/components/schemas/Meta'
        error:
          $ref: '#/components/schemas/BaseError'
      description: >-
        Error response when the provided credentials are valid but lack
        sufficient permissions for the requested operation. This occurs when:

        - The root key doesn't have the required permissions for this endpoint

        - The operation requires elevated privileges that the current key lacks

        - Access to the requested resource is restricted based on workspace
        settings


        To resolve this error, ensure your root key has the necessary
        permissions or contact your workspace administrator.
    TooManyRequestsErrorResponse:
      type: object
      required:
        - meta
        - error
      properties:
        meta:
          $ref: '#/components/schemas/Meta'
        error:
          $ref: '#/components/schemas/BaseError'
      description: >-
        Error response when the client has sent too many requests in a given
        time period. This occurs when you've exceeded a rate limit or quota for
        the resource you're accessing.


        The rate limit resets automatically after the time window expires. To
        avoid this error:

        - Implement exponential backoff when retrying requests

        - Cache results where appropriate to reduce request frequency

        - Check the error detail message for specific quota information

        - Contact support if you need a higher quota for your use case
    InternalServerErrorResponse:
      type: object
      required:
        - meta
        - error
      properties:
        meta:
          $ref: '#/components/schemas/Meta'
        error:
          $ref: '#/components/schemas/BaseError'
      description: >-
        Error response when an unexpected error occurs on the server. This
        indicates a problem with Unkey's systems rather than your request.


        When you encounter this error:

        - The request ID in the response can help Unkey support investigate the
        issue

        - The error is likely temporary and retrying may succeed

        - If the error persists, contact Unkey support with the request ID
    V2WorkspaceGetUsageRequestPeriod:
      type: object
      description: >
        The calendar month (UTC) to read. Omit it for the current month to date.
        A

        past month returns the full month. It cannot be in the future, and it
        must

        start within the last 90 days, because compute usage is kept for 90
        days.
      required:
        - year
        - month
      properties:
        year:
          type: integer
          description: The year, for example 2026.
          example: 2026
        month:
          type: integer
          minimum: 1
          maximum: 12
          description: The month, from 1 (January) to 12 (December).
          example: 9
      additionalProperties: false
    Meta:
      type: object
      required:
        - requestId
      properties:
        requestId:
          description: >-
            A unique id for this request. Always include this ID when contacting
            support about a specific API request. This identifier allows Unkey's
            support team to trace the exact request through logs and diagnostic
            systems to provide faster assistance.
          example: req_123
          type: string
      additionalProperties: false
      description: >-
        Metadata object included in every API response. This provides context
        about the request and is essential for debugging, audit trails, and
        support inquiries. The `requestId` is particularly important when
        troubleshooting issues with the Unkey support team.
    V2WorkspaceGetUsageResponseData:
      type: object
      required:
        - period
        - totals
        - breakdowns
      properties:
        period:
          $ref: '#/components/schemas/V2WorkspaceGetUsagePeriod'
        totals:
          $ref: '#/components/schemas/V2WorkspaceGetUsageTotals'
        breakdowns:
          $ref: '#/components/schemas/V2WorkspaceGetUsageBreakdowns'
      additionalProperties: false
    BadRequestErrorDetails:
      allOf:
        - $ref: '#/components/schemas/BaseError'
        - type: object
          properties:
            errors:
              description: >-
                List of individual validation errors that occurred in the
                request. Each error provides specific details about what failed
                validation, where the error occurred in the request, and
                suggestions for fixing it. This granular information helps
                developers quickly identify and resolve multiple issues in a
                single request without having to make repeated API calls.
              items:
                $ref: '#/components/schemas/ValidationError'
              type: array
          required:
            - errors
      description: >-
        Extended error details specifically for bad request (400) errors. This
        builds on the BaseError structure by adding an array of individual
        validation errors, making it easy to identify and fix multiple issues at
        once.
    BaseError:
      properties:
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem. This provides detailed information about what went wrong
            and potential remediation steps. The message is intended to be
            helpful for developers troubleshooting the issue.
          example: Property foo is required but is missing.
          type: string
        status:
          description: >-
            HTTP status code that corresponds to this error. This will match the
            status code in the HTTP response. Common codes include `400` (Bad
            Request), `401` (Unauthorized), `403` (Forbidden), `404` (Not
            Found), `409` (Conflict), and `500` (Internal Server Error).
          example: 404
          format: int
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This remains
            constant from occurrence to occurrence of the same problem and
            should be used for programmatic handling.
          example: Not Found
          type: string
        type:
          description: >-
            A URI reference that identifies the problem type. This provides a
            stable identifier for the error that can be used for documentation
            lookups and programmatic error handling. When followed, this URI
            should provide human-readable documentation for the problem type.
          example: https://unkey.com/docs/errors/unkey/resource/not_found
          type: string
      required:
        - title
        - detail
        - status
        - type
      type: object
      additionalProperties: false
      description: >-
        Base error structure following Problem Details for HTTP APIs (RFC 7807).
        This provides a standardized way to carry machine-readable details of
        errors in HTTP response content.
    V2WorkspaceGetUsagePeriod:
      type: object
      description: The time window the usage covers.
      required:
        - start
        - end
      properties:
        start:
          type: integer
          format: int64
          description: >-
            Unix timestamp in milliseconds of the first day of the month, 00:00
            UTC.
          example: 1790812800000
        end:
          type: integer
          format: int64
          description: >
            Unix timestamp in milliseconds of the end of the period, exclusive.
            For

            the current month it is the time of the request. For a past month it
            is

            the start of the next month.
          example: 1790946000000
      additionalProperties: false
    V2WorkspaceGetUsageTotals:
      type: object
      description: |
        Workspace totals in the period. `compute` is the sum of
        `breakdowns.byEnvironment[].compute`. `gateway.activeKeys` is the sum of
        `breakdowns.byApp[].gateway.activeKeys`.
      required:
        - api
        - compute
        - gateway
      properties:
        api:
          $ref: '#/components/schemas/V2WorkspaceGetUsageApi'
        compute:
          $ref: '#/components/schemas/V2WorkspaceGetUsageCompute'
        gateway:
          $ref: '#/components/schemas/V2WorkspaceGetUsageGateway'
      additionalProperties: false
    V2WorkspaceGetUsageBreakdowns:
      type: object
      description: The totals split by environment and by app.
      required:
        - byEnvironment
        - byApp
      properties:
        byEnvironment:
          type: array
          description: |
            One row per environment with compute usage in the period, most
            `compute.cpuSeconds` first, then by project id and environment id.
            Empty when nothing ran.
          items:
            $ref: '#/components/schemas/V2WorkspaceGetUsageByEnvironmentRow'
        byApp:
          type: array
          description: >
            One row per app whose gateway verified keys in the period, and one
            row

            without `app` for keys that have no app id. Most
            `gateway.activeKeys`

            first, then by app id. Empty when no keys were verified.
          items:
            $ref: '#/components/schemas/V2WorkspaceGetUsageByAppRow'
      additionalProperties: false
    ValidationError:
      additionalProperties: false
      properties:
        location:
          description: >-
            JSON path indicating exactly where in the request the error
            occurred. This helps pinpoint the problematic field or parameter.
            Examples include:

            - 'body.name' (field in request body)

            - 'body.items[3].tags' (nested array element)

            - 'path.apiId' (path parameter)

            - 'query.limit' (query parameter)

            Use this location to identify exactly which part of your request
            needs correction.
          type: string
          example: body.permissions[0].name
        message:
          description: >-
            Detailed error message explaining what validation rule was violated.
            This provides specific information about why the field or parameter
            was rejected, such as format errors, invalid values, or constraint
            violations.
          type: string
          example: Must be at least 3 characters long
        fix:
          description: >-
            A human-readable suggestion describing how to fix the error. This
            provides practical guidance on what changes would satisfy the
            validation requirements. Not all validation errors include fix
            suggestions, but when present, they offer specific remediation
            advice.
          type: string
          example: >-
            Ensure the name uses only alphanumeric characters, underscores, and
            hyphens
      required:
        - location
        - message
      type: object
      description: >-
        Individual validation error details. Each validation error provides
        precise information about what failed, where it failed, and how to fix
        it, enabling efficient error resolution.
    V2WorkspaceGetUsageApi:
      type: object
      description: >
        Billable operations through the Unkey API in the period. Key
        verifications

        through the Unkey gateway are not counted here. The gateway bills by
        active

        keys, see `gateway`.
      required:
        - verifications
        - ratelimits
      properties:
        verifications:
          type: integer
          format: int64
          description: Billable key verifications.
          example: 40000
        ratelimits:
          type: integer
          format: int64
          description: Billable rate limit operations.
          example: 2000
      additionalProperties: false
    V2WorkspaceGetUsageCompute:
      type: object
      description: Compute usage in the period.
      required:
        - cpuSeconds
        - memoryGiBHours
        - storageGiBHours
        - egressGiB
      properties:
        cpuSeconds:
          type: number
          format: double
          description: CPU time used, in seconds.
          example: 5400.5
        memoryGiBHours:
          type: number
          format: double
          description: Memory used over time, in GiB-hours.
          example: 96.2
        storageGiBHours:
          type: number
          format: double
          description: Ephemeral disk reserved over time, in GiB-hours.
          example: 0
        egressGiB:
          type: number
          format: double
          description: Public network egress, in GiB.
          example: 1.4
      additionalProperties: false
    V2WorkspaceGetUsageGateway:
      type: object
      description: Unkey gateway usage in the period.
      required:
        - activeKeys
      properties:
        activeKeys:
          type: integer
          format: int64
          description: >
            Distinct keys verified through the Unkey gateway. A key verified
            through

            several apps counts once, for the app that verified it most.
          example: 12
      additionalProperties: false
    V2WorkspaceGetUsageByEnvironmentRow:
      type: object
      description: Compute one environment used in the period.
      required:
        - project
        - environment
        - compute
      properties:
        project:
          description: The project the environment belongs to.
          allOf:
            - $ref: '#/components/schemas/V2WorkspaceGetUsageResource'
        app:
          description: >
            The app the environment belongs to. Omitted when the usage was
            recorded

            before Unkey stored app ids and the environment was deleted since.
          allOf:
            - $ref: '#/components/schemas/V2WorkspaceGetUsageResource'
        environment:
          $ref: '#/components/schemas/V2WorkspaceGetUsageEnvironmentResource'
        compute:
          $ref: '#/components/schemas/V2WorkspaceGetUsageCompute'
      additionalProperties: false
    V2WorkspaceGetUsageByAppRow:
      type: object
      description: Active gateway keys counted for one app in the period.
      required:
        - gateway
      properties:
        project:
          description: >-
            The project the app belongs to. Omitted when the app was deleted or
            `app` is omitted.
          allOf:
            - $ref: '#/components/schemas/V2WorkspaceGetUsageResource'
        app:
          description: |
            The app whose gateway verified the keys. Omitted for keys whose
            verifications were all recorded before Unkey stored app ids.
          allOf:
            - $ref: '#/components/schemas/V2WorkspaceGetUsageResource'
        gateway:
          $ref: '#/components/schemas/V2WorkspaceGetUsageGateway'
      additionalProperties: false
    V2WorkspaceGetUsageResource:
      type: object
      description: A project or app. `name` is omitted when the resource was deleted.
      required:
        - id
      properties:
        id:
          type: string
          description: The resource id.
          example: proj_1234abcd
        name:
          type: string
          description: The resource name.
          example: Payments
      additionalProperties: false
    V2WorkspaceGetUsageEnvironmentResource:
      type: object
      description: An environment. `slug` is omitted when the environment was deleted.
      required:
        - id
      properties:
        id:
          type: string
          description: The environment id.
          example: env_1234abcd
        slug:
          type: string
          description: The environment slug.
          example: production
      additionalProperties: false
  securitySchemes:
    bearer:
      bearerFormat: bearer token
      description: >-
        Unkey uses bearer tokens for authentication. Public integrations use
        root keys, while the dashboard proxy uses short-lived JWTs.

        To authenticate, include the token in the Authorization header of each
        request:

        ```

        Authorization: Bearer unkey_123

        ```

        Root keys have specific permissions attached to them, controlling what
        operations they can perform. Resource permissions use Unkey Resource
        Names plus actions, like
        `unkey:v1:ws_123:projects/*/keyspaces/*/keys/*#write`.

        Security best practices:

        - Keep root keys secure and never expose them in client-side code

        - Use different root keys for different environments

        - Rotate keys periodically, especially after team member departures

        - Create keys with minimal necessary permissions following least
        privilege principle

        - Monitor key usage with audit logs.
      scheme: bearer
      type: http
      x-speakeasy-name-override: rootKey

````

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