Retrieving and Installing Updates Using the API

You can use the Automox REST API to programmatically retrieve and install updates. This article describes how to do this and references our Developer Portal and API Guide.

Step 1 - Retrieve your API Key

The API key for your account is located on the Settings → Secrets & Keys page of the console. For more information about API keys, see Managing Keys.

Step 2 - Retrieve the list of packages for a device

Using the servers/{id}/packages API endpoint issue a call to retrieve the full list of installed and available packages (software and patches) for a device.

Endpoint:

https://console.automox.com/api/servers/{server_id}/packages?o={organization_id}

Parameters:

You can find the parameters for the servers/{id}/packages API call by navigating to the Device Details page for the target device in question (for example, https://console.automox.com/device-detail?s=68439&o=6)

  • organization_id:  Is the o= parameter of the query string (o=6 above)

  • server_id: is the s= parameter of the query string  (s=68439 above)

Request:

curl -X GET --header 'Accept: application/json' 'https://console.automox.com/api/servers/68439/packages?o=6&api_key=YOUR_API_KEY'

Response:

This returns a JSON array of packages found and available for this device. To filter this JSON response, look for packages for which the installed attribute is false, such as the following excerpt from a servers/{id}/packages response:

[
 {
   "id": 617664440,
   "server_id": 68439,
   "package_id": 214744671,
   "installed": false,
   "ignored": false,
   "deferred_until": null,
   "name": "org.mozilla.firefox",
   "display_name": "Firefox",
   "version": "56.0.1",
   "repo": "Installed",
   "package_type_name": "other",
   "group_ignored": false,
   "group_deferred_until": null,
   "cves": null,
   "cve_score": null,
   "severity": "other",
   "package_version_id": 215219918,
   "os_name": "OS X",
   "os_version": "10.12.6",
   "create_time": "2017-10-10T01:51:28+0000",
   "requires_reboot": false,
   "os_classification": null,
   "is_uninstallable": false
 },...
]

Step 3 - Issue the API request to install a package

Referring to the example response from Step 2, we will issue an API request to the servers/{id}/queues API endpoint to have the Firefox update installed on this device:

Endpoint:

https://console.automox.com/api/servers/{server_id}/queues?o={organization_id}&api_key=YOUR_API_KEY

Parameters:

You can find the parameters for the servers/{id}/queues API call by navigating to the Device Details page for the target device in question (for example, https://console.automox.com/device-detail?s=68439&o=6)

  • organization_id:  Is the o= parameter of the query string (o=6 above)

  • server_id: is the s= parameter of the query string  (s=68439 above)

POST Data Parameters:

The following POST data parameters must be supplied in the request body as a JSON-formatted object:

  • command_type_name: ["InstallUpdate" | "Reboot"] - indicates the command you want to perform on the device. For this example, we  use "InstallUpdate".

args: ["\"org.mozilla.firefox\" \"com.google.Chrome\""] - A space-delimited list of packages you want to have installed on the device. The package names are derived from the name attribute of the response JSON in Step 2. Don't forget to escape the quotes if you're specifying multiple packages.

POST Data Example:

{ "command_type_name": "InstallUpdate", "args": "org.mozilla.firefox" }

Request:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ "command_type_name": "InstallUpdate", "args": "org.mozilla.firefox" } ' 'https://console.automox.com/api/servers/68439/queues?o=6&api_key=API_KEY'

Response:

A successful call to this API endpoint returns HTTP status code 201 - Created.

Was this article helpful?
0 out of 0 found this helpful