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

# Get sandbox stats

> Returns an average and a time-series of CPU%, memory%, and network
bytes/sec for the requested lookback window. Server targets ~250 evenly
spaced data points; step interval adjusts with `hoursAgo`.




## OpenAPI

````yaml GET /sandboxes/{id}/stats
openapi: 3.0.3
info:
  title: Brimble Sandbox API
  description: >
    REST API for managing Brimble sandboxes, ephemeral compute environments with

    optional persistent storage. Covers lifecycle (create / pause / resume /
    destroy),

    egress policy, runtime operations (exec, runCode, file upload/download),

    observability (logs, stats), and snapshots.


    ## Conventions


    - **Response envelope:** non-`204` JSON responses use `{ "message": string,
    "data"?: <payload> }`.
      The schemas below describe the **`data`** payload only.
    - **Errors:** every non-2xx response uses `{ "message": string }`. The
    message is
      user-facing.
    - **Async transitions:** pause / resume / destroy return immediately;
      the status change is visible on the next `GET` or in the dashboard.
      **Create is synchronous** — `POST /sandboxes` blocks until `status` is `ready`.
    - **IDs:** every `id` is a 24-char hex string.
  version: 1.0.0
  contact:
    name: Brimble Engineering
    url: https://brimble.io
servers:
  - url: https://sandbox.brimble.io
    description: Production
security:
  - brimbleKey: []
tags:
  - name: Sandboxes
    description: Lifecycle and metadata
  - name: Runtime
    description: Exec, code, files
  - name: Observability
    description: Logs and stats
  - name: Snapshots
    description: Manual & automatic snapshots
  - name: Volumes
    description: >-
      Persistent disks, pre-provisioned independently of sandbox lifecycle, then
      attached to a sandbox or project
paths:
  /sandboxes/{id}/stats:
    get:
      tags:
        - Observability
      summary: Get CPU / memory / network stats
      description: |
        Returns an average and a time-series of CPU%, memory%, and network
        bytes/sec for the requested lookback window. Server targets ~250 evenly
        spaced data points; step interval adjusts with `hoursAgo`.
      operationId: getSandboxStats
      parameters:
        - $ref: '#/components/parameters/SandboxIdParam'
        - in: query
          name: hoursAgo
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Lookback window in hours.
      responses:
        '200':
          description: Stats payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatsEnvelope'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    SandboxIdParam:
      in: path
      name: id
      required: true
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
      description: 24-char hex id of the sandbox.
  schemas:
    StatsEnvelope:
      type: object
      required:
        - message
        - data
      properties:
        message:
          type: string
          example: Sandbox stats fetched
        data:
          $ref: '#/components/schemas/Stats'
    Stats:
      type: object
      required:
        - average
        - replicaCount
        - results
        - responseTime
      properties:
        average:
          type: object
          required:
            - memory
            - cpu
            - network
          properties:
            memory:
              $ref: '#/components/schemas/StatsAverageNumeric'
            cpu:
              $ref: '#/components/schemas/StatsAverageNumeric'
            network:
              $ref: '#/components/schemas/StatsAverageNetwork'
        replicaCount:
          type: integer
          description: Always `1` for sandboxes.
        results:
          type: array
          items:
            $ref: '#/components/schemas/StatsTimelinePoint'
        responseTime:
          type: object
          nullable: true
          description: Always `null` for sandboxes (no HTTP-facing proxy).
    ErrorResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human-readable, user-facing error reason.
    StatsAverageNumeric:
      type: object
      required:
        - totalInPercentage
        - size
      properties:
        totalInPercentage:
          type: number
          description: Mean utilization 0–100.
        size:
          type: number
          description: |
            Cap value. For memory this is MB, for CPU this is MHz.
    StatsAverageNetwork:
      type: object
      properties:
        value:
          type: number
          nullable: true
        total:
          type: number
          nullable: true
        totalInPercentage:
          type: number
          nullable: true
        bytesPerSecond:
          type: number
          nullable: true
    StatsTimelinePoint:
      type: object
      required:
        - date
        - memory
        - cpu
        - network
      properties:
        date:
          type: string
          format: date-time
        memory:
          type: number
        cpu:
          type: number
        network:
          type: object
          required:
            - bytesPerSecond
          properties:
            bytesPerSecond:
              type: number
              nullable: true
  responses:
    BadRequest:
      description: Validation error / invalid state transition
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalidId:
              summary: Invalid sandbox id
              value:
                message: Invalid sandbox id
            statusTransition:
              summary: Wrong status
              value:
                message: Sandbox is paused; only ready sandboxes can be paused
            fileNotDir:
              summary: Parent dir missing on upload
              value:
                message: 'Destination directory does not exist: /work'
            duplicateVolumeName:
              summary: Duplicate volume name
              value:
                message: A volume named "node-cache" already exists
            volumeAttached:
              summary: Delete attempted on attached volume
              value:
                message: Volume is attached; detach it before deleting
    NotFound:
      description: >-
        Sandbox or related resource not found (also returned when owned by
        another user)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            sandboxNotFound:
              value:
                message: Sandbox not found
            snapshotNotFound:
              value:
                message: Snapshot not found
            volumeNotFound:
              value:
                message: Volume not found
  securitySchemes:
    brimbleKey:
      type: apiKey
      in: header
      name: x-brimble-key
      description: |
        Your account-level Brimble API key. Find it in the dashboard under
        your profile drawer → **API key** (click the avatar in the sidebar).
        Available on paid plans only.

````