Tests and Evidence

Estimated reading: 6 minutes 520 views

Tests are a means of validating a control.  A number of tests are automated by TrustCloud via integrations to various systems.  Tests that are not automated and require manual completion are called self-assessment tests.  These tests require an attestation of control adherence (via a yes/no answer and a description), and supplied evidence to demonstrate the validity of the attestation.  

Self-assessment tests can be automated via the TrustCloud API.  The TrustCloud API provides the ability retrieve and view self-assessment tests, find tests where evidence is due, and submit evidence and execute the test.  

In this guide, we will learn how to retrieve the self-assessment tests, submit evidence, and complete a self-assessment test.  

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:

Javascript
				
					const headers = {
  'Authorization': '<your_api_key_here>',
  'x-trustcloud-api-version': '1'
};

				
			
Java
				
					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/tests");
request.setHeader("Authorization", "<your_api_key_here>");
request.setHeader("x-trustcloud-api-version", "1");

				
			
Csharp
				
					using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;

string apiKey = "<your_api_key_here>";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";

				
			
Python
				
					import requests
headers = {
   'Authorization': '<your_api_key_here>',
   'x-trustcloud-api-version': '1'
}

				
			
Go
				
					package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

apiKey := "<your_api_key_here>"
url := "https://api.trustcloud.ai/tests"

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")

				
			
Bash
				
					GET /tests HTTP/1.1
Host: api.trustcloud.ai
Authorization: Bearer <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Retrieving All Tests

To retrieve a list of all tests, make a GET request to the /tests endpoint using the headers set up in Step 2.

Javascript
				
					import axios from 'axios';

const headers = {
  'Authorization': '<your_api_key_here>',
  'x-trustcloud-api-version': '1'
};

axios.get('https://api.trustcloud.ai/tests, { headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });

				
			
Java
				
					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/tests");
request.setHeader("Authorization", "<your_api_key_here>");
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();
}

				
			
Csharp
				
					using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;

string apiKey = "<your_api_key_here>";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";

var client = new RestClient(baseUrl);
var request = new RestRequest("/tests", 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);
}

				
			
Python
				
					import requests
headers = {
   'Authorization': '<your_api_key_here>',
   'x-trustcloud-api-version': '1'
}

response = requests.get('https://api.trustcloud.ai/tests, headers=headers)
if response.status_code == 200:
   test = response.json()
   print(test)
else:
   print('Error retrieving Tests:', response.text)

				
			
Go
				
					package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

apiKey := "<your_api_key_here>"
url := "https://api.trustcloud.ai/tests"

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)

				
			
Bash
				
					GET /tests HTTP/1.1
Host: api.trustcloud.ai
Authorization: Bearer <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Here is an example of the response we might receive:

Html
				
					HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1234

				
			
Html
				
					[  
  {
    "id": "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f",
    "testId": "change-management",
    "type": "self_assessment",
    "name": "Change management workflow",
    "level": "basic",
    "question": "Do you have a documented change management process outlining the workflow for propagating application and infrastructure code changes to production environments, including tracking, testing, review, and approval?",
    "recommendation": "Document your change management process, outlining the workflow for propagating application and infrastructure code changes to the production environment. Including information about tracking, testing, review, and approval processes.",
    "evidenceCount": {},
    "evidenceDescription": "Your change management, release management, or software development life cycle process documentation, outlining the workflows for propagating application and infrastructure code changes to production environments, including tracking, testing, review and approval",
    "evidenceStatus": "missing",
    "executionOutcome": {},
    "executionSatus": {},
    "nextEvidenceDueDate": {},
    "owner": {
      "name": {},
      "id": {}
    },
    "control": {
      "id": "cd2d4fe0-187f-4126-9cdb-edb9867b8040",
      "controlId": "PDP-11",
      "name": "Product Delivery Process",
      "category": "Change Management Workflow"
    },
    "system": {
      "id": {},
      "name": {}
    },
    "metadata": {
      "createdby": "59246246-ed25-48a8-ae5e-67732c6ee332",
      "createddate": "2022-02-15 17:14:28.757+00",
      "lastmodifiedby": "0ef2f025-46df-47d0-8bcd-11f62aa10612",
      "lastmodifieddate": "2023-02-20 16:16:07.316+00"
    },
  },...
]

				
			

Filtering Tests

Various filters can be applied to retrieve only a subset of tests based on its evidence status.

 

Filter

Valid values

Description

evidenceStatus

·       missing

·       outdated

·       due

·       up_to_date

·       not_required

Filters tests based on the current evidence status of the test.

testStatus

·       available

·       In_progress

·       excluded

Filters tests based on the current test state

evidenceDueByDate

Valid date in YYYY-MM-DD format

Returns tests that have current evidence due by the supplied date

evidenceDueByDays

