Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Created August 23, 2026 23:40
Show Gist options
  • Select an option

  • Save talkingmoose/90b269d7edc8dd3227fd91c33fc32080 to your computer and use it in GitHub Desktop.

Select an option

Save talkingmoose/90b269d7edc8dd3227fd91c33fc32080 to your computer and use it in GitHub Desktop.
Purpose: Example Jamf Platform API Gateway script to run a Jamf Pro command (turn computer Bluetooth on or off).
#!/bin/zsh
:<<'ABOUT_THIS_SCRIPT'
-----------------------------------------------------------------------
Written by:William Smith
Technical Enablement Manager
Jamf
bill@talkingmoose.net
https://gist.github.com/talkingmoose/90b269d7edc8dd3227fd91c33fc32080
Originally posted: August 23, 2026
Purpose: Example Jamf Platform API Gateway script to run a
Jamf Pro command (turn computer Bluetooth on or off).
Instructions:
1. In Jamf Account > Integrations, create a new integration
with permissions:
execute:pro:computer-commands
execute:pro:mobile-device-commands
2. Update url, client_id, and client_secret variables below.
3. In Jamf Account > Platform Environments, locate the tenant
selected in the integration.
4. Update tenant_id variable below.
5. Set bluetooth to "true" or "false" in the clientData below.
Except where otherwise noted, this work is licensed under
http://creativecommons.org/licenses/by/4.0/
"She wasn't doing a thing that I could see,
except standing there leaning on the balcony railing,
holding the universe together."
-----------------------------------------------------------------------
ABOUT_THIS_SCRIPT
url="https://us.apigw.jamf.com"
client_id="dfab3788-63ab-4458-a1db-58e606e4a82a"
client_secret="pqE269pc0AFP9UehhKzJqGMf0aDtyXik"
tenant_id="87c4cfcb-de07-4003-9d8c-c067edb6cd16"
access_token=$( /usr/bin/curl \
--data-urlencode "client_id=$client_id" \
--data-urlencode "client_secret=$client_secret" \
--data-urlencode "grant_type=client_credentials" \
--header "Content-Type: application/x-www-form-urlencoded" \
--request POST \
--silent \
--url "$url/auth/token" \
| /usr/bin/plutil -extract access_token raw - )
/usr/bin/curl \
--header "Authorization: Bearer $access_token" \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--request POST \
--silent \
--url "$url/api/pro/v2/tenant/$tenant_id/mdm/commands" \
--data '
{
"clientData": [
{
"managementId": "6e98eb59-4aa8-4cae-aab7-070fb5907ae2"
}
],
"commandData": {
"commandType": "SETTINGS",
"bluetooth": true
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment