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

# Count the devices a script run would reach

> Return how many devices a run with this target and these platforms would resolve to, using exactly the same resolution as `runScript`. Nothing is executed. Call this before `runScript` to check the blast radius, especially with `target.type = "all"`.

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


## OpenAPI

````yaml https://api.getprimo.com/openapi.json post /script-runs/preview-target-count
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:
  /script-runs/preview-target-count:
    post:
      tags:
        - Scripts
      summary: Count the devices a script run would reach
      description: >-
        Return how many devices a run with this target and these platforms would
        resolve to, using exactly the same resolution as `runScript`. Nothing is
        executed. Call this before `runScript` to check the blast radius,
        especially with `target.type = "all"`.
      operationId: previewScriptRunTarget
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewScriptRunTargetBody'
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreviewScriptRunTarget_Output'
components:
  schemas:
    PreviewScriptRunTargetBody:
      type: object
      properties:
        target:
          description: >-
            Which devices to run on, intersected with `platforms`. Resolved once
            at trigger time — devices joining a group later are not included.
          anyOf:
            - type: object
              properties:
                type:
                  type: string
                  const: all
              required:
                - type
            - type: object
              properties:
                type:
                  type: string
                  const: deviceGroups
                deviceGroupIds:
                  minItems: 1
                  type: array
                  items:
                    type: string
              required:
                - type
                - deviceGroupIds
            - type: object
              properties:
                type:
                  type: string
                  const: devices
                deviceIds:
                  minItems: 1
                  type: array
                  items:
                    type: string
              required:
                - type
                - deviceIds
        platforms:
          description: >-
            Platforms to run on. The target is intersected with this list, and a
            saved script must support them.
          minItems: 1
          type: array
          items:
            type: string
            enum:
              - macos
              - windows
              - linux
      required:
        - target
        - platforms
    PreviewScriptRunTarget_Output:
      type: object
      properties:
        count:
          type: number
          description: >-
            Number of devices a run with this target and these platforms would
            reach.
      required:
        - count
      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>`.

````