Getting started with Drata.com APIs
Tags: compliance, drata, iso27001, postman
Published: 2024-06-04 12:50:00

## Intro
Integrating Drata's compliance automation tool can significantly streamline your compliance processes. This tutorial will guide you through utilising Drata's APIs with Postman. We'll cover importing the Drata Postman collection, setting an environment and making an API call.

We won't cover first time installation of Postman or Drata, this doc will assume a basic understanding of the two.


{% embed https://youtu.be/sVSRQ9xx-Go %}


## Getting started

### Importing Postman Collection
We need to download the [Drata Postman Collection
](https://developers.drata.com/docs/openapi/reference/overview/) and following the documentation on Drata, to import the collection into Postman.

Click **Import**, select the **swagger.json** file you just downloaded, next make sure we click **View Import Settings**
![Importing the Postman Collection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81ajmpxcwpncprzf2q5c.png)

Under **Folder organization** click the drop down and select **Tags** (the default is likely set to Paths
![Changing Postman to Tags](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/80tiu0k8gk3ojfgy6fqc.png)


### Creating a new Postman Environment
Create a new environment in Postman
On the left hand navigation, select **Environments**, and at the top click **+** the plus
Add two new **Variables**
`baseUrl`
`bearerToken`

![Adding environment variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enp1m0yuhvazs4svra6r.png)

For the **baseUrl**, set the value depending on the location of your Drata instance ([reference documentation](https://developers.drata.com/docs/#base-url))


### Creating our Drata API token
We need to generate an API token within Drata and update the bearerToken in the Postman environment.
To do this, login to Drata and click **your name** at the bottom left corner and then click **Settings**

![Settings in Drata](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wr18fai7i31izagi1mqx.png)

Click **API Keys**

![Settings > API Keys](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k54kpzm9vw2uj6veh6gd.png)

Then we need to **Create API Key**
Follow the details on screen, including a Name, expiration and the scopes required.
Best practice is to limit the time of the token for how long you need it, limiting certain IP addresses to use the token and limiting the scope to what you need.

![Creating an API key in Drata](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ol7i7e2rz25632y7qkd4.png)


Take the API Key you are given and update the `bearerToken` value in the Postman environment. Don't forget to click **Save** for the Enviornment

It should now look something like:

![Setting environment variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0m3jx9ft96ax5po5onc3.png)


### Let's run a request!
Go to the collection, and let's run a basic request. Expand **Drata API Documentation > Personnel** and select **Get personnel by id**
Update the **:id** with a personnel ID (1 should be fine)

If you want to check what the `id` should be set to, you can open up the Drata app, go to **Personnel** and open the user, you'll find their ID in the URL bar.

![Personnel ID in Drata](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggp80s39r2ehabcbz8qq.png)


Make sure we have selected an Environment within Postman (top right corner) and click **Send**
![Successful Postman request](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5n8i3p79n1e90s9n7ogi.png)


🚀 Congratulations, we have now made an API call to Drata using Postman


## Recap
We have successfully setup the Drata Postman collection and are now able to make Postman requests against the Drata API.

What features of the Drata API would you like to know more about or see examples of?