Get a list of distinct tests that failed in the given time range
curl --request POST \
--url https://api.trunk.io/v1/flaky-tests/list-failing-tests \
--header 'Content-Type: application/json' \
--header 'x-api-token: <api-key>' \
--data '
{
"repo": {
"host": "<string>",
"owner": "<string>",
"name": "<string>"
},
"org_url_slug": "<string>",
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"page_query": {
"page_size": 50,
"page_token": "<string>"
}
}
'import requests
url = "https://api.trunk.io/v1/flaky-tests/list-failing-tests"
payload = {
"repo": {
"host": "<string>",
"owner": "<string>",
"name": "<string>"
},
"org_url_slug": "<string>",
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"page_query": {
"page_size": 50,
"page_token": "<string>"
}
}
headers = {
"x-api-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repo: {host: '<string>', owner: '<string>', name: '<string>'},
org_url_slug: '<string>',
start_time: '2023-11-07T05:31:56Z',
end_time: '2023-11-07T05:31:56Z',
page_query: {page_size: 50, page_token: '<string>'}
})
};
fetch('https://api.trunk.io/v1/flaky-tests/list-failing-tests', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trunk.io/v1/flaky-tests/list-failing-tests",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repo' => [
'host' => '<string>',
'owner' => '<string>',
'name' => '<string>'
],
'org_url_slug' => '<string>',
'start_time' => '2023-11-07T05:31:56Z',
'end_time' => '2023-11-07T05:31:56Z',
'page_query' => [
'page_size' => 50,
'page_token' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trunk.io/v1/flaky-tests/list-failing-tests"
payload := strings.NewReader("{\n \"repo\": {\n \"host\": \"<string>\",\n \"owner\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"org_url_slug\": \"<string>\",\n \"start_time\": \"2023-11-07T05:31:56Z\",\n \"end_time\": \"2023-11-07T05:31:56Z\",\n \"page_query\": {\n \"page_size\": 50,\n \"page_token\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trunk.io/v1/flaky-tests/list-failing-tests")
.header("x-api-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"repo\": {\n \"host\": \"<string>\",\n \"owner\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"org_url_slug\": \"<string>\",\n \"start_time\": \"2023-11-07T05:31:56Z\",\n \"end_time\": \"2023-11-07T05:31:56Z\",\n \"page_query\": {\n \"page_size\": 50,\n \"page_token\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trunk.io/v1/flaky-tests/list-failing-tests")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repo\": {\n \"host\": \"<string>\",\n \"owner\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"org_url_slug\": \"<string>\",\n \"start_time\": \"2023-11-07T05:31:56Z\",\n \"end_time\": \"2023-11-07T05:31:56Z\",\n \"page_query\": {\n \"page_size\": 50,\n \"page_token\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"tests": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"repository": {
"html_url": "<string>"
},
"html_url": "<string>",
"name": "<string>",
"variant": "<string>",
"status": {
"reason": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
},
"most_common_failures": [
{
"summary": "<string>",
"occurrence_count": 1,
"last_occurrence": "2023-11-07T05:31:56Z"
}
],
"failure_rate_last_7d": 123,
"failure_rate_last_24h": 123,
"codeowners": [
"<string>"
],
"pull_requests_impacted_last_7d": 1,
"quarantined": true,
"file_path": "<string>",
"parent": "<string>",
"classname": "<string>",
"ticket": {
"html_url": "<string>"
}
}
],
"page": {
"total_rows": 1,
"total_pages": 1,
"next_page_token": "<string>",
"prev_page_token": "<string>",
"last_page_token": "<string>",
"page_index": 1
}
}"<string>"API reference
Get a list of distinct tests that failed in the given time range
POST
/
flaky-tests
/
list-failing-tests
Get a list of distinct tests that failed in the given time range
curl --request POST \
--url https://api.trunk.io/v1/flaky-tests/list-failing-tests \
--header 'Content-Type: application/json' \
--header 'x-api-token: <api-key>' \
--data '
{
"repo": {
"host": "<string>",
"owner": "<string>",
"name": "<string>"
},
"org_url_slug": "<string>",
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"page_query": {
"page_size": 50,
"page_token": "<string>"
}
}
'import requests
url = "https://api.trunk.io/v1/flaky-tests/list-failing-tests"
payload = {
"repo": {
"host": "<string>",
"owner": "<string>",
"name": "<string>"
},
"org_url_slug": "<string>",
"start_time": "2023-11-07T05:31:56Z",
"end_time": "2023-11-07T05:31:56Z",
"page_query": {
"page_size": 50,
"page_token": "<string>"
}
}
headers = {
"x-api-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repo: {host: '<string>', owner: '<string>', name: '<string>'},
org_url_slug: '<string>',
start_time: '2023-11-07T05:31:56Z',
end_time: '2023-11-07T05:31:56Z',
page_query: {page_size: 50, page_token: '<string>'}
})
};
fetch('https://api.trunk.io/v1/flaky-tests/list-failing-tests', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trunk.io/v1/flaky-tests/list-failing-tests",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repo' => [
'host' => '<string>',
'owner' => '<string>',
'name' => '<string>'
],
'org_url_slug' => '<string>',
'start_time' => '2023-11-07T05:31:56Z',
'end_time' => '2023-11-07T05:31:56Z',
'page_query' => [
'page_size' => 50,
'page_token' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trunk.io/v1/flaky-tests/list-failing-tests"
payload := strings.NewReader("{\n \"repo\": {\n \"host\": \"<string>\",\n \"owner\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"org_url_slug\": \"<string>\",\n \"start_time\": \"2023-11-07T05:31:56Z\",\n \"end_time\": \"2023-11-07T05:31:56Z\",\n \"page_query\": {\n \"page_size\": 50,\n \"page_token\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trunk.io/v1/flaky-tests/list-failing-tests")
.header("x-api-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"repo\": {\n \"host\": \"<string>\",\n \"owner\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"org_url_slug\": \"<string>\",\n \"start_time\": \"2023-11-07T05:31:56Z\",\n \"end_time\": \"2023-11-07T05:31:56Z\",\n \"page_query\": {\n \"page_size\": 50,\n \"page_token\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trunk.io/v1/flaky-tests/list-failing-tests")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repo\": {\n \"host\": \"<string>\",\n \"owner\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"org_url_slug\": \"<string>\",\n \"start_time\": \"2023-11-07T05:31:56Z\",\n \"end_time\": \"2023-11-07T05:31:56Z\",\n \"page_query\": {\n \"page_size\": 50,\n \"page_token\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"tests": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"repository": {
"html_url": "<string>"
},
"html_url": "<string>",
"name": "<string>",
"variant": "<string>",
"status": {
"reason": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
},
"most_common_failures": [
{
"summary": "<string>",
"occurrence_count": 1,
"last_occurrence": "2023-11-07T05:31:56Z"
}
],
"failure_rate_last_7d": 123,
"failure_rate_last_24h": 123,
"codeowners": [
"<string>"
],
"pull_requests_impacted_last_7d": 1,
"quarantined": true,
"file_path": "<string>",
"parent": "<string>",
"classname": "<string>",
"ticket": {
"html_url": "<string>"
}
}
],
"page": {
"total_rows": 1,
"total_pages": 1,
"next_page_token": "<string>",
"prev_page_token": "<string>",
"last_page_token": "<string>",
"page_index": 1
}
}"<string>"Authorizations
Body
application/json
The repository to list tests for.
Show child attributes
Show child attributes
The slug of your organization. Find this at https://app.trunk.io/trunk/settings under "Organization Name" > "Slug"
Example:
"my-trunk-org-slug"
The start time of the failing tests (inclusive). Must be within 7 days of the end time.
The end time of the failing tests (exclusive). Must be within 7 days of the start time.
Pagination options for the list of tests.
Show child attributes
Show child attributes
Was this page helpful?
⌘I