Integer

Returns tests that have evidence due within the next x days

name

string

The name or partial name of a test or tests

Filtering tests based on evidence status

Javascript
				
					const axios = require('axios');

const apiKey = '<your_api_key_here>';
const url = 'https://api.trustcloud.ai/tests?evidenceStatus=due';

axios.get(url, {
  headers: {
    'Authorization': apiKey,
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});



				
			
Java
				
					import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

public class TrustCloud {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        URL url = new URL("https://api.trustcloud.ai/tests?evidenceStatus=due");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Authorization", apiKey);
        connection.setRequestProperty("x-trustcloud-api-version", "1");

        Scanner scanner = new Scanner(connection.getInputStream());
        while (scanner.hasNext()) {
            System.out.println(scanner.nextLine());
        }
        scanner.close();
    }
}

				
			
Csharp
				
					using System;
using System.Net.Http;
using System.Threading.Tasks;

class TrustCloud {
    static async Task Main(string[] args) {
        string apiKey = "<your_api_key_here>";
        string url = "https://api.trustcloud.ai/tests?evidenceStatus=due";
        
        using (HttpClient client = new HttpClient()) {
            client.DefaultRequestHeaders.Add("Authorization", apiKey);
            client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

            HttpResponseMessage response = await client.GetAsync(url);
            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
    }
}

				
			
Python
				
					import requests

api_key = '<your_api_key_here>'
url = 'https://api.trustcloud.ai/tests?evidenceStatus=due'

headers = {
    'Authorization': api_key,
    'x-trustcloud-api-version': '1'
}

response = requests.get(url, headers=headers)
print(response.json())

				
			
Go
				
					package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	apiKey := "<your_api_key_here>"
	url := "https://api.trustcloud.ai/tests?evidenceStatus=due"

	client := &http.Client{}
	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("Authorization", apiKey)
	req.Header.Add("x-trustcloud-api-version", "1")

	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

				
			
Bash
				
					GET /tests?evidenceStatus=due HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Filtering tests based on test status

Javascript
				
					const axios = require('axios');

const apiKey = '<your_api_key_here>';
const url = 'https://api.trustcloud.ai/tests?testStatus=available;

axios.get(url, {
  headers: {
    'Authorization': apiKey,
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});



				
			
Java
				
					import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

public class TrustCloud {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        URL url = new URL("https://api.trustcloud.ai/tests?testStatus=available");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Authorization", apiKey);
        connection.setRequestProperty("x-trustcloud-api-version", "1");

        Scanner scanner = new Scanner(connection.getInputStream());
        while (scanner.hasNext()) {
            System.out.println(scanner.nextLine());
        }
        scanner.close();
    }
}

				
			
Csharp
				
					using System;
using System.Net.Http;
using System.Threading.Tasks;

class TrustCloud {
    static async Task Main(string[] args) {
        string apiKey = "<your_api_key_here>";
        string url = "https://api.trustcloud.ai/tests?testStatus=available";
        
        using (HttpClient client = new HttpClient()) {
            client.DefaultRequestHeaders.Add("Authorization", apiKey);
            client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

            HttpResponseMessage response = await client.GetAsync(url);
            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
    }
}

				
			
Python
				
					import requests

api_key = '<your_api_key_here>'
url = 'https://api.trustcloud.ai/tests?testStatus=available

headers = {
    'Authorization': api_key,
    'x-trustcloud-api-version': '1'
}

response = requests.get(url, headers=headers)
print(response.json())

				
			
Go
				
					package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	apiKey := "<your_api_key_here>"
	url := "https://api.trustcloud.ai/tests?testStatus=available"

	client := &http.Client{}
	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("Authorization", apiKey)
	req.Header.Add("x-trustcloud-api-version", "1")

	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

				
			
Bash
				
					GET /tests?testStatus=available HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Filtering tests based on evidence due by date

Javascript
				
					const axios = require('axios');

const apiKey = '<your_api_key_here>';
const url = 'https://api.trustcloud.ai/tests?evidenceDueByDate=2023-01-01';

axios.get(url, {
  headers: {
    'Authorization': apiKey,
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});



				
			
Java
				
					import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

public class TrustCloud {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        URL url = new URL("https://api.trustcloud.ai/tests?evidenceDueByDate=2023-01-01");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Authorization", apiKey);
        connection.setRequestProperty("x-trustcloud-api-version", "1");

        Scanner scanner = new Scanner(connection.getInputStream());
        while (scanner.hasNext()) {
            System.out.println(scanner.nextLine());
        }
        scanner.close();
    }
}

				
			
Csharp
				
					using System;
using System.Net.Http;
using System.Threading.Tasks;

class TrustCloud {
    static async Task Main(string[] args) {
        string apiKey = "<your_api_key_here>";
        string url = "https://api.trustcloud.ai/tests?evidenceDueByDate=2023-01-01";
        
        using (HttpClient client = new HttpClient()) {
            client.DefaultRequestHeaders.Add("Authorization", apiKey);
            client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

            HttpResponseMessage response = await client.GetAsync(url);
            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
    }
}

				
			
Python
				
					import requests

api_key = '<your_api_key_here>'
url = 'https://api.trustcloud.ai/tests?evidenceDueByDate=2023-01-01'

headers = {
    'Authorization': api_key,
    'x-trustcloud-api-version': '1'
}

response = requests.get(url, headers=headers)
print(response.json())

				
			
Go
				
					package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	apiKey := "<your_api_key_here>"
	url := "https://api.trustcloud.ai/tests?evidenceDueByDate=2023-01-01"

	client := &http.Client{}
	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("Authorization", apiKey)
	req.Header.Add("x-trustcloud-api-version", "1")

	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

				
			
Bash
				
					GET /tests?evidenceDueByDate=2023-01-01 HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Filtering tests based on evidence due within x days

Javascript
				
					const axios = require('axios');

const apiKey = '<your_api_key_here>';
const url = 'https://api.trustcloud.ai/tests?evidenceDueBydays=30';

axios.get(url, {
  headers: {
    'Authorization': apiKey,
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});



				
			
Java
				
					import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

public class TrustCloud {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        URL url = new URL("https://api.trustcloud.ai/tests?evidenceDueByDays=30");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Authorization", apiKey);
        connection.setRequestProperty("x-trustcloud-api-version", "1");

        Scanner scanner = new Scanner(connection.getInputStream());
        while (scanner.hasNext()) {
            System.out.println(scanner.nextLine());
        }
        scanner.close();
    }
}

				
			
Csharp
				
					using System;
using System.Net.Http;
using System.Threading.Tasks;

class TrustCloud {
    static async Task Main(string[] args) {
        string apiKey = "<your_api_key_here>";
        string url = "https://api.trustcloud.ai/tests?evidenceDueByDays=30";
        
        using (HttpClient client = new HttpClient()) {
            client.DefaultRequestHeaders.Add("Authorization", apiKey);
            client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

            HttpResponseMessage response = await client.GetAsync(url);
            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
    }
}

				
			
Python
				
					import requests

api_key = '<your_api_key_here>'
url = 'https://api.trustcloud.ai/tests?evidenceDueByDays=30'

headers = {
    'Authorization': api_key,
    'x-trustcloud-api-version': '1'
}

response = requests.get(url, headers=headers)
print(response.json())

				
			
Go
				
					package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	apiKey := "<your_api_key_here>"
	url := "https://api.trustcloud.ai/tests?evidenceDueByDays=30"

	client := &http.Client{}
	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("Authorization", apiKey)
	req.Header.Add("x-trustcloud-api-version", "1")

	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

				
			
Bash
				
					GET /tests?evidenceDueByDays=30 HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Retrieving a test by name

Javascript
				
					const axios = require('axios');

const apiKey = '<your_api_key_here>';
const url = 'https://api.trustcloud.ai/tests?name=Multi-factor';

axios.get(url, {
  headers: {
    'Authorization': apiKey,
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});



				
			
Java
				
					import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

public class TrustCloud {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        URL url = new URL("https://api.trustcloud.ai/tests?name=Multi-factor");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Authorization", apiKey);
        connection.setRequestProperty("x-trustcloud-api-version", "1");

        Scanner scanner = new Scanner(connection.getInputStream());
        while (scanner.hasNext()) {
            System.out.println(scanner.nextLine());
        }
        scanner.close();
    }
}

				
			
Csharp
				
					using System;
using System.Net.Http;
using System.Threading.Tasks;

class TrustCloud {
    static async Task Main(string[] args) {
        string apiKey = "<your_api_key_here>";
        string url = "https://api.trustcloud.ai/tests?name=Multi-factor";
        
        using (HttpClient client = new HttpClient()) {
            client.DefaultRequestHeaders.Add("Authorization", apiKey);
            client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

            HttpResponseMessage response = await client.GetAsync(url);
            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
    }
}

				
			
Python
				
					import requests

api_key = '<your_api_key_here>'
url = 'https://api.trustcloud.ai/tests?name=Multi-factor'

headers = {
    'Authorization': api_key,
    'x-trustcloud-api-version': '1'
}

response = requests.get(url, headers=headers)
print(response.json())

				
			
Go
				
					package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	apiKey := "<your_api_key_here>"
	url := "https://api.trustcloud.ai/tests?name=Multi-factor"

	client := &http.Client{}
	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("Authorization", apiKey)
	req.Header.Add("x-trustcloud-api-version", "1")

	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

				
			
Bash
				
					GET /tests?name=Multi-factor HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Retrieving a Single Test

Javascript
				
					import axios from 'axios';

const headers = {
  'Authorization': '<your_api_key_here>',
  'x-trustcloud-api-version': '1'
};

const id = 'c6354cde-3a4e-4b35-8bfd-aafb33a9f44f'; // Replace with the ID of the Test you want to retrieve

axios.get(`https://api.trustcloud.ai/tests/${id}`, { headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });

				
			
Java
				
					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/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f");
request.setHeader("Authorization", "<your_api_key_here>");
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();
}

				
			
Csharp
				
					using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;

string apiKey = "<your_api_key_here>";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";

var client = new RestClient(baseUrl);
var request = new RestRequest("/tests/{id}", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
request.AddUrlSegment("id", "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f");

IRestResponse response = client.Execute(request);

if (response.IsSuccessful)
{
    Console.WriteLine(response.Content);
}
else
{
    Console.WriteLine("Error: " + response.Content);
}

				
			
Python
				
					import requests
headers = {
   'Authorization': '<your_api_key_here>',
   'x-trustcloud-api-version': '1'
}

response = requests.get('https://api.trustcloud.ai/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f', headers=headers)
if response.status_code == 200:
   test = response.json()
   print(test)
else:
   print('Error retrieving System:', response.text)

				
			
Go
				
					package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

apiKey := "<your_api_key_here>"
url := "https://api.trustcloud.ai/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f"

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)

				
			
Bash
				
					GET /tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f HTTP/1.1
Host: API.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Here is an example of the response we might receive:

Html
				
					HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 234

				
			
Html
				
					{
  "id": "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f",
  "testId": "change-management",
  "type": "self_assessment",
  "name": "Change management workflow",
  "level": "basic",
  "question": "Do you have a documented change management process outlining the workflow for propagating application and infrastructure code changes to production environments, including tracking, testing, review, and approval?",
  "recommendation": "Document your change management process, outlining the workflow for propagating application and infrastructure code changes to the production environment. Including information about tracking, testing, review, and approval processes.",
  "evidenceCount": {},
  "evidenceDescription": "Your change management, release management, or software development life cycle process documentation, outlining the workflows for propagating application and infrastructure code changes to production environments, including tracking, testing, review and approval",
  "evidenceStatus": "missing",
  "executionOutcome": {},
  "executionSatus": {},
  "nextEvidenceDueDate": {},
  "owner": {
    "name": {},
    "id": {}
  },
  "control": {
    "id": "cd2d4fe0-187f-4126-9cdb-edb9867b8040",
    "controlId": "PDP-11",
    "name": "Product Delivery Process",
    "category": "Change Management Workflow"
  },
  "system": {
    "id": {},
    "name": {}
  },
  "metadata": {
    "createdby": "59246246-ed25-48a8-ae5e-67732c6ee332",
    "createddate": "2022-02-15 17:14:28.757+00",
    "lastmodifiedby": "0ef2f025-46df-47d0-8bcd-11f62aa10612",
    "lastmodifieddate": "2023-02-20 16:16:07.316+00"
  },
}

				
			

Retrieving test history

To retrieve the history of test executions for a specific test, append /history to the single test endpoint.   In this example, we will retrieve the history of the test with ID

c6354cde-3a4e-4b35-8bfd-aafb33a9f44f:

Javascript
				
					import axios from 'axios';

const headers = {
  'Authorization': '<your_api_key_here>',
  'x-trustcloud-api-version': '1'
};

const id = 'c6354cde-3a4e-4b35-8bfd-aafb33a9f44f'; // Replace with the ID of the Test you want to retrieve

axios.get(`https://api.trustcloud.ai/tests/${id}/history`, { headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });

				
			
Java
				
					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/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/history");
request.setHeader("Authorization", "<your_api_key_here>");
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();
}

				
			
Csharp
				
					using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;

string apiKey = "<your_api_key_here>";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";

var client = new RestClient(baseUrl);
var request = new RestRequest("/tests/{id}/history", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
request.AddUrlSegment("id", "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f");

IRestResponse response = client.Execute(request);

if (response.IsSuccessful)
{
    Console.WriteLine(response.Content);
}
else
{
    Console.WriteLine("Error: " + response.Content);
}

				
			
Python
				
					import requests
headers = {
   'Authorization': '<your_api_key_here>',
   'x-trustcloud-api-version': '1'
}

response = requests.get('https://api.trustcloud.ai/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/history', headers=headers)
if response.status_code == 200:
   test = response.json()
   print(test)
else:
   print('Error retrieving System:', response.text)

				
			
Go
				
					package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

apiKey := "<your_api_key_here>"
url := "https://api.trustcloud.ai/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/history"

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)

				
			
Bash
				
