# Test Sessions API (a.k.a TIA API)

You can integrate any Testing framework with Sealights to capture Tests Events like Start and End of Test Stage, Tests results, etc using the API described on this page.\
This API includes getting the list of tests recommended to be skipped by Sealights for Test Optimization (TIA) and forcing a Full-Run on the next execution of a Test Stage.

For your reference, you’ll find a few sample integrations with various Testing frameworks listed on [integrating-test-executions-from-various-testing-frameworks](https://docs.sealights.io/knowledgebase/setup-and-configuration/integrations/sample-integrations/integrating-test-executions-from-various-testing-frameworks "mention").

{% hint style="info" %}
This API requires the [Agent token](https://docs.sealights.io/knowledgebase/setup-and-configuration/getting-started/steps-for-successful-onboarding/generating-a-token#agent-tokens).
{% endhint %}

***

## Creating Test Session <a href="#creating-test-session" id="creating-test-session"></a>

Create a test session with a specific Labid and test stage, if there is no labId - use BSId instead

Calling this request to create a new test session for the current run

{% code overflow="wrap" lineNumbers="true" %}

```
POST /sl-api/v1/test-sessions
```

{% endcode %}

### Request details <a href="#request-details" id="request-details"></a>

#### Request body <a href="#request-body" id="request-body"></a>

<table><thead><tr><th width="159.96875">Parameter</th><th width="252.23046875">Description</th><th>Default value</th><th>Is mandatory?</th></tr></thead><tbody><tr><td><code>labId</code></td><td>Lab Id</td><td> </td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td><code>testStage</code></td><td>Test Stage</td><td> </td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td><code>bsid</code></td><td>Build Session Id</td><td> </td><td> </td></tr><tr><td><code>sessionTimeout</code></td><td>Session Timeout (seconds), max timeout 86400 (24 hours)</td><td>14,400 (4 hours)</td><td> </td></tr><tr><td><code>testGroupId</code></td><td>Test group id</td><td> </td><td> </td></tr></tbody></table>

#### Request Samples <a href="#request-samples" id="request-samples"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
POST /sl-api/v1/test-sessions HTTP/1.1
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
{
  "labId": "LabId",
  "testStage": "Unit Tests",
  "bsid": "bsId",
  "sessionTimeout": 10000,
  "testGroupId": "job name"
}

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample" id="response-sample"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data": {
    "testSessionId": "341dc795-71a8-4253-b686-27ff09f04468"
  }
}
```

{% endcode %}

#### Sample Shell command and response <a href="#sample-shell-command-and-response" id="sample-shell-command-and-response"></a>

{% tabs %}
{% tab title="Linux" %}
{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X POST "https://$DOMAIN/sl-api/v1/test-sessions"
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"labId\":\"LabId\",\"testStage\":\"UnitTests\",\"bsid\":\"bsId\",\"sessionTimeout\":10000}"

200 OK
404 NOT_FOUND
500 BAD_REQUEST
```

{% endcode %}
{% endtab %}

{% tab title="Powershell" %}
{% code overflow="wrap" lineNumbers="true" %}

```powershell
Invoke-RestMethod -Uri "https://$SL_DOMAIN/sl-api/v1/test-sessions" -Method 'Post' \
  -Headers @{'Authorization'="Bearer $SEALIGHTS_AGENT_TOKEN";'Content-Type'='application/json'} 
  -Body @{'testStage'='Automation Tests';'bsid'='123'}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Get Exclude Tests v1 (deprecated) <a href="#get-exclude-tests-v1-deprecated" id="get-exclude-tests-v1-deprecated"></a>

Getting a list of tests that should be excluded

{% hint style="warning" %}
Test Optimization must be turned **on** for the Test Stage in order to receive a non-empty response.
{% endhint %}

Calling this request to get a list of test names that should be excluded in the current run (by default with test names)

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v1/test-sessions/{testSessionId}/exclude-tests
```

{% endcode %}

You can specify to get only the External Tests IDs (instead of Test Names) to be returned in the response

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v1/test-sessions/{testSessionId}/exclude-tests?type=externalId
```

{% endcode %}

### Request details <a href="#request-details.1" id="request-details.1"></a>

#### Request parameters <a href="#request-parameters" id="request-parameters"></a>

<table><thead><tr><th width="155.390625">Parameter</th><th width="346.953125">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td><code>testSessionId</code></td><td>Test Session ID</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td><code>type</code></td><td><p>enum:</p><ul><li><code>name</code> - <em>Default type if not specific</em>.</li><li><code>externalId</code></li></ul></td><td> </td></tr></tbody></table>

#### Request/Response Samples <a href="#request-response-samples" id="request-response-samples"></a>

{% tabs %}
{% tab title="Default (using test names)" %}
**Request**

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v1/test-sessions/{testSessionId}/exclude-tests
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

**Response**

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data":[
    "Test1",
    "Test2"
    ]
}
```

{% endcode %}
{% endtab %}

{% tab title="externalId" %}
**Request**

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v1/test-sessions/{testSessionId}/exclude-tests?type=externalId
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

**Response**

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data":[
    "123-456",
    "adg-457"
    ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Sample Shell command and response <a href="#sample-shell-command-and-response-.1" id="sample-shell-command-and-response-.1"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN/sl-api/v1/test-sessions/$TESTSESSIONID/exclude-tests" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json"

200 OK
404 NOT_FOUND
500 BAD_REQUEST
```

{% endcode %}

## Get Exclude Tests v2 <a href="#get-exclude-tests-v2" id="get-exclude-tests-v2"></a>

Getting a list of tests that should be excluded

{% hint style="warning" %}
Test Optimization must be turned **on** for the Test Stage in order to receive a non-empty response.
{% endhint %}

Calling this request to get a list of test names that should be excluded in the current run (by default with test names)

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v2/test-sessions/{testSessionId}/exclude-tests
```

{% endcode %}

### Request details <a href="#request-details.2" id="request-details.2"></a>

#### Request parameters <a href="#request-parameters.1" id="request-parameters.1"></a>

| **Parameter**   | **Description** | **Is mandatory?**                                                    |
| --------------- | --------------- | -------------------------------------------------------------------- |
| `testSessionId` | Test Session ID | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |

#### Request/Response Samples <a href="#request-response-samples.1" id="request-response-samples.1"></a>

{% tabs %}
{% tab title="Default (using test names)" %}
**Request**

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v2/test-sessions/{testSessionId}/exclude-tests
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

**Response**

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "metadata": { // metadata to help DevOps debug their integration
    "appName": "string", // app name requested.
    "branchName": "string", // branch name requested.
    "buildName": "string", // build name requested.
    "testStage": "string", // test stage requested.
    "testGroupId": "string", // test group id requested.
    "testSelectionEnabled": true, // when true TIA is on the given app/branch/test-stage
    "isFullRun": true, // when true it means that on the given app/branch/test-stage for the build
    "status": "notReady", // represent recommendations status [notReady, noHistory, ready, error, wontBeReady]
    "fullRunReason": "No statistical model available for build" // describe the reason why full run is recommended (Optional, only if isFullRun=true)
  },
  "excludedTests": [ // an array of objects representing the execluded tests.
    {
      "testName": "string"
    }
  ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Sample Shell command and response <a href="#sample-shell-command-and-response-.2" id="sample-shell-command-and-response-.2"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN/sl-api/v2/test-sessions/$TESTSESSIONID/exclude-tests" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json"

200 OK
404 NOT_FOUND
500 BAD_REQUEST
```

{% endcode %}

## Sending Test Events <a href="#sending-test-events" id="sending-test-events"></a>

Sending test events with status

Calling this request for reporting SeaLights test event result.

{% code overflow="wrap" lineNumbers="true" %}

```
POST /sl-api/v2/test-sessions/{testSessionId}
```

{% endcode %}

{% hint style="warning" %}

* This API must be called before closing/deleting the session.
* Please notice this specific endpoint uses a `v2` URL
  {% endhint %}

{% hint style="info" %}
This API can be called several times during a session to report tests in bulk.
{% endhint %}

### Request details <a href="#request-details.3" id="request-details.3"></a>

#### Request parameters <a href="#request-parameters.2" id="request-parameters.2"></a>

<table><thead><tr><th width="190.32421875">Parameter</th><th>Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td><code>testSessionId</code></td><td>Test Session ID</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr></tbody></table>

#### Request Body <a href="#request-body" id="request-body"></a>

{% hint style="warning" %}

* The tests skipped per the recommendation (GetExcluded Tests API above) must be explicitly included in the results of the test sent to Sealights (with the status `skipped`)
* Skipped tests must be provided with start and end parameters, as well. We recommend providing them with `start = end = now()` value.
  {% endhint %}

| Parameter          | Description                                                                                                                                      | Is mandatory?                                                        |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
| `body`             | Array of Test run events (even for a single test)                                                                                                | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| **Test run event** |                                                                                                                                                  |                                                                      |
| `name`             | Test Name                                                                                                                                        | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| `externalId`       | <p>(Optional) Test ID from the Test Management platform/framework .<br>This identifier must be Unique and a string long up to 48 characters.</p> |                                                                      |
| `start`            | Starting time of the test (milliseconds since epoch)                                                                                             | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| `end`              | Ending time of the test (milliseconds since epoch)                                                                                               | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| `status`           | Test status: `passed`, `failed` or `skipped`                                                                                                     | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |

{% hint style="danger" %}
In case of Invalid parameters, API will return an Error code `400 INVALID`. For example, if the timestamps are not sent in milliseconds format, API will return with code `400` and a message `Invalid timestamp`
{% endhint %}

#### Request Samples <a href="#request-samples.1" id="request-samples.1"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
POST /sl-api/v2/test-sessions/{testSessionId}
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
[
  {
    "name": "TestToRun1",
    "start": 1619341754996,
    "end": 1619341754998,
    "status": "passed"
  }
]

HTTP/1.1 200 OK
HTTP/1.1 400 INVALID
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Sample Shell command and response <a href="#sample-shell-command-and-response-.3" id="sample-shell-command-and-response-.3"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
curl -X POST "https://$DOMAIN/sl-api/v2/test-sessions/$TESTSESSIONID" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d "[{\"name\":\"TestToRun1\",\"start\":1619341754996,\"end\":1619341754998,\"status\":\"passed\"}]"

200 OK
400 INVALID
404 NOT_FOUND
500 BAD_REQUEST 
```

{% endcode %}

## Delete Test Session <a href="#delete-test-session" id="delete-test-session"></a>

Delete test session when sending of test events has been done.

Calling this request will close the test session and update the coverage.

{% code overflow="wrap" lineNumbers="true" %}

```
DELETE /sl-api/v1/test-sessions/{testSessionId}
```

{% endcode %}

### Request details <a href="#request-details.4" id="request-details.4"></a>

#### Request parameters <a href="#request-parameters.3" id="request-parameters.3"></a>

| Parameter       | Description     | Is mandatory?                                                        |
| --------------- | --------------- | -------------------------------------------------------------------- |
| `testSessionId` | Test Session ID | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |

#### Request Samples <a href="#request-samples.2" id="request-samples.2"></a>

```
DELETE /sl-api/v1/test-sessions/{testSessionId}
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

#### Sample Shell command and response <a href="#sample-shell-command-and-response-.4" id="sample-shell-command-and-response-.4"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X DELETE "https://$DOMAIN/sl-api/v1/test-sessions/$TESTSESSIONID" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" 

200 OK
404 NOT_FOUND
500 BAD_REQUEST
```

{% endcode %}

## Force “Full-Run” on a Test Stage <a href="#force-full-run-on-a-test-stage" id="force-full-run-on-a-test-stage"></a>

This request will schedule a “full run” for the subsequent execution of a specified Test Stage.

{% code overflow="wrap" lineNumbers="true" %}

```
PUT /sl-api/v1/tia/apps/{appName}/branches/{branchName}/testStages/{testStage}/full-run
```

{% endcode %}

{% hint style="warning" %}
This API call should be executed BEFORE creating the test session.
{% endhint %}

### Request details <a href="#request-details.5" id="request-details.5"></a>

#### Request parameters <a href="#request-parameters.4" id="request-parameters.4"></a>

<table><thead><tr><th width="132.171875">Parameter</th><th width="466.75">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td><code>appName</code></td><td>App to schedule full run for</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td><code>branchName</code></td><td>Branch to schedule full run for</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td><code>testStage</code></td><td>Test Stage to schedule full run for</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr></tbody></table>

#### Request Body <a href="#request-body.1" id="request-body.1"></a>

<table><thead><tr><th width="133.52734375">Parameter</th><th width="467.68359375">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td><code>enable</code></td><td>Boolean indicator, indicates if next run will be full run or not</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr></tbody></table>

#### Request Samples <a href="#request-samples.3" id="request-samples.3"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
PUT /sl-api/v1/tia/apps/{appName}/branches/{branchName}/testStages/{testStage}/full-run
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
{
    "enable": true
}

HTTP/1.1 200 OK
HTTP/1.1 400 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Sample Shell command and response <a href="#sample-shell-command-and-response-.5" id="sample-shell-command-and-response-.5"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X PUT "https://$DOMAIN/sl-api/v1/tia/apps/$APPNAME/branches/$BRANCHNAME/testStages/$TESTSTAGE/full-run" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"enable\":true}"

200 OK
404 NOT_FOUND
500 BAD_REQUEST
```

{% endcode %}

## Get Recommended Tests (White List) <a href="#get-recommended-tests-white-list" id="get-recommended-tests-white-list"></a>

{% hint style="warning" %}
This API call does not require a test session.
{% endhint %}

### Get Recommended Tests for the latest build from a specific app/branch <a href="#get-recommended-tests-for-the-latest-build-from-a-specific-app-branch" id="get-recommended-tests-for-the-latest-build-from-a-specific-app-branch"></a>

Get recommendations for the latest build for a specific app/branch: it returns a list of test names recommended to be run.

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/tia/apps/{appName}/branches/{branchName}/test-stages/{testStage}/recommendations
```

{% endcode %}

#### Request details <a href="#request-details.6" id="request-details.6"></a>

**Request parameters**

| Parameter  | Description     | Is mandatory?                                                        |
| ---------- | --------------- | -------------------------------------------------------------------- |
| appName    | App name        | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| branchName | Branch name     | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| testStage  | Test Stage name | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |

<details>

<summary>Optional parameters</summary>

<table><thead><tr><th width="131.7578125">Parameter</th><th width="413.3203125">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>offset</td><td>Result offset - used for pagination</td><td> </td></tr><tr><td>limit</td><td>Result limit - used for pagination (max limit 100,000 records)</td><td> </td></tr><tr><td>search</td><td>Free text to filter the recommednations by</td><td> </td></tr><tr><td>sortBy</td><td><p>Sort recommnedations bym options are:</p><ul><li>testName</li></ul></td><td> </td></tr><tr><td>sortDirection</td><td><p>Sort recommendations direction, options are:</p><ul><li>asc</li><li>desc</li></ul></td><td> </td></tr><tr><td>facet</td><td><p>Saved filters according to recommendations` types, options are:</p><ul><li>all (default)</li><li>impacted</li><li>dependent</li><li>recentlyFailed</li><li>previouslyRecommendedAndNotExecuted</li><li>pinned</li><li>other</li></ul></td><td></td></tr></tbody></table>

</details>

#### Request/Response Samples <a href="#request-response-samples.2" id="request-response-samples.2"></a>

{% tabs %}
{% tab title="Default" %}
**Request**

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/tia/apps/{appName}/branches/{branchName}/test-stages/{testStage}/recommendations
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

**Response**

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data": {
    "total": 500,
    "next": 50,
    "previous": 0,
    "list": [
      {
        "testName": "it should return ok",
        "testType": "parameterized",
        "numberOfpermutations": 3,
        "reasons": [
          "impacted"
        ],
        "relativeBuild": {
          "bsId": "some-bsid",
          "buildName": "build1",
          "timestamp": 1651545121
        },
        "pinnedBy": "user",
        "pinnedDate": "12/12/2022",
        "pinnedReason": "important test"
      }
    ],
    "metadata": {
      "appName": "app1",
      "branchName": "master",
      "buildName": "build1",
      "buildSessionId": "bsid1",
      "testStage": "Unit Tests"
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.6" id="sample-shell-command-and-response-.6"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
curl -X GET "https://$DOMAIN/sl-api/v1/tia/apps/$APP_NAME/branches/$BRANCH_NAME/test-stages/$TEST_STAGE/recommendations" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK
400 Missing parameters
401 Recommendations not found due to error
```

{% endcode %}

### Get Recommended Tests by BSID and Test-Stage <a href="#get-recommended-tests-by-bsid-and-test-stage" id="get-recommended-tests-by-bsid-and-test-stage"></a>

Get recommendations for a specific build according to buildSessionId: it will return a list of test names that are recommended to be run for the given build.

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/tia/builds/{bsId}/test-stages/{testStage}/recommendations
```

{% endcode %}

#### Request details <a href="#request-details.7" id="request-details.7"></a>

**Request parameters**

<table><thead><tr><th width="146.921875">Parameter</th><th width="451.54296875">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>bsId</td><td>Build session Id</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testStage</td><td>Test Stage name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>offset</td><td>Result offset - used for pagination</td><td> </td></tr><tr><td>limit</td><td>Result limit - used for pagination (max limit 100,000 records)</td><td> </td></tr><tr><td>search</td><td>Free text to filter the recommednations by</td><td> </td></tr><tr><td>sortBy</td><td><p>Sort recommnedations bym options are:</p><ul><li>testName</li></ul></td><td> </td></tr><tr><td>sortDirection</td><td><p>Sort recommendations direction, options are:</p><ul><li>asc</li><li>desc</li></ul></td><td> </td></tr><tr><td>facet</td><td><p>Saved filters according to recommendations` types, options are:</p><ul><li>all (default)</li><li>impacted</li><li>dependent</li><li>recentlyFailed</li><li>previouslyRecommendedAndNotExecuted</li><li>pinned</li><li>other</li></ul></td><td> </td></tr></tbody></table>

#### Request Samples <a href="#request-samples.4" id="request-samples.4"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/tia/builds/{bsId}/test-stages/{testStage}/recommendations
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.1" id="response-sample.1"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data": {
    "total": 500,
    "next": 50,
    "previous": 0,
    "list": [
      {
        "testName": "it should return ok",
        "testType": "parameterized",
        "numberOfpermutations": 3,
        "reasons": [
          "impacted"
        ],
        "relativeBuild": {
          "bsId": "some-bsid",
          "buildName": "build1",
          "timestamp": 1651545121
        },
        "pinnedBy": "user",
        "pinnedDate": "12/12/2022",
        "pinnedReason": "important test"
      }
    ],
    "metadata": {
      "appName": "app1",
      "branchName": "master",
      "buildName": "build1",
      "buildSessionId": "bsid1",
      "testStage": "Unit Tests"
    }
  }
}
```

{% endcode %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.7" id="sample-shell-command-and-response-.7"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN/sl-api/v1/tia/builds/$BSID/test-stages/$TEST_STAGE/recommendations" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK
400 Missing parameters
401 Recommendations not found due to error
```

{% endcode %}

### Get Recommended Tests by app name, branch name, build name and Test Stage <a href="#get-recommended-tests-by-app-name-branch-name-build-name-and-test-stage" id="get-recommended-tests-by-app-name-branch-name-build-name-and-test-stage"></a>

Get recommendations for a specific build according to app/branch/build-name.

Calling this request for getting a list of test names that are recommended to be run for the given build.

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/tia/apps/{appName}/branches/{branchName}/builds/{buildName}/test-stages/{testStage}/recommendations
```

{% endcode %}

#### Request details <a href="#request-details.8" id="request-details.8"></a>

**Request parameters**

<table><thead><tr><th>Parameter</th><th width="457.0546875">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>appName</td><td>App name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>branchName</td><td>Branch name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>buildName</td><td>Build name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testStage</td><td>Test Stage name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>offset</td><td>Result offset - used for pagination</td><td> </td></tr><tr><td>limit</td><td>Result limit - used for pagination (max limit 100,000 records)</td><td> </td></tr><tr><td>search</td><td>Free text to filter the recommednations by</td><td> </td></tr><tr><td>sortBy</td><td><p>Sort recommnedations bym options are:</p><ul><li>testName</li></ul></td><td> </td></tr><tr><td>sortDirection</td><td><p>Sort recommendations direction, options are:</p><ul><li>asc</li><li>desc</li></ul></td><td> </td></tr><tr><td>facet</td><td><p>Saved filters according to recommendations` types, options are:</p><ul><li>all (default)</li><li>impacted</li><li>dependent</li><li>recentlyFailed</li><li>previouslyRecommendedAndNotExecuted</li><li>pinned</li><li>other</li></ul></td><td> </td></tr></tbody></table>

#### Request Samples <a href="#request-samples.5" id="request-samples.5"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/tia/apps/{appName}/branches/{branchName}/builds/{buildName}/test-stages/{testStage}/recommendations
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.2" id="response-sample.2"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data": {
    "total": 500,
    "next": 50,
    "previous": 0,
    "list": [
      {
        "testName": "it should return ok",
        "testType": "parameterized",
        "numberOfpermutations": 3,
        "reasons": [
          "impacted"
        ],
        "relativeBuild": {
          "bsId": "some-bsid",
          "buildName": "build1",
          "timestamp": 1651545121
        },
        "pinnedBy": "user",
        "pinnedDate": "12/12/2022",
        "pinnedReason": "important test"
      }
    ],
    "metadata": {
      "appName": "app1",
      "branchName": "master",
      "buildName": "build1",
      "buildSessionId": "bsid1",
      "testStage": "Unit Tests"
    }
  }
}
```

{% endcode %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.8" id="sample-shell-command-and-response-.8"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN/sl-api/v1/tia/apps/$APP_NAME/branches/$BRANCH_NAME/builds/$BUILD_NAME/test-stages/$TEST_STAGE/recommendations" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK
400 Missing parameters
401 Recommendations not found due to error
```

{% endcode %}

## Get Executions Status List <a href="#get-executions-status-list" id="get-executions-status-list"></a>

Calling this request will respond with a status of all executions that are suitable for the request.

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v1/executions
```

{% endcode %}

This API provides you the ability to handle unexpected end of the execution of your tests that may not trigger the graceful closure of the test session to Sealights (via delete Session API call).\
If the Timeout set at the creation of the execution is not sufficient to ensure automatic closure, you can use this API to list the executions left open and close them one by one gracefully before opening new sessions.

### Request details <a href="#request-details.9" id="request-details.9"></a>

#### Request parameters <a href="#request-parameters.8" id="request-parameters.8"></a>

{% hint style="warning" %}
You must provide **LabId** or/and **BuildSessionID** (bsid)
{% endhint %}

<table><thead><tr><th width="129.375">Parameter</th><th width="479.53125">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td><code>bsid</code></td><td>Build session Id</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td><code>labId</code></td><td>Lab Id</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td><code>testStage</code></td><td>Test Stage</td><td> </td></tr><tr><td><code>status</code></td><td><p>enum:</p><ul><li><code>created</code></li><li><code>pendingDelete</code> / <code>deleting</code></li><li><code>ended</code></li></ul></td><td> </td></tr></tbody></table>

#### Request Samples <a href="#request-samples.6" id="request-samples.6"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
GET /sl-api/v1/executions?bsid={bsid}&status={status}&testStage={testStage}
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json

HTTP/1.1 200 OK
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.3" id="response-sample.3"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data": {
    "total": 3,
    "list": [
      {
        "executionId": "executionId1",
        "bsId": "buildSessionId1",
        "labId": "labId1",
        "creationTime": 226978745454,
        "ttl": 3000,
        "testStage": "unit",
        "status": "created"
      }
    ]
  }
}
```

{% endcode %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.9" id="sample-shell-command-and-response-.9"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN/sl-api/v1/executions?bsid=$bsid" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" 

200 OK
500 BAD_REQUEST
```

{% endcode %}

## Get Test Runs <a href="#get-test-runs" id="get-test-runs"></a>

### Get Test Runs by buildSessionId and Test-Stage <a href="#get-test-runs-by-buildsessionid-and-test-stage" id="get-test-runs-by-buildsessionid-and-test-stage"></a>

Get test runs for a specific build according to the build session ID and test stage.

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v2/tests/builds/{bsId}/test-stages/{testStage}/runs
```

{% endcode %}

### Request details <a href="#request-details.10" id="request-details.10"></a>

#### Request parameters <a href="#request-parameters.9" id="request-parameters.9"></a>

<table><thead><tr><th width="125.73046875">Parameter</th><th width="476.51953125">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>bsId</td><td>Build session Id</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testStage</td><td>Test Stage name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testGroupId</td><td>Id of the test group</td><td> </td></tr><tr><td>offset</td><td>Result offset - used for pagination</td><td> </td></tr><tr><td>limit</td><td>Result limit - used for pagination (max limit 100,000 records)</td><td> </td></tr></tbody></table>

#### Request Samples <a href="#request-samples.7" id="request-samples.7"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v2/tests/builds/{bsId}/test-stages/{testStage}/runs
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.4" id="response-sample.4"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
    "data":
    {
        "total": 163,
        "list":
        [
            {
                "executionId": "eId1",
                "testName": "it should return ok",
                "results":
                {
                    "passed": 0,
                    "failed": 0,
                    "skipped": 1,
                    "total": 1
                },
                "testGroupId": "group 1"
            }
        ],
        "metadata":
        {
            "appName": "My app",
            "branchName": "Development",
            "buildName": "21.2",
            "buildSessionId": "45699dbe-b7a9-4b95-98ba-10e9173a1221",
            "testStage": "Acceptance Tests",
            "txId": "APIGW-2c8688c2-6c93-48df-9e21-c15862f4as5f",
            "dateTime": "Tue, 01 Aug 2023 04:53:12 GMT"
        },
        "summary":
        {
            "total": 163,
            "passed": 80,
            "skipped": 94,
            "failed": 0
        }
    }
}
```

{% endcode %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.10" id="sample-shell-command-and-response-.10"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
curl -X GET "https://$DOMAIN/sl-api/v2/tests/builds/{bsId}/test-stages/{testStage}/runs" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK

400 Missing parameters
```

{% endcode %}

### Get Test Runs by app name, branch name, build name and Test Stage <a href="#get-test-runs-by-app-name-branch-name-build-name-and-test-stage" id="get-test-runs-by-app-name-branch-name-build-name-and-test-stage"></a>

Get test runs for a specific build according to the app name, branch name, build name and test stage.

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v2/tests/apps/{appName}/branches/{branchName}/builds/{buildName}/test-stages/{testStage}/runs
```

{% endcode %}

### Request details <a href="#request-details.11" id="request-details.11"></a>

#### Request parameters <a href="#request-parameters.10" id="request-parameters.10"></a>

<table><thead><tr><th width="121.078125">Parameter</th><th width="483.04296875">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>appName</td><td>App Name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>branchName</td><td>Branch Name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>buildName</td><td>Build Name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testStage</td><td>Test Stage name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testGroupId</td><td>Id of the test group</td><td> </td></tr><tr><td>offset</td><td>Result offset - used for pagination</td><td> </td></tr><tr><td>limit</td><td>Result limit - used for pagination (max limit 100,000 records)</td><td> </td></tr></tbody></table>

#### Request Samples <a href="#request-samples.8" id="request-samples.8"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v2/tests/apps/{appName}/branches/{branchName}/builds/{buildName}/test-stages/{testStage}/runs
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.5" id="response-sample.5"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
    "data":
    {
        "total": 163,
        "list":
        [
            {
                "executionId": "eId1",
                "testName": "it should return ok",
                "results":
                {
                    "passed": 0,
                    "failed": 0,
                    "skipped": 1,
                    "total": 1
                },
                "testGroupId": "group 1"
            }
        ],
        "metadata":
        {
            "appName": "My app",
            "branchName": "Development",
            "buildName": "21.2",
            "buildSessionId": "45699dbe-b7a9-4b95-98ba-10e9173a1221",
            "testStage": "Acceptance Tests",
            "txId": "APIGW-2c8688c2-6c93-48df-9e21-c15862f4as5f",
            "dateTime": "Tue, 01 Aug 2023 04:53:12 GMT"
        },
        "summary":
        {
            "total": 163,
            "passed": 80,
            "skipped": 94,
            "failed": 0
        }
    }
}
```

{% endcode %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.11" id="sample-shell-command-and-response-.11"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN//sl-api/v2/tests/apps/{appName}/branches/{branchName}/builds/{buildName}/test-stages/{testStage}/runs" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK

400 Missing parameters
```

{% endcode %}

### Get Test Runs by latest build on app name, branch name and Test Stage <a href="#get-test-runs-by-latest-build-on-app-name-branch-name-and-test-stage" id="get-test-runs-by-latest-build-on-app-name-branch-name-and-test-stage"></a>

Get test runs for a specific build according to the app name, branch name, build name and test stage.

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v2/tests/apps/{appName}/branches/{branchName}/testStages/{testStage}/runs
```

{% endcode %}

### Request details <a href="#request-details.12" id="request-details.12"></a>

#### Request parameters <a href="#request-parameters.11" id="request-parameters.11"></a>

| Parameter   | Description                                                    | Is mandatory?                                                        |
| ----------- | -------------------------------------------------------------- | -------------------------------------------------------------------- |
| appName     | App Name                                                       | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| branchName  | Branch Name                                                    | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| testStage   | Test Stage name                                                | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |
| testGroupId | Id of the test group                                           |                                                                      |
| offset      | Result offset - used for pagination                            |                                                                      |
| limit       | Result limit - used for pagination (max limit 100,000 records) |                                                                      |

#### Request Samples <a href="#request-samples.9" id="request-samples.9"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v2/tests/apps/{appName}/branches/{branchName}/testStages/{testStage}/runs
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.6" id="response-sample.6"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
    "data":
    {
        "total": 163,
        "list":
        [
            {
                "executionId": "eId1",
                "testName": "it should return ok",
                "results":
                {
                    "passed": 0,
                    "failed": 0,
                    "skipped": 1,
                    "total": 1
                },
                "testGroupId": "group 1"
            }
        ],
        "metadata":
        {
            "appName": "My app",
            "branchName": "Development",
            "buildName": "21.2",
            "buildSessionId": "45699dbe-b7a9-4b95-98ba-10e9173a1221",
            "testStage": "Acceptance Tests",
            "txId": "APIGW-2c8688c2-6c93-48df-9e21-c15862f4as5f",
            "dateTime": "Tue, 01 Aug 2023 04:53:12 GMT"
        },
        "summary":
        {
            "total": 163,
            "passed": 80,
            "skipped": 94,
            "failed": 0
        }
    }
}
```

{% endcode %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.12" id="sample-shell-command-and-response-.12"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN///sl-api/v2/tests/apps/{appName}/branches/{branchName}/testStages/{testStage}/runs" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK

400 Missing parameters
```

{% endcode %}

## Recalculation <a href="#recalculation" id="recalculation"></a>

### Get Previous Build to Recalculate <a href="#get-previous-build-to-recalculate" id="get-previous-build-to-recalculate"></a>

{% hint style="warning" %}
This specific API is in **beta** mode. Please contact your Customer Success representative for details.
{% endhint %}

Get a list of previous builds that the TIA can re-calculate against them

```
/sl-api/v1/builds/{bsId}/test-stages/{testStage}/previous
```

### Request details <a href="#request-details.13" id="request-details.13"></a>

#### Request parameters <a href="#request-parameters.12" id="request-parameters.12"></a>

<table><thead><tr><th width="122.82421875">Parameter</th><th width="486.17578125">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>bsId</td><td>Build Session Id</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testStage</td><td>Test stage name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>offset</td><td>Result offset - Used for pagination</td><td> </td></tr><tr><td>limit</td><td>Result limit - Used for pagination (max limit 100,000 records)</td><td> </td></tr><tr><td>branchName</td><td>Limit query to a specific branch</td><td> </td></tr></tbody></table>

#### Request Sample <a href="#request-sample" id="request-sample"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/builds/{bsId}/test-stages/{testStage}/previous
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.7" id="response-sample.7"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data": {
    "total": 500,
    "next": 50,
    "previous": 0,
    "list": [
      {
        "branchName": "dev-1",
        "buildName": "build-1",
        "bsId": "some-bsid"
      }
    ]
  }
}
```

{% endcode %}

#### Sample Shell command and response: <a href="#sample-shell-command-and-response-.13" id="sample-shell-command-and-response-.13"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN/sl-api/v1/builds/$BSID/test-stages/$TEST_STAGE}/previous" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK

400 Missing parameters
```

{% endcode %}

### Re-calculate Recommendations Based on Baseline BuildSessionId <a href="#re-calculate-recommendations-based-on-baseline-buildsessionid" id="re-calculate-recommendations-based-on-baseline-buildsessionid"></a>

{% hint style="info" %}
This specific API is in **beta** mode. Please contact your Customer Success representative for details.
{% endhint %}

Re-calculation of recommendations to specific build and test stage

```
/sl-api/v1/tia/builds/{bsId}/test-stages/{testStage}/recommendations/calculate
```

### Request details <a href="#request-details.14" id="request-details.14"></a>

<table><thead><tr><th width="131.6328125">Parameter</th><th width="423.4609375">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>bsId</td><td>Build Session Id</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testStage</td><td>Test stage name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>baselineBsId</td><td>Build Session ID against which to recalculate</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr></tbody></table>

#### Request Sample <a href="#request-sample.1" id="request-sample.1"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
/sl-api/v1/tia/builds/${bsId}/test-stages/${testStage}/recommendations/calculate?baselineBsId=${baseLineBsID}
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
```

{% endcode %}

#### Response Sample <a href="#response-sample.8" id="response-sample.8"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
{
  "data": {
    "recommendationsUrl": "/sl-api/v1/tia/builds/ff1e8adf-2617-4320-a6ec-aab25b46f15a/test-stages/Unit Tests/recommendations"
  }
}
```

