Public API > API External Download.

Documentation Menu

API External Download

The purpose of this document is to demonstrate, how requests can be retrieved and approve from an external system. The goal is to empty the request queue on an interval and approve or deny requests that are already stored in the external system. The scenario could be to make a recurring job in ServiceNow and then add buttons on tickets to approve or deny requests.

The public REST API is explained here. The API exposes the same features as you can find in the portal and the mobile app. There are three areas: Auditlog, Requests, and Inventory.

Set up

The first step is to generate an API key. By default, your tenant data is not exposed to the public API. You have to generate a new key and use to get the data. Note that the API has brute force protections in place, so it’s safe to open the API. Once we have this key, we can make a call to the API using the API key as the “apikey” header. We will be using the free Postman ( ) to demonstrate the use. Here we have called the Auditlog API to get entries.


Getting Requests

Requests will appear in the “Requests” top menu in the portal as shown here:

To get a list of pending requests for approval, we need to call the Requests API indicating that we are only interested in “Pending” states. The URL is then (dc1api for Europe and dc2api for US tenants):
This will give us a list in json format with all the same information that is shown in the portal:

Approving Requests

Notice that each request has an “id” field. This field is used to perform an approve or deny request as explained in the this page. So all we have to do is to make a simple PUT request with the ID:

…and the request is now approved and the user is notified accordingly. It’s that simple!


Keeping State

So how do you only get new requests? The easiest way is to store the highest id you have received before and use this for the next calls. Here are the filters for the Requests API:

Let’s say the last request we received was 65430930. Then we add one (since we already received 65430930) and use as startid, meaning that we only want to see any requests with an id higher than 65430930: