Skip to main content
POST
/
flaky-tests
/
get-test-details
Get the details of a test case
curl --request POST \
  --url https://api.trunk.io/v1/flaky-tests/get-test-details \
  --header 'Content-Type: application/json' \
  --header 'x-api-token: <api-key>' \
  --data '
{
  "repo": {
    "host": "<string>",
    "owner": "<string>",
    "name": "<string>"
  },
  "org_url_slug": "<string>",
  "test_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'
import requests

url = "https://api.trunk.io/v1/flaky-tests/get-test-details"

payload = {
"repo": {
"host": "<string>",
"owner": "<string>",
"name": "<string>"
},
"org_url_slug": "<string>",
"test_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
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>',
test_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};

fetch('https://api.trunk.io/v1/flaky-tests/get-test-details', 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/get-test-details",
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>',
'test_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
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/get-test-details"

payload := strings.NewReader("{\n \"repo\": {\n \"host\": \"<string>\",\n \"owner\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"org_url_slug\": \"<string>\",\n \"test_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\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/get-test-details")
.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 \"test_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.trunk.io/v1/flaky-tests/get-test-details")

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 \"test_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"

response = http.request(request)
puts response.read_body
{
  "test": {
    "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>"
    }
  }
}
"<string>"

Authorizations

x-api-token
string
header
required

Body

application/json
repo
object
required

The repository to list tests for.

org_url_slug
string
required

The slug of your organization. Find this at https://app.trunk.io/trunk/settings under "Organization Name" > "Slug"

Example:

"my-trunk-org-slug"

test_id
string<uuid>
required

The id of a test case. Should be a UUID.

Example:

"01234567-0123-0123-0123-0123456789ab"

Response

OK

test
object
required

The details of a test case.