Help with API Restart Script for iPads on JAMF School

New Contributor

Hey everyone,

I am wondering if i could get some advice on setting up an API Script for JAMF School that will restart 2 specific iPads at a set time each day. What would be the code and do I have to run it on a Mac? I have seen a few older forums that have restart scripts but i could not get them to work with JAMF School.

I would appreciate any help on this.


New Contributor III

Jamf provide a description of the api on the zuludesk website: 

Here is a basic implementation for an api call provided for JavaScript and PHP. But I prefer and use python.

The device restart endpoint is described here 


Now lets get coding...

import requests
from requests.auth import HTTPBasicAuth

# Settings for authentication against the API endpoint
# configured in Jamf-School -> Settings -> API -> Add API Key
netwok_id = "123455675332"  # Network ID of your API endpoint
api_pw = "324JNSDNK29KNKJ239NJKN"  # API Password of your Api endpoint
authObject = HTTPBasicAuth(network_id, api_pw)
url = ""

# Aquire udid of the device we want to restart 
# -> if they are always the same you can save these udids and dont need this call
path = "/".join((url, "devices"))

serialnumber = "GXYZH1292XXX"
payload = { "serialnumber": serialnumber }  # Serial Number of the device 
r = requests.get(path, params=payload, auth=authObject)
if r.status_code == 200:
    if len(r.json().get("devices")) > 0:
        udid = r.json().get("devices")[0].get("UDID")
        print(f"{serialnumber} -> {udid}")
        print("no device found")

# /devices/:udid/restart
path = "/".join((url, "devices", udid, "restart"))

payload = {"udid": udid, "clearPasscode": "false"}  # turn true, if you want to clear passcode first
r =, json=payload, auth=authObject)
if r.status_code == 200:
    print(f"{r.json().get('message')} of device {r.json().get('device')}")
elif r.status_code == 404:
    print("unknown error occured")


I tested this peace of code with my own credentials and a serial number of a known device. and it worked. But you can improve it more. Because it is not really usable at the moment, but this is part of basically python programming at all. 


In my own implementation i have encapsulated the Jamf API in a python class and can use it via command-line. 

But with this you can restart a device. (for ure 2 or more device purpose you have to send a request for every device you would like to get, or filter by location or some other stuff mentioned in the documentation. But it is not possible to send a filter like: payload = {"serialnumber": serialnumbers_as_list }  # in this only the last one in the list get returned... not as intuitive - but the api is fast enought to request all devices and filter dem loacally with python to get the list of udids)