Using Apple Shortcuts to access the Workspace One API

The Apple Shortcuts application can be utilized to make API calls against your Workspace One MDM.

Using Apple Shortcuts to access the Workspace One API

Workspace One is a pretty powerful MDM solution for managing Apple devices, but there are a few things the console does not allow a user to do easily. For me, the two things I find I want to do most on multiple endpoints is enable Remote Desktop, and make sure the agent is installed. I wrote some Python scripts to automate the process, but then decided to see if it could be done using the Apple Shortcuts application. After playing around with it for a while I think I've found a pretty decent solution.

The Get Contents of URL command in Shortcuts can be used to make GET and POST calls against URLs to manipulate the Workspace One API, so that's what I've chosen to use to make the API calls.

WS1 - get access token

Click to download shortcut

The first shortcut does a basic call to get the Access Token you will need to make further API calls. You must create a new Console Administrator role in the Workspace One console under Groups & Setting → Configurations → OAuth Client Management and save the Client ID and Client Secret.

When you import this shortcut you will be prompted for the Client ID, Client Secret, Access Token URL, and API Server URL. The Access Token URL defaults to what I use, but I understand this is a regional thing so yours may be different. See here for more information. Your API server URL is typically your console server URL renamed slightly. For example, a console URL of https://cn1234.awmdm.com would have an API server URL of https://aw1234.awmdm.com.

After setting up the shortcut you should be able to run it and receive an access token from the API. This shortcut does not send any notifications or popups. It outputs a dictionary with your Access Token, as well as the API Server URL. Further shortcuts will use these values.

WS1 API - search devices

Click to download shortcut

This second shortcut runs the WS1 API - get access token shortcut to get the API endpoint URL and Access Token, then asks you what you want to search by.

You are then asked for a string and the chosen search by field is searched for the string.

The shortcut returns a dictionary with the API access information, and a list of found devices. This return data is used by the next shortcut.

WS1 - run commands

Click to download shortcut

This final shortcut provides a short list of commands you can run against the WS1 API, then runs the WS1 API - search devices shortcut to get a list of devices.

It presents you with the list of devices, asking you to confirm that you want to run the command on them.

Finally, you are shown an alert with the results of the command on each device.

These shortcuts work well for me in my environment, but your mileage may vary. Feel free to reach out with any issues or questions.