> ## 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 a device's script history

> Return the paginated script executions that reached this device, newest first — across every run, including company-wide and device-group runs launched elsewhere. Each entry carries the script that ran plus its status, output, exit code and runtime. Use this to answer "what has been run on this machine?".

For the per-device results of one specific run, use `getScriptRunExecutions`. For the list of runs themselves, use `getScriptRuns`.

Executions are reconciled with FleetDM by a background sweep that runs every 15 minutes, so a freshly created run reads back as `pending` until the next sweep. Poll no more often than that.

<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}/script-executions
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}/script-executions:
    get:
      tags:
        - Devices
      summary: List a device's script history
      description: >-
        Return the paginated script executions that reached this device, newest
        first — across every run, including company-wide and device-group runs
        launched elsewhere. Each entry carries the script that ran plus its
        status, output, exit code and runtime. Use this to answer "what has been
        run on this machine?".


        For the per-device results of one specific run, use
        `getScriptRunExecutions`. For the list of runs themselves, use
        `getScriptRuns`.


        Executions are reconciled with FleetDM by a background sweep that runs
        every 15 minutes, so a freshly created run reads back as `pending` until
        the next sweep. Poll no more often than that.
      operationId: getDeviceScriptExecutions
      parameters:
        - name: deviceId
          required: true
          in: path
          schema:
            type: string
        - name: page
          required: false
          in: query
          description: Page number
          schema:
            minimum: 1
            maximum: 9007199254740991
            default: 1
            type: number
        - name: perPage
          required: false
          in: query
          description: Number of items per page (max 100)
          schema:
            minimum: 1
            maximum: 100
            default: 50
            type: number
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDeviceScriptExecutions_Output'
components:
  schemas:
    GetDeviceScriptExecutions_Output:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              runId:
                description: Identifier of the script run this execution belongs to.
                type: string
              deviceId:
                type: string
              status:
                description: >-
                  Outcome on one device. `pending`: queued, the device may be
                  offline. `success`: ran with exit code 0. `failed`: ran with a
                  non-zero exit code, or the device was incompatible. `timeout`:
                  exceeded the execution limit. `cancelled`: cancelled before
                  running.
                type: string
                enum:
                  - pending
                  - success
                  - failed
                  - timeout
                  - cancelled
              output:
                description: >-
                  Combined stdout/stderr once the execution completes. Null
                  while pending.
                anyOf:
                  - type: string
                  - type: 'null'
              exitCode:
                description: >-
                  Process exit code once the execution completes. Null while
                  pending.
                anyOf:
                  - type: number
                  - type: 'null'
              runtime:
                description: >-
                  Duration in seconds once the execution completes. Null while
                  pending.
                anyOf:
                  - type: number
                  - type: 'null'
              createdAt:
                type: string
                format: date-time
                pattern: >-
                  ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
              updatedAt:
                type: string
                format: date-time
                pattern: >-
                  ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
              script:
                description: >-
                  The script as executed. `scriptId` and `name` are null when
                  the run used inline contents.
                anyOf:
                  - type: object
                    properties:
                      scriptId:
                        anyOf:
                          - type: number
                          - type: 'null'
                      name:
                        anyOf:
                          - type: string
                          - type: 'null'
                    required:
                      - scriptId
                      - name
                    additionalProperties: false
                  - type: 'null'
            required:
              - id
              - runId
              - deviceId
              - status
              - output
              - exitCode
              - runtime
              - createdAt
              - updatedAt
              - script
            additionalProperties: false
        pagination:
          type: object
          properties:
            totalElements:
              type: integer
              minimum: 0
              maximum: 9007199254740991
            totalPages:
              type: integer
              minimum: 0
              maximum: 9007199254740991
            page:
              type: integer
              minimum: 1
              maximum: 9007199254740991
            perPage:
              type: integer
              minimum: 1
              maximum: 100
          required:
            - totalElements
            - totalPages
            - page
            - perPage
          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>`.

````