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

# List MDM commands for a device

> Return the paginated list of MDM commands sent to a device, including their status.

<span className="badge-read">Key: Read</span><span className="badge-company">Scope: Company</span>


## OpenAPI

````yaml https://api.getprimo.com/openapi.json get /devices/{deviceId}/commands
openapi: 3.1.1
info:
  title: Public API - BETA
  description: Read docs on https://docs.getprimo.com/
  version: '1.0'
  contact: {}
servers:
  - url: https://api.getprimo.com
security:
  - apikey: []
tags: []
paths:
  /devices/{deviceId}/commands:
    get:
      tags:
        - Devices
      summary: List MDM commands for a device
      description: >-
        Return the paginated list of MDM commands sent to a device, including
        their status.
      operationId: getDeviceCommands
      parameters:
        - name: deviceId
          required: true
          in: path
          schema:
            type: string
        - name: commandStatus
          required: false
          in: query
          description: Filter by command status
          schema:
            enum:
              - ran
              - pending
              - failed
            type: string
        - name: requestType
          required: false
          in: query
          description: Filter by MDM command request type
          schema:
            type: string
        - name: orderDirection
          required: false
          in: query
          description: Order direction
          schema:
            enum:
              - asc
              - desc
            type: string
        - name: orderKey
          required: false
          in: query
          description: Field to order results by
          schema:
            type: string
        - name: page
          required: false
          in: query
          description: Page number
          schema:
            type: number
        - name: perPage
          required: false
          in: query
          description: Number of items per page (max 100)
          schema:
            type: number
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDeviceCommands_Output'
components:
  schemas:
    GetDeviceCommands_Output:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              hostUuid:
                type: string
              commandUuid:
                type: string
              status:
                type: string
              commandStatus:
                anyOf:
                  - type: string
                  - type: 'null'
              updatedAt:
                type: string
              requestType:
                type: string
              name:
                anyOf:
                  - type: string
                  - type: 'null'
              hostname:
                anyOf:
                  - type: string
                  - type: 'null'
            required:
              - hostUuid
              - commandUuid
              - status
              - commandStatus
              - updatedAt
              - requestType
              - name
              - hostname
            additionalProperties: false
        pagination:
          type: object
          properties:
            page:
              type: integer
              minimum: 1
              maximum: 9007199254740991
            perPage:
              type: integer
              minimum: 1
              maximum: 100
            hasNextPage:
              type: boolean
            hasPreviousPage:
              type: boolean
            totalElements:
              anyOf:
                - type: integer
                  minimum: 0
                  maximum: 9007199254740991
                - type: 'null'
          required:
            - page
            - perPage
            - hasNextPage
            - hasPreviousPage
            - totalElements
          additionalProperties: false
      required:
        - data
        - pagination
      additionalProperties: false
  securitySchemes:
    apikey:
      scheme: bearer
      bearerFormat: API key
      type: http
      description: >-
        Use your Primo API key in the Authorization header as `Bearer
        <API_KEY>`.

````