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

# Get device counts

> Return per-status device counts for a site, with the device list filters.

Requires ``site_id`` to scope the response (matching the compact
``list-all``/``list-all-ids`` endpoints) and additionally accepts every
``DeviceFilter`` query parameter the paginated list supports (e.g.
``device_class``, ``location_id``, ``rack_id``, ``topology_group_id``), so
the counts reflect whatever filter the device list is showing. Aggregates
in a single query; the response mirrors the ``counts`` object embedded on
the site detail endpoint, including the ``total``.



## OpenAPI

````yaml /openapi/fleet-manager-openapi.yaml get /api/v1/devices/counts/
openapi: 3.0.3
info:
  title: Fleet Manager API
  version: 1.0.0
  description: API for the Nscale Fleet Manager
servers: []
security: []
paths:
  /api/v1/devices/counts/:
    get:
      tags:
        - Devices
      summary: Get device counts
      description: >-
        Return per-status device counts for a site, with the device list
        filters.


        Requires ``site_id`` to scope the response (matching the compact

        ``list-all``/``list-all-ids`` endpoints) and additionally accepts every

        ``DeviceFilter`` query parameter the paginated list supports (e.g.

        ``device_class``, ``location_id``, ``rack_id``, ``topology_group_id``),
        so

        the counts reflect whatever filter the device list is showing.
        Aggregates

        in a single query; the response mirrors the ``counts`` object embedded
        on

        the site detail endpoint, including the ``total``.
      operationId: api_v1_devices_counts_retrieve
      parameters:
        - in: query
          name: allocation_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - name: annotation_eq
          required: false
          in: query
          description: >-
            Filter by annotation key=value pairs (AND semantics). Use
            annotation_eq[key]=value.
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties:
              type: string
        - name: annotation_has
          required: false
          in: query
          description: Filter by annotation key existence (comma-separated, AND semantics).
          schema:
            type: string
        - in: query
          name: chad_ignore
          schema:
            type: boolean
        - in: query
          name: current_instance_uuid
          schema:
            type: string
        - in: query
          name: current_tenant_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: customer_ready
          schema:
            type: boolean
        - in: query
          name: device_class
          schema:
            type: array
            items:
              type: string
              enum:
                - cpu_baremetal
                - cpu_hypervisor
                - gpu_compute
                - switch
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: device_group_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: device_type_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: health_status
          schema:
            type: array
            items:
              type: string
              enum:
                - critical
                - degraded
                - healthy
                - unknown
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: in_triage
          schema:
            type: boolean
        - in: query
          name: infrastructure_ref
          schema:
            type: string
        - in: query
          name: infrastructure_ref__startswith
          schema:
            type: string
        - in: query
          name: inventory_only
          schema:
            type: boolean
        - in: query
          name: inventory_status
          schema:
            type: array
            items:
              type: string
              enum:
                - active
                - decommissioned
                - decommissioning
                - failed
                - inventory
                - offline
                - planned
                - returned
                - rma
                - staged
                - unknown
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: ironic_provision_state
          schema:
            type: array
            items:
              type: string
              enum:
                - active
                - adopt failed
                - adopting
                - available
                - clean failed
                - clean hold
                - clean wait
                - cleaning
                - deleted
                - deleting
                - deploy complete
                - deploy failed
                - deploy hold
                - deploying
                - enroll
                - error
                - inspect failed
                - inspect wait
                - inspecting
                - manageable
                - rebuild
                - rescue
                - rescue failed
                - rescue wait
                - rescuing
                - service
                - service failed
                - service hold
                - service wait
                - servicing
                - unknown
                - unrescue failed
                - unrescuing
                - verifying
                - wait call-back
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: job_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: location_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: name
          schema:
            type: string
        - in: query
          name: name_exact
          schema:
            type: string
        - in: query
          name: netbox_id
          schema:
            type: integer
        - in: query
          name: operational_status
          schema:
            type: array
            items:
              type: string
              enum:
                - available
                - delegated
                - drained
                - failed
                - in_use
                - pending_handover
                - quarantine
                - unknown
                - validation
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: rack_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: role_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: serial_number
          schema:
            type: string
        - in: query
          name: site_id
          schema:
            type: string
            format: uuid
          description: Site ID used to constrain the unpaginated compact response.
          required: true
        - in: query
          name: slurm_states
          schema:
            type: array
            items:
              type: string
              enum:
                - ALLOCATED
                - BLOCKED
                - CLOUD
                - COMPLETING
                - DOWN
                - DRAIN
                - DYNAMIC_FUTURE
                - DYNAMIC_NORM
                - ERROR
                - FAIL
                - FUTURE
                - IDLE
                - INVALID_REG
                - MAINTENANCE
                - MIXED
                - NOT_RESPONDING
                - PLANNED
                - POWERED_DOWN
                - POWERING_DOWN
                - POWERING_UP
                - POWER_DOWN
                - POWER_DRAIN
                - POWER_UP
                - REBOOT_CANCELED
                - REBOOT_ISSUED
                - REBOOT_REQUESTED
                - RESERVED
                - RESUME
                - UNDRAIN
                - UNKNOWN
          description: >-
            SLURM node states. A device matches when its own state list contains
            any of these. Multiple values may be separated by commas.
          explode: false
          style: form
        - name: tag
          required: false
          in: query
          description: Filter by tags (comma-separated, OR semantics).
          schema:
            type: string
        - in: query
          name: topology_group_id
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: topology_group_id_strict
          schema:
            type: array
            items:
              type: string
              format: uuid
          description: Multiple values may be separated by commas.
          explode: false
          style: form
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SiteDeviceCounts'
          description: ''
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication credentials were not provided or are invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: You do not have permission to perform this action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - oauth2:
            - device:read
        - cookieAuth: []
components:
  schemas:
    SiteDeviceCounts:
      type: object
      description: >-
        Schema for the nested counts field on Site responses.


        Every bucket bar ``inventory_only_devices`` is scoped to FM-managed
        devices

        (see ``device_status_count_aggregations``), so an ``inventory_only``
        site

        legitimately reports zero across them however many inventory rows it
        holds —

        ``inventory_only_devices`` is where those rows are counted. Filter the
        site

        list by ``inventory_only`` to list the same universe a given bucket
        measures.
      properties:
        total:
          type: integer
          description: >-
            Number of FM-managed devices at the site; excludes inventory-only
            devices.
        inventory_only_devices:
          type: integer
          description: >-
            Number of inventory-only devices at the site, the population
            excluded from total and from every status breakdown. Add the two for
            every device row the site holds.
        customer_ready:
          allOf:
            - $ref: '#/components/schemas/CustomerReadyCount'
          description: Counts of customer-ready vs non-customer-ready devices
        inventory_status:
          allOf:
            - $ref: '#/components/schemas/DeviceInventoryStatusCounts'
          description: Count of devices per inventory status
        operational_status:
          allOf:
            - $ref: '#/components/schemas/DeviceOperationalStatusCounts'
          description: Count of devices per operational status
        health_status:
          allOf:
            - $ref: '#/components/schemas/DeviceHealthStatusCounts'
          description: Count of devices per health status
      required:
        - customer_ready
        - health_status
        - inventory_only_devices
        - inventory_status
        - operational_status
        - total
    ErrorResponse:
      type: object
      description: >-
        Uniform error body for every 4xx/5xx response. `detail` is a
        human-readable message, always present, safe to display to end users.
        `code` is the machine-readable identifier. `field_errors` lists
        per-input-field validation messages and is empty for non-field errors
        (auth, permission, not-found, conflict, server).
      required:
        - detail
        - code
        - field_errors
      properties:
        detail:
          type: string
        code:
          $ref: '#/components/schemas/ErrorCodeEnum'
        field_errors:
          type: array
          items:
            $ref: '#/components/schemas/FieldError'
    CustomerReadyCount:
      type: object
      description: Serializer for customer_ready true/false counts.
      properties:
        'true':
          type: integer
          description: Count of customer-ready devices
        'false':
          type: integer
          description: Count of non-customer-ready devices
      required:
        - 'false'
        - 'true'
    DeviceInventoryStatusCounts:
      type: object
      description: Count of devices per inventory status.
      properties:
        planned:
          type: integer
        staged:
          type: integer
        active:
          type: integer
        failed:
          type: integer
        offline:
          type: integer
        rma:
          type: integer
        returned:
          type: integer
        decommissioning:
          type: integer
        decommissioned:
          type: integer
        inventory:
          type: integer
        unknown:
          type: integer
      required:
        - active
        - decommissioned
        - decommissioning
        - failed
        - inventory
        - offline
        - planned
        - returned
        - rma
        - staged
        - unknown
    DeviceOperationalStatusCounts:
      type: object
      description: Count of devices per operational status.
      properties:
        unknown:
          type: integer
        quarantine:
          type: integer
        validation:
          type: integer
        available:
          type: integer
        in_use:
          type: integer
        delegated:
          type: integer
        pending_handover:
          type: integer
        drained:
          type: integer
        failed:
          type: integer
      required:
        - available
        - delegated
        - drained
        - failed
        - in_use
        - pending_handover
        - quarantine
        - unknown
        - validation
    DeviceHealthStatusCounts:
      type: object
      description: Count of devices per health status.
      properties:
        unknown:
          type: integer
        healthy:
          type: integer
        degraded:
          type: integer
        critical:
          type: integer
      required:
        - critical
        - degraded
        - healthy
        - unknown
    ErrorCodeEnum:
      type: string
      description: >-
        Stable machine-readable error identifier. New members may be added
        within this API version; clients must tolerate unknown values.
      enum:
        - error
        - invalid
        - parse_error
        - authentication_failed
        - not_authenticated
        - permission_denied
        - not_found
        - method_not_allowed
        - not_acceptable
        - unsupported_media_type
        - conflict
        - enrollment_infrastructure_reference_pending
        - enrollment_infrastructure_reference_changed
        - unprocessable_entity
        - throttled
        - service_unavailable
    FieldError:
      type: object
      description: One input field's validation messages.
      required:
        - field
        - messages
      properties:
        field:
          type: string
          description: >-
            Dotted path to the offending input field, or to the collection row
            when the whole row is invalid (e.g. `filters.end_date`,
            `memberships.0.role`, `memberships.0`).
        messages:
          type: array
          minItems: 1
          items:
            type: string
  securitySchemes:
    oauth2:
      type: oauth2
      flows: {}
    cookieAuth:
      type: apiKey
      in: cookie
      name: sessionid

````

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