					GET /tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/history HTTP/1.1
Host: API.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Here is an example of the response we might receive:

Html
				
					HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 234

				
			
Html
				
					[
  {
    "id": "4dec2cb5-5147-4fc0-a75c-6add7ed6d0fd",
    "testId": "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f",
    "description": "contains link\n",
    "type": "link",
    "evidenceDate": "2023-05-18",
    "_metadata": {
      "name": "Liam Boyle",
      "email": "Liam_Boyle4012@jcf8v.app",
      "id": "98be43e3-bcbb-4ff0-827a-bbbea8df619c"
    }
  }...,
]

				
			

Retrieving evidence history

To retrieve the history of evidence for a specific test, append /evidence to the single test endpoint.   In this example, we will retrieve the evidence history of the test with ID

c6354cde-3a4e-4b35-8bfd-aafb33a9f44f:

Javascript
				
					import axios from 'axios';

const headers = {
  'Authorization': '<your_api_key_here>',
  'x-trustcloud-api-version': '1'
};

const id = 'c6354cde-3a4e-4b35-8bfd-aafb33a9f44f'; // Replace with the ID of the Test you want to retrieve

axios.get(`https://api.trustcloud.ai/tests/${id}/evidence`, { headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });

				
			
Java
				
					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/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/evidence");
request.setHeader("Authorization", "<your_api_key_here>");
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();
}

				
			
Csharp
				
					using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;

string apiKey = "<your_api_key_here>";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";

var client = new RestClient(baseUrl);
var request = new RestRequest("/tests/{id}/evidence", Method.GET);
request.AddHeader("Authorization", apiKey);
request.AddHeader("x-trustcloud-api-version", apiVersion);
request.AddUrlSegment("id", "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f");

IRestResponse response = client.Execute(request);

if (response.IsSuccessful)
{
    Console.WriteLine(response.Content);
}
else
{
    Console.WriteLine("Error: " + response.Content);
}

				
			
Python
				
					import requests
headers = {
   'Authorization': '<your_api_key_here>',
   'x-trustcloud-api-version': '1'
}

response = requests.get('https://api.trustcloud.ai/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/evidence, headers=headers)
if response.status_code == 200:
   test = response.json()
   print(test)
else:
   print('Error retrieving System:', response.text)

				
			
Go
				
					package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

apiKey := "<your_api_key_here>"
url := "https://api.trustcloud.ai/tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/evidence"

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)

				
			
Bash
				
					GET /tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/evidence HTTP/1.1
Host: API.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

Here is an example of the response we might receive:

Html
				
					HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 234

				
			
Html
				
					[
  {
    "id": "2ea585b7-ef32-40ec-817b-4bafa6e50c08",
    "testId": "cba9989c-94e3-40a4-9bb9-9cb4344e392f",
    "description": "contains link\n",
    "type": "link",
    "evidenceDate": "2023-05-18",
    "_metadata": {
      "name": "Jane Ripley",
      "email": "Jane_Ripley7853@voylg.biz",
      "id": "72bda9e5-8dd5-4677-b664-a3c27b9beaee"
    }
  }...,
]

				
			

Submitting Evidence

To add evidence to a test, you can submit a POST request to the the /test/{id}/evidence endpoint.  There are two types of evidence – links and files.  

Submitting a link as evidence

You can submit a link as evidence by invoking the POST /tests/{id}/evidence with a type of “link” and passing the URL in the request body.  

Javascript
				
