> ## 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.

# List latest job execution per device

> List each device in a site with its latest job execution.

Device-first: one row per device, ordered by the latest execution's
``created_at`` (most recent first), with never-run devices last. A
device that has never run a job returns ``latest_execution: null``. The
``status`` filter matches the device's LATEST execution — a device whose
most recent run passed is excluded from ``status=failed`` even if it
failed earlier, and never-run devices drop out when ``status`` is set.
``workflow_id``/``workflow_name`` narrow which runs count as "latest";
``workflow_name`` uses the workflow's temporal name.



## OpenAPI

````yaml /openapi/fleet-manager-openapi.yaml get /api/v1/devices/latest-executions/
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/latest-executions/:
    get:
      tags:
        - Devices
      summary: List latest job execution per device
      description: |-
        List each device in a site with its latest job execution.

        Device-first: one row per device, ordered by the latest execution's
        ``created_at`` (most recent first), with never-run devices last. A
        device that has never run a job returns ``latest_execution: null``. The
        ``status`` filter matches the device's LATEST execution — a device whose
        most recent run passed is excluded from ``status=failed`` even if it
        failed earlier, and never-run devices drop out when ``status`` is set.
        ``workflow_id``/``workflow_name`` narrow which runs count as "latest";
        ``workflow_name`` uses the workflow's temporal name.
      operationId: api_v1_devices_latest_executions_list
      parameters:
        - name: limit
          required: false
          in: query
          description: Number of results to return per page.
          schema:
            type: integer
            maximum: 500
            minimum: 1
        - name: page
          required: false
          in: query
          description: A page number within the paginated result set.
          schema:
            type: integer
        - in: query
          name: site_id
          schema:
            type: string
            format: uuid
          description: Site to scope the device list to. Required.
          required: true
        - in: query
          name: status
          schema:
            type: array
            items:
              $ref: '#/components/schemas/JobDeviceStatusEnum'
          description: >-
            Filter to devices whose LATEST execution has one of these statuses.
            Multiple values may be separated by commas.
          explode: false
          style: form
        - in: query
          name: workflow_id
          schema:
            type: string
            format: uuid
          description: Narrow which runs count as 'latest' to this workflow.
        - in: query
          name: workflow_name
          schema:
            $ref: '#/components/schemas/TemporalWorkflowNameEnum'
          description: Narrow which runs count as 'latest' to this temporal workflow name.
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedDeviceLatestExecutionList'
          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
            - job-device-status:read
        - cookieAuth: []
