Run a script on a target
Run a script on all devices, on one or more device groups, or on an explicit list of devices — intersected with the given platforms. Pass { "scriptId": 12 } to run a saved script (see getScripts), or { "contents": "..." } to send the source inline. An inline run may only target a single device.
The target is resolved once, at trigger time: devices that join a group later are not included. The response returns immediately with every execution pending; poll getScriptRun for progress.
To run on exactly one device, runDeviceScript is the shorter equivalent. To check how many devices would be reached without executing anything, use previewScriptRunTarget.
⚠️ This executes arbitrary code on the targeted devices with elevated privileges, and is not idempotent — repeating the call runs the script again. Review the script and the target before calling.
Supported platforms: macOS, Windows, Linux. Not supported: iOS, Android, ChromeOS.
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.
Authorizations
Use your Primo API key in the Authorization header as Bearer <API_KEY>.
Body
What to run: { "scriptId": 12 } for a script from the catalog, or { "contents": "..." } to send the source inline. An inline run may only target a single device.
- Option 1
- Option 2
Which devices to run on, intersected with platforms. Resolved once at trigger time — devices joining a group later are not included.
- Option 1
- Option 2
- Option 3
Platforms to run on. The target is intersected with this list, and a saved script must support them.
1macos, windows, linux Response
The target as submitted.
- Option 1
- Option 2
- Option 3
macos, windows, linux Full source of the script as executed.
Number of devices the run resolved to.
^(?:(?:\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))$One execution per resolved device, all pending at creation. Poll getScriptRun or getScriptRunExecutions for outcomes.