					const axios = require('axios');

const apiKey = '<your_api_key_here>';
const testId = 'c6354cde-3a4e-4b35-8bfd-aafb33a9f44f';
const url = `https://api.trustcloud.ai/tests/${testId}/evidence`;

const data = {
  type: 'link',
  url: 'https://someurl.com',
  description: 'Some URL evidence to support my test.',
  evidenceDate: '2022/12/31'
};

axios.post(url, data, {
  headers: {
    'Authorization': apiKey,
    'Content-Type': 'application/json',
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});

				
			
Java
				
					import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class TrustCloudLink {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        String testId = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f";
        String url = "https://api.trustcloud.ai/tests/" + testId + "/evidence";

        OkHttpClient client = new OkHttpClient();

        String json = "{\"type\":\"link\",\"url\":\"https://someurl.com\",\"description\":\"Some URL evidence to support my test.\",\"evidenceDate\":\"2022/12/31\"}";
        MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        RequestBody requestBody = RequestBody.create(json, JSON);

        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .addHeader("Authorization", apiKey)
                .addHeader("x-trustcloud-api-version", "1")
                .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

				
			
Csharp
				
					using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

class TrustCloudLink
{
    static async Task Main()
    {
        string apiKey = "<your_api_key_here>";
        string testId = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f";
        string url = $"https://api.trustcloud.ai/tests/{testId}/evidence";

        using HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
        client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

        string json = "{\"type\":\"link\",\"url\":\"https://someurl.com\",\"description\":\"Some URL evidence to support my test.\",\"evidenceDate\":\"2022/12/31\"}";
        HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");

        HttpResponseMessage response = await client.PostAsync(url, content);
        string result = await response.Content.ReadAsStringAsync();

        Console.WriteLine(result);
    }
}

				
			
Python
				
					import requests

api_key = "<your_api_key_here>"
test_id = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f"
url = f"https://api.trustcloud.ai/tests/{test_id}/evidence"

headers = {
    "Authorization": api_key,
    "Content-Type": "application/json",
    "x-trustcloud-api-version": "1"
}

data = {
    "type": "link",
    "url": "https://someurl.com",
    "description": "Some URL evidence to support my test.",
    "evidenceDate": "2022/12/31"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

				
			
Go
				
					package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type EvidenceLink struct {
	Type        string `json:"type"`
	URL         string `json:"url"`
	Description string `json:"description"`
	EvidenceDate string `json:"evidenceDate"`
}

func main() {
	apiKey := "<your_api_key_here>"
	testID := "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f"
	url := "https://api.trustcloud.ai/tests/" + testID + "/evidence"

	data := EvidenceLink{
		Type:        "link",
		URL:         "https://someurl.com",
		Description: "Some URL evidence to support my test.",
		EvidenceDate: "2022/12/31",
	}
	jsonData, err := json.Marshal(data)
	if err != nil {
		panic(err)
	}

	client := &http.Client{}
	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	if err != nil {
		panic(err)
	}

	req.Header.Set("Authorization", apiKey)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-trustcloud-api-version", "1")

	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(body))
}

				
			
Bash
				
					POST /tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/evidence HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
Content-Type: application/json
x-trustcloud-api-version: 1

{
  "type": "link",
  "url": "https://someurl.com",
  "description": "Some URL evidence to support my test.",
  "evidenceDate": "2022/12/31"
}

				
			

Submitting a file as evidence

You can submit a file as evidence by invoking the POST /tests/{id}/evidence with a type of “file” and passing the filename in the request body.  Files are submitted via multipart form post, with the metadata 

Javascript
				
					const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');

const apiKey = '<your_api_key_here>';
const testId = 'c6354cde-3a4e-4b35-8bfd-aafb33a9f44f';
const url = `https://api.trustcloud.ai/tests/${testId}/evidence`;

const formData = new FormData();
formData.append('description', 'Some file to support my test.');
formData.append('evidenceDate', '2022/12/31');
formData.append('type', 'file');
formData.append('file', fs.createReadStream('evidence.png'), 'evidence.png');

axios.post(url, formData, {
  headers: {
    ...formData.getHeaders(),
    'Authorization': apiKey,
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});

				
			
Java
				
					import java.io.File;
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.Request;
import okhttp3.Response;

public class TrustCloudFile {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        String testId = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f";
        String url = "https://api.trustcloud.ai/tests/" + testId + "/evidence";
        String filePath = "evidence.png";

        OkHttpClient client = new OkHttpClient();

        File file = new File(filePath);
        MediaType mediaType = MediaType.parse("image/png");
        RequestBody fileBody = RequestBody.create(file, mediaType);

        RequestBody requestBody = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("description", "Some file to support my test.")
                .addFormDataPart("evidenceDate", "2022/12/31")
                .addFormDataPart("type", "file")
                .addFormDataPart("file", "evidence.png", fileBody)
                .build();

        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .addHeader("Authorization", apiKey)
                .addHeader("x-trustcloud-api-version", "1")
                .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

				
			
Csharp
				
					using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

class TrustCloudFile
{
    static async Task Main()
    {
        string apiKey = "<your_api_key_here>";
        string testId = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f";
        string url = $"https://api.trustcloud.ai/tests/{testId}/evidence";
        string filePath = "evidence.png";

        using HttpClient client = new HttpClient();
        using MultipartFormDataContent formData = new MultipartFormDataContent();

        formData.Add(new StringContent("Some file to support my test."), "description");
        formData.Add(new StringContent("2022/12/31"), "evidenceDate");
        formData.Add(new StringContent("file"), "type");
        formData.Add(new StreamContent(File.OpenRead(filePath)), "file", "evidence.png");

        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
        client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

        HttpResponseMessage response = await client.PostAsync(url, formData);
        string result = await response.Content.ReadAsStringAsync();

        Console.WriteLine(result);
    }
}

				
			
Python
				
					import requests

api_key = "<your_api_key_here>"
test_id = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f"
url = f"https://api.trustcloud.ai/tests/{test_id}/evidence"

headers = {
    "Authorization": api_key,
    "x-trustcloud-api-version": "1"
}

data = {
    "description": "Some file to support my test.",
    "evidenceDate": "2022/12/31",
    "type": "file"
}

with open("evidence.png", "rb") as file:
    files = {"file": ("evidence.png", file, "image/png")}
    response = requests.post(url, headers=headers, data=data, files=files)

print(response.json())

				
			
Go
				
					package main

import (
	"bytes"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
)

func main() {
	apiKey := "<your_api_key_here>"
	testID := "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f"
	url := "https://api.trustcloud.ai/tests/" + testID + "/evidence"

	var buffer bytes.Buffer
	writer := multipart.NewWriter(&buffer)

	description, _ := writer.CreateFormField("description")
	io.WriteString(description, "Some file to support my test.")

	evidenceDate, _ := writer.CreateFormField("evidenceDate")
	io.WriteString(evidenceDate, "2022/12/31")

	evidenceType, _ := writer.CreateFormField("type")
	io.WriteString(evidenceType, "file")

	file, err := os.Open("evidence.png")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer file.Close()

	fileWriter, _ := writer.CreateFormFile("file", "evidence.png")
	io.Copy(fileWriter, file)

	writer.Close()

	req, _ := http.NewRequest("POST", url, &buffer)
	req.Header.Set("Content-Type", writer.FormDataContentType())
	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 respBuffer bytes.Buffer
	io.Copy(&respBuffer, resp.Body)

	fmt.Println(respBuffer.String())
}


				
			
Bash
				
					POST /tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/evidence HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
Content-Type: multipart/form-data; boundary=<boundary>
x-trustcloud-api-version: 1

--<boundary>
Content-Disposition: form-data; name="description"
Some file to support my test.

--<boundary>
Content-Disposition: form-data; name="evidenceDate"
2022/12/31

--<boundary>
Content-Disposition: form-data; name="type"
file

--<boundary>
Content-Disposition: form-data; name="file"; filename="evidence.png"
Content-Type: <file_mime_type>

<file_binary_data>
--<boundary>--

				
			

Completing a test

You can complete the attestation for a test by invoking POST /tests/{id}/execute and answering the assessment with either a yes to pass the assessment, or no to fail the assessment.  Additional details can be provided by passing a comment.  

Javascript
				
					const axios = require('axios');

const apiKey = '<your_api_key_here>';
const testId = 'c6354cde-3a4e-4b35-8bfd-aafb33a9f44f';
const url = `https://api.trustcloud.ai/tests/${testId}/execute`;

const data = {
  answer: yes,
  comment: “Optional description of the assessment details”
};

axios.post(url, data, {
  headers: {
    'Authorization': apiKey,
    'Content-Type': 'application/json',
    'x-trustcloud-api-version': '1'
  }
}).then(response => {
  console.log(response.data);
}).catch(error => {
  console.error(error);
});

				
			
Java
				
					import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class TrustCloudLink {
    public static void main(String[] args) throws IOException {
        String apiKey = "<your_api_key_here>";
        String testId = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f";
        String url = "https://api.trustcloud.ai/tests/" + testId + "/execute";

        OkHttpClient client = new OkHttpClient();

        String json = "{\"answer\":\"yes\",\"comment\":\"Optional description of the assessment details\"}";
        MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        RequestBody requestBody = RequestBody.create(json, JSON);

        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .addHeader("Authorization", apiKey)
                .addHeader("x-trustcloud-api-version", "1")
                .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

				
			
Csharp
				
					using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

class TrustCloudLink
{
    static async Task Main()
    {
        string apiKey = "<your_api_key_here>";
        string testId = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f";
        string url = $"https://api.trustcloud.ai/tests/{testId}/execute";

        using HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
        client.DefaultRequestHeaders.Add("x-trustcloud-api-version", "1");

        string json = "{\"answer\":\"yes\",\"comment\":\"Optional description of the assessment details\"}";
        HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");

        HttpResponseMessage response = await client.PostAsync(url, content);
        string result = await response.Content.ReadAsStringAsync();

        Console.WriteLine(result);
    }
}

				
			
Python
				
					import requests

api_key = "<your_api_key_here>"
test_id = "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f"
url = f"https://api.trustcloud.ai/tests/{test_id}/evidence"

headers = {
    "Authorization": api_key,
    "Content-Type": "application/json",
    "x-trustcloud-api-version": "1"
}

data = {
    "answer": "yes",
    "comment": "Optional description of the assessment details"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

				
			
Go
				
					package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type EvidenceLink struct {
	Type        string `json:"type"`
	URL         string `json:"url"`
	Description string `json:"description"`
	EvidenceDate string `json:"evidenceDate"`
}

func main() {
	apiKey := "<your_api_key_here>"
	testID := "c6354cde-3a4e-4b35-8bfd-aafb33a9f44f"
	url := "https://api.trustcloud.ai/tests/" + testID + "/execute"

	data := EvidenceLink{
		answer:        "yes",
		comment:       "Optional description of the assessment details"
"
	}
	jsonData, err := json.Marshal(data)
	if err != nil {
		panic(err)
	}

	client := &http.Client{}
	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	if err != nil {
		panic(err)
	}

	req.Header.Set("Authorization", apiKey)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-trustcloud-api-version", "1")

	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(body))
}

				
			
Bash
				
					POST /tests/c6354cde-3a4e-4b35-8bfd-aafb33a9f44f/execute HTTP/1.1
Host: api.trustcloud.ai
Authorization: <your_api_key_here>
Content-Type: application/json
x-trustcloud-api-version: 1

{
  "answer": "yes",
  "comment": "Optional description of the assessment details"
}

				
			

Paging

If there are a large number of tests  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 tests:

Javascript
				
					import axios from 'axios';

const headers = {
  'Authorization': '<your_api_key_here>',
  'x-trustcloud-api-version': '1'
};

const limit = 10; // The number of Tests to retrieve per page
const page = 1; // The page number to retrieve (starts at 1)

axios.get('https://api.trustcloud.ai/tests, {
  headers,
  params: {
    limit,
    page,
  }
})
  .then(response => {
    console.log(response.data);
    console.log(response.headers.link); // log link header
  })
  .catch(error => {
    console.log(error);
  });

				
			
Java
				
					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/tests?limit=10&page=1");
request.setHeader("Authorization", "<your_api_key_here>");
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();
}

				
			
Csharp
				
					using System;
using System.Collections.Generic;

string apiKey = "<your_api_key_here>";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";

var client = new RestClient(baseUrl);
var request = new RestRequest("/tests", 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);
}

				
			
Python
				
					import requests
headers = {
   'Authorization': '<your_api_key_here>',
   'x-trustcloud-api-version': '1'
}

response = requests.get('https://api.trustcloud.ai/tests?limit=10&page=1', headers=headers', headers=headers)
if response.status_code == 200:
   test = response.json()
   print(test)
else:
   print('Error retrieving Tests:', response.text)

				
			
Go
				
					package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

apiKey := "<your_api_key_here>"
url := "https://api.trustcloud.ai/tests?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)

				
			
Bash
				
					GET /tests?limit=10&page=1 HTTP/1.1
Host: API.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1

				
			

To retrieve the next set of tests, 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.

Javascript
				
					import axios from 'axios';

const headers = {
  'Authorization': '<your_api_key_here>',
  'x-trustcloud-api-version': '1'
};

const limit = 10; // The number of Tests to retrieve per page
const page = 1; // The page number to retrieve (starts at 1)

axios.get('https://api.trustcloud.ai/tests, {
  headers,
  params: {
    limit,
    page,
  }
})
  .then(response => {
    console.log(response.data);
    console.log(response.headers.link); // log link header
  })
  .catch(error => {
    console.log(error);
  });

				
			
Java
				
					String linkHeader = response.getFirstHeader("link").getValue();
String nextPageUrl = linkHeader.split(";")[0].replace("<", "").replace(">", "");
HttpGet nextPageRequest = new HttpGet(nextPageUrl);
nextPageRequest.setHeader("Authorization", "<your_api_key_here>");
nextPageRequest.setHeader("x-trustcloud-api-version", "1");

				
			
Csharp
				
					using System;
using System.Collections.Generic;

string apiKey = "<your_api_key_here>";
string apiVersion = "1";
string baseUrl = "https://api.trustcloud.ai";

var client = new RestClient(baseUrl);
var request = new RestRequest("/tests", 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);

				
			
Python
				
					import requests
import re

headers = {
   'Authorization': '<your_api_key_here>',
   'x-trustcloud-api-version': '1'
}

response = requests.get('https://api.trustcloud.ai/tests?limit=10&page=1', headers=headers)
if response.status_code == 200:
   test = response.json()
   print(test)
   link_header = response.headers.get('link')
   if link_header:
      nextPage = re.search('<(.+)>', link_header)
else:
   print('Error retrieving Tests:', response.text)

				
			
Go
				
					package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"strings"
)

func main() {
	apiKey := "<your_api_key_here>"
	url := "https://api.trustcloud.ai/tests"

	// 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))
	}
}

				
			
Bash
				
					HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 234
link: <http://api.trustcloud.ai/tests?page=2&limit=10>; rel="next"

GET /vendors?pag2&limit=10 HTTP/1.1
Host: API.trustcloud.ai
Authorization: <your_api_key_here>
x-trustcloud-api-version: 1



				
			

API Reference

Join the conversation

ON THIS PAGE
SHARE THIS PAGE

SUBSCRIBE
FlightSchool
OR