Vendors
Vendors are various companies from whom you have purchased software or services that you use to run your business.
For example, Microsoft, Salesforce, and Okta are vendors. One Vendor can provide you with many Systems. For example, Microsoft is a vendor, and it provides you with many systems like Azure AD, Confluence, Office 365, etc.
TrustCloud allows you to manage your existing vendor relationships and consolidate any potential documents that you were keeping elsewhere.
In this guide, we will learn how to retrieve vendors from the TrustCloud API using REST calls, and then retrieve systems associated with a specific vendor.Â
Retrieving an API Key
To make requests to the TrustCloud API, an API key is required. To obtain an API key, follow the instructions in the Getting Started Guide to connect to the API. Â
Setting up the Request
Before we make any requests, we need to set up our HTTP headers. We need to include the API key in the “Authorization” header, and set the “x-trustcloud-api-version” header to 1 to ensure we are using the correct API version.
Here is an example of the headers we need to include in our HTTP request:
const headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
};
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
HttpGet request = new HttpGet("https://api.trustcloud.ai/vendors");
request.setHeader("Authorization", "");
request.setHeader("x-trustcloud-api-version", "1");
using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;
string apiKey = "";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";
import requests
headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
}
package main
import (
"encoding/json"
"fmt"
"net/http"
)
apiKey := ""
url := "https://api.trustcloud.ai/vendors"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
GET /vendors HTTP/1.1
Host: api.trustcloud.ai
Authorization: Bearer
x-trustcloud-api-version: 1
Retrieving All Vendors
To retrieve a list of all vendors, make a GET request to the /vendors endpoint using the headers set up in Step 2.
import axios from 'axios';
const headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
};
axios.get('https://api.trustcloud.ai/vendors, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
HttpGet request = new HttpGet("https://api.trustcloud.ai/vendors");
request.setHeader("Authorization", "");
request.setHeader("x-trustcloud-api-version", "1");
HttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = client.execute(request);
try {
String responseBody = EntityUtils.toString(response.getEntity());
System.out.println(responseBody);
} finally {
response.close();
}
using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;
string apiKey = "";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";
var client = new RestClient(baseUrl);
var request = new RestRequest("/vendors", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
IRestResponse response = client.Execute(request);
if (response.IsSuccessful)
{
Console.WriteLine(response.Content);
}
else
{
Console.WriteLine("Error: " + response.Content);
}
import requests
headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
}
response = requests.get('https://api.trustcloud.ai/vendors, headers=headers)
if response.status_code == 200:
vendors = response.json()
print(vendors)
else:
print('Error retrieving Vendors:', response.text)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
apiKey := ""
url := "https://api.trustcloud.ai/vendors"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
var data []interface{}
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%+v\n", data)
GET /vendors HTTP/1.1
Host: api.trustcloud.ai
Authorization: Bearer
x-trustcloud-api-version: 1
Here is an example of the response we might receive:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1234
[
{
"id": "501995bb-61eb-4e0f-bf20-e42ca23c93d8",
"name": "Salesforce",
"catalogVendorId": "681a0c8d-4397-4a4a-a821-9c012063806f",
"purpose": null,
"vendorLocations": {},
"classification": [
null
],
"logoUrl": null,
"tags": [
"cmmc",
"BU1",
"CRM Application"
],
"isSubprocessor": false,
"vendorPrivacyPolicyUrl": null,
"vendorSecurityPageUrl": null,
"vendorTosUrl": null,
"groupId": "ee72eb8b-f338-492e-8c2f-a0a8dbbfd01d",
"groupName": "Sales and Marketing",
"owner": {
"id": "7531ed17-aad1-4204-a6f8-3d33373f1060",
"name": "Zola Rameckersm"
},
"_metadata": {
"createdBy": "e4362dc1-40c9-456d-bfbe-b4f2450b3d88",
"createdDate": "2021-05-18 20:17:29.623701+00",
"lastModifiedBy": "e4362dc1-40c9-456d-bfbe-b4f2450b3d88",
"lastModifiedDate": "2023-05-03 03:13:56.314+00"
}
},...
]
Retrieving a Single Vendor
To retrieve a single vendor, include the vendor ID in the URL by appending the ID to the /vendors endpoint. In this example, we will retrieve the vendor with ID
501995bb-61eb-4e0f-bf20-e42ca23c93d8:
import axios from 'axios';
const headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
};
const id = '501995bb-61eb-4e0f-bf20-e42ca23c93d8'; // Replace with the ID of the vendor you want to retrieve
axios.get(`https://api.trustcloud.ai/vendors/${id}`, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
HttpGet request = new HttpGet("https://api.trustcloud.ai/vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8");
request.setHeader("Authorization", "");
request.setHeader("x-trustcloud-api-version", "1");
HttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = client.execute(request);
try {
String responseBody = EntityUtils.toString(response.getEntity());
System.out.println(responseBody);
} finally {
response.close();
}
using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;
string apiKey = "";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";
var client = new RestClient(baseUrl);
var request = new RestRequest("/vendors/{id}", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
request.AddUrlSegment("id", "501995bb-61eb-4e0f-bf20-e42ca23c93d8");
IRestResponse response = client.Execute(request);
if (response.IsSuccessful)
{
Console.WriteLine(response.Content);
}
else
{
Console.WriteLine("Error: " + response.Content);
}
import requests
headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
}
response = requests.get('https://api.trustcloud.ai/vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8', headers=headers)
if response.status_code == 200:
vendor = response.json()
print(vendor)
else:
print('Error retrieving System:', response.text)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
apiKey := ""
url := "https://api.trustcloud.ai/vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
var data map[string]interface{}
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%+v\n", data)
GET /vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8 HTTP/1.1
Host: API.trustcloud.ai
Authorization:
x-trustcloud-api-version: 1
Here is an example of the response we might receive:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 234
{
"id": "501995bb-61eb-4e0f-bf20-e42ca23c93d8",
"name": "Salesforce",
"catalogVendorId": "681a0c8d-4397-4a4a-a821-9c012063806f",
"purpose": null,
"vendorLocations": {},
"classification": [
null
],
"logoUrl": null,
"tags": [
"cmmc",
"BU1",
"CRM Application"
],
"isSubprocessor": false,
"vendorPrivacyPolicyUrl": null,
"vendorSecurityPageUrl": null,
"vendorTosUrl": null,
"groupId": "ee72eb8b-f338-492e-8c2f-a0a8dbbfd01d",
"groupName": "Sales and Marketing",
"owner": {
"id": "7531ed17-aad1-4204-a6f8-3d33373f1060",
"name": "Zola Rameckersm"
},
"_metadata": {
"createdBy": "e4362dc1-40c9-456d-bfbe-b4f2450b3d88",
"createdDate": "2021-05-18 20:17:29.623701+00",
"lastModifiedBy": "e4362dc1-40c9-456d-bfbe-b4f2450b3d88",
"lastModifiedDate": "2023-05-03 03:13:56.314+00"
}
}
Retrieving systems associated with a vendor
To retrieve systems associated with a single vendor, append /systems to the single vendor endpoint. Â In this example, we will retrieve systems associated with the vendor with ID
501995bb-61eb-4e0f-bf20-e42ca23c93d8:
import axios from 'axios';
const headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
};
const id = '501995bb-61eb-4e0f-bf20-e42ca23c93d8'; // Replace with the ID of the Vendor you want to retrieve
axios.get(`https://api.trustcloud.ai/vendors/${id}/systems`, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
HttpGet request = new HttpGet("https://api.trustcloud.ai/vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8/systems");
request.setHeader("Authorization", "");
request.setHeader("x-trustcloud-api-version", "1");
HttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = client.execute(request);
try {
String responseBody = EntityUtils.toString(response.getEntity());
System.out.println(responseBody);
} finally {
response.close();
}
using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;
string apiKey = "";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";
var client = new RestClient(baseUrl);
var request = new RestRequest("/vendors/{id}/systems", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
request.AddUrlSegment("id", "501995bb-61eb-4e0f-bf20-e42ca23c93d8");
IRestResponse response = client.Execute(request);
if (response.IsSuccessful)
{
Console.WriteLine(response.Content);
}
else
{
Console.WriteLine("Error: " + response.Content);
}
import requests
headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
}
response = requests.get('https://api.trustcloud.ai/vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8/systems, headers=headers)
if response.status_code == 200:
system = response.json()
print(system)
else:
print('Error retrieving systems:', response.text)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
apiKey := ""
url := "https://api.trustcloud.ai/vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8/systems"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
var data map[string]interface{}
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%+v\n", data)
GET /vendors/501995bb-61eb-4e0f-bf20-e42ca23c93d8/systems HTTP/1.1
Host: API.trustcloud.ai
Authorization:
x-trustcloud-api-version: 1
Here is an example of the response we might receive:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 234
[
{
"id": "efd09275-8de7-4ef6-8b89-76ee1b382271",
"name": "Pardot",
"systemId": "pardot",
"purpose": "Marketing",
"riskScore": "100.00",
"_metadata": {
"createdBy": "9f72fa4b-8f83-4072-b8e4-537410edcd12",
"createdDate": "2021-12-22 19:49:58.459+00",
"lastModifiedBy": "9f72fa4b-8f83-4072-b8e4-537410edcd12",
"lastModifiedDate": "2021-12-22 19:50:21.433+00"
},
"owner": {
"name": "Reilly Marchand",
"id": "f1c28644-9ae5-4c13-b79e-b65b53ad5181"
},
"group": {
"id": "950cea2e-caf7-4052-9359-ebac23f92b82",
"name": "Sales and Marketing"
},
"provider": {
"id": "4866e085-7eb1-4406-a099-052dcea4604e",
"name": "Salesforce"
}
},...
]
Paging
If there are a large number of vendors in a response, it is recommended to use paging to retrieve them in batches. To do this, we can use the limit and page query parameters.
The limit parameter specifies the number of records to retrieve in each page. The default value is 100, but we can set it to any value up to 1000.
The page parameter specifies which page to retrieve. The first page is page 1.
For example, to retrieve the first 10 vendors:
import axios from 'axios';
const headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
};
const limit = 10; // The number of Vendors to retrieve per page
const page = 1; // The page number to retrieve (starts at 1)
axios.get('https://api.trustcloud.ai/vendors, {
headers,
params: {
limit,
page,
}
})
.then(response => {
console.log(response.data);
console.log(response.headers.link); // log link header
})
.catch(error => {
console.log(error);
});
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
HttpGet request = new HttpGet("https://api.trustcloud.ai/vendors?limit=10&page=1");
request.setHeader("Authorization", "");
request.setHeader("x-trustcloud-api-version", "1");
HttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = client.execute(request);
try {
String responseBody = EntityUtils.toString(response.getEntity());
System.out.println(responseBody);
} finally {
response.close();
}
using System;
using System.Collections.Generic;
string apiKey = "";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";
var client = new RestClient(baseUrl);
var request = new RestRequest("/vendors", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
request.AddParameter("limit", 50);
request.AddParameter("page", 1);
IRestResponse response = client.Execute(request);
if (response.IsSuccessful)
{
Console.WriteLine(response.Content);
}
else
{
Console.WriteLine("Error: " + response.Content);
}
import requests
headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
}
response = requests.get('https://api.trustcloud.ai/vendors?limit=10&page=1', headers=headers', headers=headers)
if response.status_code == 200:
system = response.json()
print(system)
else:
print('Error retrieving vendors:', response.text)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
apiKey := ""
url := "https://api.trustcloud.ai/vendors?page=1&limit=10"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
var data []interface{}
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%+v\n", data)
GET /vendors?limit=10&page=1 HTTP/1.1
Host: API.trustcloud.ai
Authorization:
x-trustcloud-api-version: 1
To retrieve the next set of vendors, you can obtain the next URL from the link response header, or manually increment the page number. If link is null, that means there are no more pages.
import axios from 'axios';
const headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
};
const limit = 10; // The number of Vendors to retrieve per page
const page = 1; // The page number to retrieve (starts at 1)
axios.get('https://api.trustcloud.ai/vendors, {
headers,
params: {
limit,
page,
}
})
.then(response => {
console.log(response.data);
console.log(response.headers.link); // log link header
})
.catch(error => {
console.log(error);
});
String linkHeader = response.getFirstHeader("link").getValue();
String nextPageUrl = linkHeader.split(";")[0].replace("<", "").replace(">", "");
HttpGet nextPageRequest = new HttpGet(nextPageUrl);
nextPageRequest.setHeader("Authorization", "");
nextPageRequest.setHeader("x-trustcloud-api-version", "1");
using System;
using System.Collections.Generic;
string apiKey = "";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";
var client = new RestClient(baseUrl);
var request = new RestRequest("/vendors", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
request.AddParameter("limit", 50);
request.AddParameter("page", 1);
IRestResponse response = client.Execute(request);
if (response.IsSuccessful)
{
Console.WriteLine(response.Content);
// retrieve next page
var nextPageUrl = response.Headers.FirstOrDefault(x => x.Name == "Link")?.Value?.Split(';')[0]?.Trim('<', '>');
if (!string.IsNullOrEmpty(nextPageUrl))
{
var nextPageRequest = new RestRequest(nextPageUrl, Method.GET);
nextPageRequest.AddHeader("Authorization", apiKey);
nextPageRequest.AddHeader("x-trustcloud-api-version", apiVersion);
IRestResponse nextPageResponse = client.Execute(nextPageRequest);
if (nextPageResponse.IsSuccessful)
{
Console.WriteLine(nextPageResponse.Content);
}
else
{
Console.WriteLine("Error retrieving next page: " + nextPageResponse.Content);
import requests
import re
headers = {
'Authorization': '',
'x-trustcloud-api-version': '1'
}
response = requests.get('https://api.trustcloud.ai/vendors?limit=10&page=1', headers=headers)
if response.status_code == 200:
vendors = response.json()
print(vendors)
link_header = response.headers.get('link')
if link_header:
nextPage = re.search('<(.+)>', link_header)
else:
print('Error retrieving Vendors:', response.text)
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
)
func main() {
apiKey := ""
url := "https://api.trustcloud.ai/vendors"
// Create a new HTTP client
client := &http.Client{}
// Create a new HTTP request
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
// Add the API key and version headers
req.Header.Set("Authorization", apiKey)
req.Header.Set("x-trustcloud-api-version", "1")
// Add the page and limit parameters
q := req.URL.Query()
q.Add("page", "1")
q.Add("limit", "10")
req.URL.RawQuery = q.Encode()
// Make the API call
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
// Check the response status code
if resp.StatusCode != http.StatusOK {
log.Fatal(resp.Status)
}
// Parse the link header to get the URL for the next page
linkHeader := resp.Header.Get("Link")
nextPageURL := ""
if linkHeader != "" {
links := strings.Split(linkHeader, ",")
for _, link := range links {
if strings.Contains(link, "rel=\"next\"") {
parts := strings.Split(link, ";")
if len(parts) > 0 {
nextPageURL = strings.Trim(parts[0], "<>")
}
}
}
}
// Read the response body
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
// Print the response body
fmt.Println(string(body))
// Make the API call for the next page if it exists
if nextPageURL != "" {
// Create a new HTTP request for the next page
nextPageReq, err := http.NewRequest("GET", nextPageURL, nil)
if err != nil {
log.Fatal(err)
}
// Add the API key and version headers to the next page request
nextPageReq.Header.Set("Authorization", apiKey)
nextPageReq.Header.Set("x-trustcloud-api-version", "1")
// Make the next page API call
nextPageResp, err := client.Do(nextPageReq)
if err != nil {
log.Fatal(err)
}
defer nextPageResp.Body.Close()
// Check the response status code for the next page
if nextPageResp.StatusCode != http.StatusOK {
log.Fatal(nextPageResp.Status)
}
// Read the response body for the next page
nextPageBody, err := ioutil.ReadAll(nextPageResp.Body)
if err != nil {
log.Fatal(err)
}
// Print the response body for the next page
fmt.Println(string(nextPageBody))
}
}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 234
link: ; rel="next"
GET /vendors?pag2&limit=10 HTTP/1.1
Host: API.trustcloud.ai
Authorization:
x-trustcloud-api-version: 1