# CI / CD

In order to get started, you will need to sign into your DoesQA account.\
\
Once in the app, head to **Settings** ( bottom of the menu ) and into **Webhooks**.

From here, you are able to **Create** and **Delete** webhook keys.

### Creating a new key

To create a new key, from the settings menu click on the **+** icon at the top.

A modal will appear and give you the following:

#### Name

Use this field to identify the token, this will be visible instead of the user that triggered the run. An example would be "CI - Staging"

#### Slack Channel

If you have installed our Slack integration, then from here you will be able to pick a channel for the test reports to go to. This is handy if you have a different channel for different environments. By default, these will go to the original channel that you picked when you integrated slack

#### Webhook Key

This is your secret key, only displayed once - so please store this in a safe place. You will need this key in order to authenticate requests coming into our APIs.

### Crafting a webhook call

To trigger test runs remotely, you need to POST to our API. Your **ACCOUNT\_ID** is located on the settings page. Alternatively, you can also do a GET, see the API options below.

## Preview tests before integrating the hook into your pipelines

<mark style="color:blue;">`GET`</mark> `https://app.does.qa/api/hook/ACCOUNT_ID`

Preview a webhook trigger, this can be used for making sure the correct amount of flows are going to trigger and that you have configured any replacement values correctly

#### Query Parameters

| Name                                  | Type   | Description                                                                                                                                                 |
| ------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| key<mark style="color:red;">\*</mark> | String | The [#webhook-key](#webhook-key "mention") above                                                                                                            |
| label                                 | String | Customise the run label, helpful for differentiating runs ( Staging - Build 1234 )                                                                          |
| ids                                   | String | A comma-separated set of  Flow IDs                                                                                                                          |
| recipe                                | String | Recipe ID. Create and manage recipes from [Settings > Recipes](https://app.does.qa/app/settings/recipes)                                                    |
| withAll                               | String | A comma-separated set of tags ( "pipeline,staging" )                                                                                                        |
| withoutAny                            | String | A comma-separated set of tags to exclude ( "wip,dev" )                                                                                                      |
| values                                | String | A url-ecoded JSON object containing keys and values for any overrides to the [values-value-store](https://docs.does.qa/values/values-value-store "mention") |

{% tabs %}
{% tab title="200: OK Successful Response" %}

```
{
    "triggerLabel": "",
    "ids": number[],
    "withAll": string[],
    "withoutAny": string[],
    "hookValues": { [key: string]: string },
    "previews": boolean,
    "triggerName": string,
    "slackChannelId": string,
    "hasUsageAvailable": string,
    "topicType": string,
    "foundFlowsCount": number,
    "preview": boolean
}
```

{% endtab %}

{% tab title="401: Unauthorized Missing / Invalid Webhook Key" %}

{% endtab %}

{% tab title="404: Not Found Missing Information" %}
You should be presented with an error code. Reach out to support and we would be happy to assist.
{% endtab %}

{% tab title="429: Too Many Requests" %}
The request would initiate too many test cases and exceed system limits. Please reduce the number of test cases that would be initiated before trying again.
{% endtab %}

{% tab title="500: Internal Server Error Internal Error - Seek Support" %}

{% endtab %}
{% endtabs %}

## Trigger DoesQA tests externally from the UI

<mark style="color:green;">`POST`</mark> `https://app.does.qa/api/hook/ACCOUNT_ID`

Trigger a webhook, this will take the given parameters, find flows that match and triggers a DoesQA test run.

#### Query Parameters

| Name                                  | Type   | Description                                                                                                                                                 |
| ------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| key<mark style="color:red;">\*</mark> | String | The [#webhook-key](#webhook-key "mention") above                                                                                                            |
| label                                 | String | Customise the run label, helpful for differentiating runs ( Staging - Build 1234 )                                                                          |
| ids                                   | String | A comma-separated set of  Flow IDs                                                                                                                          |
| recipe                                | String | Recipe ID. Create and manage recipes from [Settings > Recipes](https://app.does.qa/app/settings/recipes)                                                    |
| withAll                               | String | A comma-separated set of tags ( "pipeline,staging" )                                                                                                        |
| withoutAny                            | String | A comma-separated set of tags to exclude ( "wip,dev" )                                                                                                      |
| values                                | String | A url-ecoded JSON object containing keys and values for any overrides to the [values-value-store](https://docs.does.qa/values/values-value-store "mention") |

{% tabs %}
{% tab title="200: OK Successful Response" %}

```
{
    "triggerLabel": string,
    "ids": number[],
    "withAll": string[],
    "withoutAny": string[],
    "hookValues": { [key: string]: string },
    "previews": boolean,
    "triggerName": string,
    "slackChannelId": string,
    "hasUsageAvailable": string,
    "topicType": string,
    "foundFlowsCount": number,
    "preview": boolean
}
```

{% endtab %}

{% tab title="401: Unauthorized Missing / Invalid Webhook Key" %}

{% endtab %}

{% tab title="404: Not Found Missing Information" %}
You should be presented with an error code. Reach out to support and we would be happy to assist.
{% endtab %}

{% tab title="500: Internal Server Error Internal Error - Seek Support" %}

{% endtab %}
{% endtabs %}

For any additional assistance in setting up your webhooks, please reach out to support and we would be more than happy to assist!