{% endcode %}

#### Sample Shell Command and Response: <a href="#sample-shell-command-and-response" id="sample-shell-command-and-response"></a>

{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X GET "https://$DOMAIN/sl-api/v1/tia/builds/$BSID/test-stages/$TEST_STAGE/recommendations/calculate?baselineBsId=$BASELINE_BSID" \
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \

200 OK

400 Missing parameters
```

{% endcode %}

## Enable/Disable TIA <a href="#enable-disable-tia" id="enable-disable-tia"></a>

Enable/Disable TIA for a given app/branch

{% code overflow="wrap" lineNumbers="true" %}

```
POST /sl-api/v1/tia/apps/{appName}/branches/{branchName}/test-stages/{testStage}/test-selection-status
```

{% endcode %}

### Request details <a href="#request-details.15" id="request-details.15"></a>

#### Request parameters <a href="#request-parameters.13" id="request-parameters.13"></a>

<table><thead><tr><th width="143.33203125">Parameter</th><th width="436.2890625">Description</th><th>Is mandatory?</th></tr></thead><tbody><tr><td>appName</td><td>App Name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>branchName</td><td>Branch Name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr><tr><td>testStage</td><td>Test Stage name</td><td><mark style="color:red;background-color:red;"><strong><code>Mandatory</code></strong></mark></td></tr></tbody></table>

#### Request body <a href="#request-body.1" id="request-body.1"></a>

| Parameter             | Description        | Default value | Is mandatory?                                                        |
| --------------------- | ------------------ | ------------- | -------------------------------------------------------------------- |
| `testSelectionStatus` | Enable/Disable TIA |               | <mark style="color:red;background-color:red;">**`Mandatory`**</mark> |

#### Request Samples <a href="#request-samples.10" id="request-samples.10"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
POST /sl-api/v1/tia/apps/{appName}/branches/{branchName}/test-stages/{testStage}/test-selection-status HTTP/1.1
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
{
  "testSelectionStatus": true
}

HTTP/1.1 200 test selection status updated
HTTP/1.1 400 Bad request
HTTP/1.1 500 Server error
```

{% endcode %}

#### Sample Shell command and response <a href="#sample-shell-command-and-response-.14" id="sample-shell-command-and-response-.14"></a>

{% tabs %}
{% tab title="Linux" %}
{% code overflow="wrap" lineNumbers="true" %}

```sh
curl -X POST "https://$DOMAIN/sl-api/v1/tia/apps/${appName}/branches/${branchName}/test-stages/${testStage}/test-selection-status"
  -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"testSelectionStatus\": true}"
```

{% endcode %}
{% endtab %}

{% tab title="Powershell" %}
{% code overflow="wrap" lineNumbers="true" %}

```powershell
Invoke-RestMethod -Uri "https://$SL_DOMAIN/sl-api/v1/tia/apps/${appName}/branches/${branchName}/test-stages/${testStage}/test-selection-status" -Method 'Post' \
  -Headers @{'Authorization'="Bearer $SEALIGHTS_AGENT_TOKEN";'Content-Type'='application/json'} 
  -Body @{'testSelectionStatus'=true}
```

{% endcode %}
{% endtab %}
{% endtabs %}