components:
  schemas:
    JobDeviceStatusEnum:
      enum:
        - running
        - completed
        - failed
        - cancelled
        - terminated
        - superseded
        - timed_out
      type: string
      description: |-
        * `running` - Running
        * `completed` - Completed
        * `failed` - Failed
        * `cancelled` - Cancelled
        * `terminated` - Terminated
        * `superseded` - Superseded
        * `timed_out` - Timed Out
    TemporalWorkflowNameEnum:
      enum:
        - EnrollmentWorkflow
        - SingleNodeBurnInWorkflow
        - MultiNodeBurnInPairwiseWorkflow
        - MultiNodeBurnInCollectiveWorkflow
        - PrepareHardwareTestImagesWorkflow
        - ReportGenerationWorkflow
        - SlurmAdoptWorkflow
        - SlurmReleaseWorkflow
        - CustomerReleaseWorkflow
        - IronicNodeCleanWorkflow
        - QuarantineWorkflow
        - ReleaseWorkflow
        - UnenrollmentWorkflow
        - ConnectivityVerificationWorkflow
        - FirmwareInventoryWorkflow
        - FirmwareVerificationWorkflow
        - FirmwarePolicyVerificationWorkflow
        - NVSwitchFirmwarePolicyVerificationWorkflow
        - NodeSwapWorkflow
        - PowerCycleWorkflow
        - PowerOffWorkflow
        - SetMaintenanceModeWorkflow
        - DisableMaintenanceModeWorkflow
        - ColdResetBmcWorkflow
        - SlurmDrainNodeWorkflow
        - SlurmResumeNodeWorkflow
        - FrontendVrfReturnWorkflow
        - FrontendVrfIsolateWorkflow
        - NvLinkIsolateWorkflow
        - NvLinkReturnWorkflow
        - BackendVrfIsolateWorkflow
        - BackendVrfReturnWorkflow
        - ImageNodeWorkflow
        - UnimageNodeWorkflow
        - NodeDiagnosticsWorkflow
      type: string
      description: >-
        * `EnrollmentWorkflow` - Enrollment Workflow

        * `SingleNodeBurnInWorkflow` - Single Node Burn-In Workflow

        * `MultiNodeBurnInPairwiseWorkflow` - Multi-Node Burn-In Pairwise
        Workflow

        * `MultiNodeBurnInCollectiveWorkflow` - Multi-Node Burn-In Collective
        Workflow

        * `PrepareHardwareTestImagesWorkflow` - Prepare Hardware-Test Images
        Workflow

        * `ReportGenerationWorkflow` - Report Generation Workflow

        * `SlurmAdoptWorkflow` - Add to Test Cluster Workflow

        * `SlurmReleaseWorkflow` - Release from Test Cluster Workflow

        * `CustomerReleaseWorkflow` - Customer Release Workflow

        * `IronicNodeCleanWorkflow` - Ironic Node Clean Workflow

        * `QuarantineWorkflow` - Quarantine Workflow

        * `ReleaseWorkflow` - Release Workflow

        * `UnenrollmentWorkflow` - Unenrollment Workflow

        * `ConnectivityVerificationWorkflow` - Connectivity Verification
        Workflow

        * `FirmwareInventoryWorkflow` - Firmware Inventory Workflow

        * `FirmwareVerificationWorkflow` - Firmware Verification Workflow

        * `FirmwarePolicyVerificationWorkflow` - Firmware Policy Verification
        Workflow

        * `NVSwitchFirmwarePolicyVerificationWorkflow` - NVSwitch Firmware
        Policy Verification Workflow

        * `NodeSwapWorkflow` - Node Swap Workflow

        * `PowerCycleWorkflow` - Power Cycle Workflow

        * `PowerOffWorkflow` - Power Off Workflow

        * `SetMaintenanceModeWorkflow` - Set Maintenance Mode Workflow

        * `DisableMaintenanceModeWorkflow` - Disable Maintenance Mode Workflow

        * `ColdResetBmcWorkflow` - Cold Reset BMC Workflow

        * `SlurmDrainNodeWorkflow` - Slurm Drain Node Workflow

        * `SlurmResumeNodeWorkflow` - Slurm Resume Drained Node Workflow

        * `FrontendVrfReturnWorkflow` - Frontend VRF Return Workflow

        * `FrontendVrfIsolateWorkflow` - Frontend VRF Isolate Workflow

        * `NvLinkIsolateWorkflow` - NVLink Isolate Workflow

        * `NvLinkReturnWorkflow` - NVLink Return Workflow

        * `BackendVrfIsolateWorkflow` - Back-end VRF Isolate Workflow

        * `BackendVrfReturnWorkflow` - Back-end VRF Return Workflow

        * `ImageNodeWorkflow` - Image Node Workflow

        * `UnimageNodeWorkflow` - Unimage Node Workflow

        * `NodeDiagnosticsWorkflow` - Node Diagnostics Workflow
    PaginatedDeviceLatestExecutionList:
      type: object
      required:
        - count
        - results
      properties:
        count:
          type: integer
          example: 123
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=4
        previous:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=2
        results:
          type: array
          items:
            $ref: '#/components/schemas/DeviceLatestExecution'
    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'
    DeviceLatestExecution:
      type: object
      description: |-
        One device with its latest execution (``null`` when it never ran).

        Device-static fields (rack, location, position, triage) sit at the top
        level so they are present even for never-run devices, where
        ``latest_execution`` is ``null``.
      properties:
        device_id:
          type: string
          format: uuid
        device_name:
          type: string
        rack:
          $ref: '#/components/schemas/CompactIdName'
        location:
          $ref: '#/components/schemas/CompactIdName'
        position:
          type: number
          format: double
          nullable: true
        in_triage:
          type: boolean
        entered_triage_at:
          type: string
          format: date-time
          nullable: true
        latest_execution:
          allOf:
            - $ref: '#/components/schemas/LatestExecution'
          nullable: true
      required:
        - device_id
        - device_name
        - entered_triage_at
        - in_triage
        - latest_execution
        - location
        - position
        - rack
    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
    CompactIdName:
      type: object
      description: Compact `{id, name}` response item.
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
      required:
        - id
        - name
    LatestExecution:
      type: object
      description: A device's most recent job execution (its latest ``JobDeviceStatus``).
      properties:
        job_id:
          type: string
          format: uuid
        job_device_status_id:
          type: string
          format: uuid
        workflow_id:
          type: string
          format: uuid
        workflow_name:
          $ref: '#/components/schemas/TemporalWorkflowNameEnum'
        status:
          allOf:
            - $ref: '#/components/schemas/JobDeviceStatusEnum'
          nullable: true
        started_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
        failure_code:
          type: string
          nullable: true
          description: >-
            ADR-0014 workflow failure code. Unknown historical strings are
            preserved instead of coerced to the current taxonomy.
        failure_message:
          type: string
          nullable: true
        responsible_team:
          allOf:
            - $ref: '#/components/schemas/ResponsibleTeamEnum'
          nullable: true
        temporal_link:
          type: string
          format: uri
          nullable: true
      required:
        - completed_at
        - failure_code
        - failure_message
        - job_device_status_id
        - job_id
        - responsible_team
        - started_at
        - status
        - temporal_link
        - workflow_id
        - workflow_name
    ResponsibleTeamEnum:
      type: string
      enum:
        - fleet_manager
        - infra_eng
        - dc_eng
        - unknown
  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.