API: Retrieving and Installing Updates

Follow

You can use the Automox REST API to programmatically retrieve and install updates. This article will describe how to do this and will reference our API documentation.

Step 1 - Get your API Key

The API key for your account is located on the settings page of the console at the bottom of the page. 

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 endpoint detail page for the target device in question (i.e. https://console.automox.com/endpoint-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 will return a JSON array of packages found and available for this device. You'll want to filter this JSON response by looking for packages where 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 two above, 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 endpoint detail page for the target device in question (i.e. https://console.automox.com/endpoint-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 wish to perform on the device. For this example, we will be using "InstallUpdate"

args: ["\"org.mozilla.firefox\" \"com.google.Chrome\""] - A space-delimited list of packages you'd like to have installed on the endpoint. The package names are derived from the name attribute of the response JSON in step two. 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 will return HTTP status code 201 - Created

Have more questions? Submit a request

0 Comments

Article is closed for comments.