# Load Testing API

You can automate the process of load testing your web applications or APIs, and easily incorporate load testing into your CI/CD pipeline.

Our API provides a wide range of features, including the ability to create load test plans, run load tests, and retrieve detailed reports and metrics on test results. You can also create environment variables and test data (CSV) using this API. The API is designed to be easy to use, with a RESTful architecture and JSON-based responses.

In this section, you will find the APIs for `test` and `plan` endpoints. It's recommended to start the load test with a test plan using [this](#create-a-load-test-with-plan-recommended) endpoint. You can create test plans easily with no-code UI using [Ddosify Cloud](https://app.ddosify.com/load/test-plans). You can select the `Save as Test Plan` in the summary page of the test suite. Once you create the test plan you can get the test plan id from the URL: `https://app.ddosify.com/load/configure-test-plans/<TEST_PLAN_ID>`

* [Create a Load Test (POST)](#create-a-load-test)
* [Create a Load Test with Plan (POST)](#create-a-load-test-with-plan-recommended) <- Recommended
* [List Load Tests (GET)](#get-load-tests)
* [Retrieve the Load Test (GET)](#retrieve-details-of-the-load-test)
* [Result of the Load Test (GET)](#result-of-load-test)
* [Stop the Load Test (GET)](#stop-the-load-test)
* [Get Supported Load Locations (GET)](#get-supported-load-locations)<br>
* [Create Test Plan (POST)](#create-a-load-test-plan)
* [List Test Plans (GET)](#get-load-test-plans)
* [Retrieve the Test Plan (GET)](#retrieve-details-of-the-load-test-plan)
* [Update the Test Plan (PATCH)](#update-the-load-test-plan)
* [Delete the Test Plan (DELETE)](#delete-the-load-test-plan)<br>
* [Create Environment (POST)](#create-environment)
* [List Environments (GET)](#get-environments)
* [Retrieve the Environment (GET)](#retrieve-details-of-the-environment)
* [Update the Environment (PATCH)](#update-the-environment)
* [Delete the Environment (DELETE)](#delete-the-environment)<br>
* [Create Test Data (POST)](#create-test-data)
* [List Test Data (GET)](#get-test-data)
* [Retrieve the Test Data (GET)](#retrieve-details-of-the-test-data)
* [Delete the Test Data (DELETE)](#delete-the-test-data)

You can also find different [examples](https://docs.ddosify.com/ddosify/api/load-testing-api/load-testing-examples) of this API.&#x20;

{% hint style="warning" %}
All endpoints require the `X-API-KEY` header for authentication. Please check the [Get Your API Key](https://docs.ddosify.com/ddosify/api/..#get-your-api-key) section to learn how you can get it.
{% endhint %}

{% hint style="info" %}
For every successful load test, you'll be charged for `request_count` and `duration` in the body `config_data`.
{% endhint %}

{% hint style="info" %}
API concurrency limit is 5 **requests per second** for GET endpoints and 2 **requests per second** for others. You will get `HTTP 429` (Concurrency Limit Exceeded) when you reach the concurrency.
{% endhint %}

### Load Test

## Create a Load Test

<mark style="color:green;">`POST`</mark> `https://api.ddosify.com/v1/load/test/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

#### Request Body

| Name                                           | Type   | Description                                           |
| ---------------------------------------------- | ------ | ----------------------------------------------------- |
| name<mark style="color:red;">\*</mark>         | String | Name of the test                                      |
| config\_data<mark style="color:red;">\*</mark> | JSON   | Configuration of the load test. [More](#config-data). |

{% tabs %}
{% tab title="201: Created Test Created" %}

```json
{
    "id": "fda3642b-df27-409d-b24d-63f861840ac5",
    "test_url": "https://app.ddosify.com/load/report/fda3642b-df27-409d-b24d-63f861840ac5",
    "status": "initial",
    "failure_reason": null
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Request Parameters" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Create a Load Test with Plan (Recommended)

<mark style="color:green;">`POST`</mark> `https://api.ddosify.com/v1/load/test/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

#### Request Body

| Name                                                       | Type   | Description                                                                                        |
| ---------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>                     | String | Name of the test                                                                                   |
| test\_plan\_template\_id<mark style="color:red;">\*</mark> | UUID   | Test Plan ID. Create test plan with [this](#create-a-load-test-plan) endpoint.                     |
| environment\_id                                            | UUID   | Environment ID to override the test. Get the environments from [this](#get-environments) endpoint. |

{% tabs %}
{% tab title="201: Created Test Created" %}

```javascript
{
    "id": "fda3642b-df27-409d-b24d-63f861840ac5",
    "test_url": "https://app.ddosify.com/load/report/fda3642b-df27-409d-b24d-63f861840ac5",
    "status": "initial",
    "failure_reason": null
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Request Parameters" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Get Load Tests

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/load/test/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK List of load tests" %}

```json
[
    {
        "id": "0b04ac74-b389-4749-9fa8-7484900d8319",
        "environment_id": null,
        "test_plan_template_id": null,
        "name": "Test 14",
        "testdata_ids": null,
        "date_created": "2023-03-04T00:25:50.225449Z",
        "status": "done",
        "failure_reason": null
    },
    {
        "id": "83cef293-3929-4137-a107-8890d96c43b1",
        "environment_id": null,
        "test_plan_template_id": null,
        "name": "Admin Test 10",
        "testdata_ids": null,
        "date_created": "2023-02-24T09:56:01.765072Z",
        "status": "done",
        "failure_reason": null
    },
    {
        "id": "82d8b25f-6e78-4281-b7db-b7235c0a9a2d",
        "environment_id": null,
        "test_plan_template_id": null,
        "name": "Admin Test 10",
        "testdata_ids": null,
        "date_created": "2023-02-23T11:54:50.012640Z",
        "status": "done",
        "failure_reason": null
    }
]
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Retrieve details of the Load Test

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/load/test/<TEST_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK Details of load test" %}

```json
{
    "id": "5308bc3c-7bc3-4a25-95d8-abdb57042098",
    "environment_id": null,
    "test_plan_template_id": null,
    "name": "Test 14",
    "config_data": {
        "steps": [
            {
                "id": 1,
                "url": "https://servdown.com",
                "name": "Home Page",
                "method": "GET",
                "others": {
                    "h2": false,
                    "keep-alive": false,
                    "disable-redirect": false,
                    "disable-compression": false
                },
                "headers": {
                    "Host": "asgfasfgas"
                },
                "payload": "{\"id\": 5}",
                "timeout": 15
            }
        ],
        "duration": 20,
        "load_type": "linear",
        "proxy_config": {
            "DE": 50,
            "US": 50
        },
        "request_count": 100
    },
    "testdata_ids": null,
    "date_created": "2023-03-02T18:01:45.819888Z",
    "status": "done",
    "failure_reason": null
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Result of Load Test

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/load/test/<TEST_ID>/result/`

This endpoint waits until the test is finished. [More](#test-result).

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK Result of load test." %}

```json
{
    "test_url": "https://app.ddosify.com/load/report/9272cecd-b844-43bc-9702-469895f20d90",
    "results": {
        "steps": [
            {
                "id": 1,
                "error_dist": {},
                "fail_count": 0,
                "location_dist": {
                    "DE": {
                        "error_dist": {},
                        "fail_count": 0,
                        "location_dist": {},
                        "success_count": 500,
                        "response_times": {
                            "avg": 26,
                            "max": 63,
                            "min": 19,
                            "p80": 29,
                            "p90": 33,
                            "p95": 37,
                            "p99": 56,
                            "median": 24,
                            "stddev": 6
                        },
                        "iteration_count": 500,
                        "status_code_dist": {
                            "405": 500
                        }
                    },
                    "US": {
                        "error_dist": {},
                        "fail_count": 0,
                        "location_dist": {},
                        "success_count": 500,
                        "response_times": {
                            "avg": 172,
                            "max": 201,
                            "min": 162,
                            "p80": 175,
                            "p90": 178,
                            "p95": 181,
                            "p99": 193,
                            "median": 171,
                            "stddev": 5
                        },
                        "iteration_count": 500,
                        "status_code_dist": {
                            "405": 500
                        }
                    }
                },
                "success_count": 1000,
                "response_times": {
                    "avg": 99,
                    "max": 201,
                    "min": 19,
                    "p80": 172,
                    "p90": 175,
                    "p95": 178,
                    "p99": 189,
                    "median": 113,
                    "stddev": 73
                },
                "iteration_count": 1000,
                "status_code_dist": {
                    "405": 1000
                }
            },
            {
                "id": 2,
                "error_dist": {},
                "fail_count": 0,
                "location_dist": {
                    "DE": {
                        "error_dist": {},
                        "fail_count": 0,
                        "location_dist": {},
                        "success_count": 500,
                        "response_times": {
                            "avg": 48,
                            "max": 242,
                            "min": 35,
                            "p80": 51,
                            "p90": 57,
                            "p95": 70,
                            "p99": 131,
                            "median": 44,
                            "stddev": 17
                        },
                        "iteration_count": 500,
                        "status_code_dist": {
                            "200": 500
                        }
                    },
                    "US": {
                        "error_dist": {},
                        "fail_count": 0,
                        "location_dist": {},
                        "success_count": 500,
                        "response_times": {
                            "avg": 323,
                            "max": 807,
                            "min": 296,
                            "p80": 317,
                            "p90": 332,
                            "p95": 383,
                            "p99": 684,
                            "median": 307,
                            "stddev": 64
                        },
                        "iteration_count": 500,
                        "status_code_dist": {
                            "200": 500
                        }
                    }
                },
                "success_count": 1000,
                "response_times": {
                    "avg": 186,
                    "max": 807,
                    "min": 35,
                    "p80": 309,
                    "p90": 317,
                    "p95": 332,
                    "p99": 678,
                    "median": 269,
                    "stddev": 145
                },
                "iteration_count": 1000,
                "status_code_dist": {
                    "200": 1000
                }
            }
        ],
        "fail_count": 0,
        "location_dist": {
            "DE": {
                "fail_count": 0,
                "success_count": 500,
                "response_times": {
                    "avg": 37,
                    "max": 242,
                    "min": 19,
                    "p80": 46,
                    "p90": 52,
                    "p95": 59,
                    "p99": 96,
                    "median": 37,
                    "stddev": 17
                },
                "iteration_count": 500
            },
            "US": {
                "fail_count": 0,
                "success_count": 500,
                "response_times": {
                    "avg": 247,
                    "max": 807,
                    "min": 162,
                    "p80": 309,
                    "p90": 317,
                    "p95": 332,
                    "p99": 678,
                    "median": 249,
                    "stddev": 88
                },
                "iteration_count": 500
            }
        },
        "success_count": 1000,
        "response_times": {
            "avg": 142,
            "max": 807,
            "min": 19,
            "p80": 303,
            "p90": 309,
            "p95": 317,
            "p99": 400,
            "median": 163,
            "stddev": 122
        },
        "iteration_count": 1000
    }
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Stop the Load Test

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/load/test/<TEST_ID>/stop/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK Load test is stopped" %}

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

{% endtab %}
{% endtabs %}

## Get Supported Load Locations

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/load/locations/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK List of supported load locations" %}

```json
{
    "countries": [
        "AU",
        "BE",
        "CA",
        "CH",
        "CN",
        "DE",
        "ES",
        "FI",
        "FR",
        "GB",
        "HK",
        "HR",
        "HU",
        "IL",
        "IT",
        "JP",
        "NL",
        "NO",
        "PL",
        "RO",
        "RS",
        "SE",
        "TR",
        "UA",
        "US"
    ]
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

{% endtab %}
{% endtabs %}

#### Config Data

Config data contains the configuration of the load test to [start a load test](#start-a-load-test) and [create load test plan](#create-a-load-test-plan) endpoints. Here is an example:&#x20;

```json
{
    "steps": [
        {
            "id": 1,
            "url": "https://servdown.com",
            "name": "Home Page",
            "method": "POST",
            "others": {
                "h2": false,
                "disable-redirect": false,
                "disable-compression": false
            },
            "headers": {
                "Test-Header": "Test Value",
                "Test-Header2": "Test Value2"
            },
            "payload": "{\"id\": 24}",
            "timeout": 15
        },
        {
            "id": 2,
            "url": "https://app.servdown.com",
            "name": "Servdown App",
            "method": "GET",
            "others": {
                "h2": false,
                "disable-redirect": false,
                "disable-compression": false
            },
            "timeout": 15
        }
    ],
    "proxy_config": {
        "US": 50,
        "DE": 50
    },
    "iteration_count": 1000,
    "load_type": "linear",
    "duration": 20
}
```

This load-testing configuration includes `two` steps, each of which represents a specific action to be executed by the load-testing tool.

The first step represents a `POST` request to the "[https://servdown.com](https://servdown.com/)" URL with a payload of `{"id": 24}`. The headers of the request include `Test-Header` with a value of `Test Value` and `Test-Header2` with a value of `Test Value2`. The timeout for this step is set to `15` seconds.

The second step represents a `GET` request to the "[https://app.servdown.com](https://app.servdown.com/)" URL. The timeout for this step is also set to `15` seconds.

The `proxy_config` field indicates that the load testing tool will use a mix of `US (United States)` and `DE (Germany)` servers, with a `50/50` distribution. You can get the full list of the supported locations by using [this](#get-supported-load-locations) endpoint.

The `iteration_count` field indicates that the load testing tool will execute each step `1000` times. There will be a total of `1000*2=2000` requests.

The `load_type` field specifies a `linear` load pattern, which means that the load will be the same over time.

The `duration` field indicates that the load testing will last for `20` seconds.

| Key            | Supported                                                                                                                      | Description                                                                                    |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |
| `proxy_config` | `"AU","BE","CA","CH","CN","DE","ES","FI","FR","GB","HK","HR","HU","IL","IT","JP","NL","NO","PL","RO","RS","SE","TR","UA","US"` | Supported locations. You can get the list with [this](#get-supported-load-locations) endpoint. |
| `load_type`    | `"linear", "waved", "incremental"`                                                                                             | Type of the load. [More](https://github.com/ddosify/ddosify#load-types).                       |

### Load Test Plan

## Create a Load Test Plan

<mark style="color:green;">`POST`</mark> `https://api.ddosify.com/v1/load/plan/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

#### Request Body

| Name                                           | Type   | Description                                           |
| ---------------------------------------------- | ------ | ----------------------------------------------------- |
| name<mark style="color:red;">\*</mark>         | String | Test plan name. It's unique.                          |
| config\_data<mark style="color:red;">\*</mark> | JSON   | Configuration of the load test. [More](#config-data). |

{% tabs %}
{% tab title="201: Created Test Plan Created" %}

```json
{
    "id": "49350aff-1b77-493f-bb20-9742ed345a0c"
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}

{% tab title="400: Bad Request Invalid Request Parameters" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}
{% endtabs %}

## Get Load Test Plans

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/load/plan/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK List of load test plans" %}

```json
[
    {
        "id": "6c140d00-c01f-4d60-935a-6d4424f49497",
        "test_count": 1,
        "environment_id": null,
        "name": "Fatih Test TestPlan Template 392124212242",
        "testdata_ids": null,
        "date_created": "2023-02-23T10:33:20.848546Z"
    },
    {
        "id": "d5c3b48c-cea1-4949-aae0-caa73bea6242",
        "environment_name": "Test Environment Name 6",
        "test_count": 2,
        "environment_id": "0fe50223-32a5-4cf6-9079-58e02d256331",
        "name": "Fatih Test TestPlan Template 434",
        "testdata_ids": [
            "7feefbce-8189-42f5-9c93-edfe58023b46"
        ],
        "date_created": "2023-02-18T22:06:04.647822Z"
    },
    {
        "id": "3010a2ed-3b01-41cb-a2f0-78b32ddda6c8",
        "test_count": 0,
        "environment_id": null,
        "name": "Fatih Test TestPlan New Name",
        "testdata_ids": null,
        "date_created": "2023-02-14T12:46:14.250734Z"
    }
]
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Retrieve details of the Load Test Plan

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/load/plan/<PLAN_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK Load test plan" %}

```json
{
    "id": "6d0a3cd4-a625-407c-9dc7-c7702b670550",
    "environment_id": null,
    "name": "Test TestPlan Template 1241241",
    "config_data": {
        "steps": [
            {
                "id": 1,
                "url": "https://app.servdown.com/accounts/login/?next=/",
                "method": "GET",
                "headers": {
                    "ContenType": "application/xml",
                    "X-ddosify-key": "ajkndalnasd"
                },
                "payload": "",
                "timeout": 5
            }
        ],
        "duration": 10,
        "load_type": "linear",
        "proxy_config": {
            "DE": 30,
            "GB": 20,
            "US": 50
        },
        "request_count": 100
    },
    "testdata_ids": null,
    "date_created": "2023-02-28T15:36:36.510444Z"
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Update the Load Test Plan

<mark style="color:purple;">`PATCH`</mark> `https://api.ddosify.com/v1/load/plan/<PLAN_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

#### Request Body

| Name         | Type   | Description                                           |
| ------------ | ------ | ----------------------------------------------------- |
| name         | String | Test plan name                                        |
| config\_data | JSON   | Configuration of the load test. [More](#config-data). |

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

```json
{
    "id": "49350aff-1b77-493f-bb20-9742ed345a0c",
    "environment_id": null,
    "name": "TestPlan New Name",
    "config_data": {
        "steps": [
            {
                "id": 1,
                "url": "https://app.servdown.com/accounts/login/?next=/",
                "method": "GET",
                "headers": {
                    "ContenType": "application/xml",
                    "X-ddosify-key": "ajkndalnasd"
                },
                "payload": "",
                "timeout": 5
            }
        ],
        "duration": 10,
        "load_type": "linear",
        "proxy_config": {
            "DE": 30,
            "GB": 20,
            "US": 50
        },
        "request_count": 100
    },
    "testdata_ids": null
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Delete the Load Test Plan

<mark style="color:red;">`DELETE`</mark> `https://api.ddosify.com/v1/load/plan/<PLAN_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="204: No Content " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

### Environment

## Create Environment

<mark style="color:green;">`POST`</mark> `https://api.ddosify.com/v1/environment/`

[Example](https://docs.ddosify.com/ddosify/api/load-testing-examples#create-environment).

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

#### Request Body

| Name                                   | Type   | Description                    |
| -------------------------------------- | ------ | ------------------------------ |
| name<mark style="color:red;">\*</mark> | String | Environment name. It's unique. |
| vars<mark style="color:red;">\*</mark> | JSON   | Variables. [More](#vars).      |

{% tabs %}
{% tab title="201: Created Environment Created" %}

```json
{
    "id": "e5cf444d-9d76-4ba6-843c-b20d2bcf3302"
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}

{% tab title="400: Bad Request Invalid Request Parameters" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}
{% endtabs %}

## Get Environments

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/environment/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK List of environments" %}

````javascript
```json
[
    {
        "id": "e5cf444d-9d76-4ba6-843c-b20d2bcf3302",
        "name": "Test Environment Name 5",
        "vars": [
            {
                "key": "test_key_1_bool",
                "value": false
            },
            {
                "key": "test_key_2_string",
                "value": "test_value_2"
            },
            {
                "key": "test_key_2_number_int",
                "value": 15
            },
            {
                "key": "test_key_2_number_float",
                "value": 15.2
            },
            {
                "key": "test_key_2_number_list",
                "value": [
                    14,
                    12,
                    15
                ]
            }
        ],
        "date_created": "2023-03-05T20:59:13.440806Z"
    },
    {
        "id": "8ad0f224-c338-4722-9c6d-ef14abcf8449",
        "name": "Test Environment Name 3",
        "vars": [
            {
                "key": "test_key_1",
                "value": false
            },
            {
                "key": "test_key_2",
                "value": "test_value_2"
            }
        ],
        "date_created": "2023-03-05T19:29:20.582063Z"
    }
]
````

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Retrieve details of the Environment

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/environment/<ENVIRONMENT_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK Environment" %}

```json
{
    "id": "e5cf444d-9d76-4ba6-843c-b20d2bcf3302",
    "name": "Test Environment Name 5",
    "vars": [
        {
            "key": "test_key_1_bool",
            "value": false
        },
        {
            "key": "test_key_2_string",
            "value": "test_value_2"
        },
        {
            "key": "test_key_2_number_int",
            "value": 15
        },
        {
            "key": "test_key_2_number_float",
            "value": 15.2
        },
        {
            "key": "test_key_2_number_list",
            "value": [
                14,
                12,
                15
            ]
        }
    ],
    "date_created": "2023-03-05T20:59:13.440806Z"
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Update the Environment

<mark style="color:purple;">`PATCH`</mark> `https://api.ddosify.com/v1/environment/<ENVIRONMENT_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

#### Request Body

| Name | Type   | Description                    |
| ---- | ------ | ------------------------------ |
| name | String | Environment name. It's unique. |
| vars | JSON   | Variables. [More](#vars).      |

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

```json
{
    "id": "e5cf444d-9d76-4ba6-843c-b20d2bcf3302",
    "name": "Test Environment Name 12421",
    "vars": [
        {
            "key": "test_key_3",
            "value": 1234
        },
        {
            "key": "test_key_2",
            "value": "test_value_2"
        }
    ]
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Delete the Environment

<mark style="color:red;">`DELETE`</mark> `https://api.ddosify.com/v1/environment/<ENVIRONMENT_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="204: No Content " %}

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```json
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

{% endtab %}
{% endtabs %}

#### vars

`vars` represents the environment variables for [Create Environment](#create-environment) endpoint.

Each key-value pair consists of a `key` and a `value`. The `key` represents the name of the environment variable to be set, and the `value` represents the value to be assigned to that variable.

The types of values can be `bool`, `number`, `string` and `array`. Here is an example of vars:

```json
[
    {"key": "test_key_bool", "value": false},
    {"key": "test_key_string", "value": "test_value_2"},
    {"key": "test_key_number_int", "value": 15},
    {"key": "test_key_number_float", "value": 15.2},
    {"key": "test_key_array", "value": [14, 12, 15]}
]
```

In this specific example, there are five environment variables:

* `test_key_bool` with a type of bool and value of `false`
* `test_key_string` with a type of string and value of `test_value_2`
* `test_key_number_int` with a type of number and value of `15`
* `test_key_number_float` with a type of number and value of `15.2`
* `test_key_array` with a type of `array` and value of `[14, 12, 15]`

### Test Data (CSV)

## Create Test Data

<mark style="color:green;">`POST`</mark> `https://api.ddosify.com/v1/testdata/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

#### Request Body

| Name                                           | Type   | Description                        |
| ---------------------------------------------- | ------ | ---------------------------------- |
| name<mark style="color:red;">\*</mark>         | String | Test Data name. It's unique.       |
| file<mark style="color:red;">\*</mark>         | File   | CSV File                           |
| type                                           | String | Default is `csv`.                  |
| file\_config<mark style="color:red;">\*</mark> | JSON   | File config. [More](#file_config). |

{% tabs %}
{% tab title="201: Created Test Data Created" %}

```json
{
    "id": "6c50cc89-8c1f-46f1-af9d-d61fdfc4c2f4",
    "name": "name_of_file",
    "file": "https://URL/media/testdata/38f79dbc-742f-4c73-9451-d30b54f412d2/6c50cc89-8c1f-46f1-af9d-d61fdfc4c2f4/original/medals.csv",
    "type": "csv",
    "file_config": {
        "delimiter": ";",
        "vars": {
            "0": {
                "tag": "year",
                "type": "int"
            },
            "1": {
                "tag": "city"
            },
            "2": {
                "tag": "sport"
            },
            "5": {
                "tag": "event",
                "type": "json"
            },
            "7": {
                "tag": "medal"
            },
            "8": {
                "tag": "no"
            }
        },
        "allow_quota": true,
        "order": "random",
        "skip_first_line": true,
        "skip_empty_line": true
    },
    "no_of_records": 2311,
    "size": 147343,
    "date_created": "2023-01-25T09:47:42.592256Z"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Request Parameters" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    "msg": "Detail..."
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

{% endtab %}
{% endtabs %}

## Get Test Data

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/testdata/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK List of Test Data" %}

```json
[
    {
        "id": "0696f680-96db-4b1a-b435-28238c2d7ecd",
        "name": "transactions2",
        "file": "https://URL/media/staging/testdata/d8beff19-9310-426b-9e21-a610ae956884/0696f680-96db-4b1a-b435-28238c2d7ecd/original/transactions.csv",
        "type": "csv",
        "file_config": {
            "vars": {
                "0": {
                    "tag": "api_key",
                    "type": "string"
                },
                "1": {
                    "tag": "amount",
                    "type": "string"
                },
                "2": {
                    "tag": "from",
                    "type": "string"
                },
                "3": {
                    "tag": "to",
                    "type": "string"
                }
            },
            "order": "random",
            "delimiter": ",",
            "allow_quota": false,
            "skip_empty_line": true,
            "skip_first_line": true
        },
        "no_of_records": 1000,
        "size": 52772,
        "date_created": "2023-02-20T18:59:54.037321Z"
    },
    {
        "id": "f6903569-1a14-4f86-b5c8-5b2e034d739c",
        "name": "test_data",
        "file": "https://URL/media/staging/testdata/d8beff19-9310-426b-9e21-a610ae956884/f6903569-1a14-4f86-b5c8-5b2e034d739c/original/test_data.csv",
        "type": "csv",
        "file_config": {
            "vars": {
                "0": {
                    "tag": "Username",
                    "type": "string"
                },
                "1": {
                    "tag": "City",
                    "type": "string"
                },
                "2": {
                    "tag": "Team",
                    "type": "string"
                },
                "3": {
                    "tag": "Payload",
                    "type": "json"
                },
                "4": {
                    "tag": "Age",
                    "type": "int"
                }
            },
            "order": "random",
            "delimiter": ",",
            "allow_quota": false,
            "skip_empty_line": true,
            "skip_first_line": true
        },
        "no_of_records": 99,
        "size": 1177,
        "date_created": "2023-02-20T18:59:14.151061Z"
    }
]
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

{% endtab %}
{% endtabs %}

## Retrieve details of the Test Data

<mark style="color:blue;">`GET`</mark> `https://api.ddosify.com/v1/testdata/<TEST_DATA_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="200: OK Test Data" %}

```json
{
    "id": "3a6bf234-38c5-4858-87e3-b3fdfb4ffcd2",
    "name": "test_data_success",
    "file": "https://URL/media/staging/testdata/d8beff19-9310-426b-9e21-a610ae956884/3a6bf234-38c5-4858-87e3-b3fdfb4ffcd2/original/test_data.csv",
    "type": "csv",
    "file_config": {
        "vars": {
            "0": {
                "tag": "Username",
                "type": "string"
            },
            "1": {
                "tag": "City",
                "type": "string"
            },
            "2": {
                "tag": "Team",
                "type": "string"
            },
            "3": {
                "tag": "Payload",
                "type": "json"
            },
            "4": {
                "tag": "Age",
                "type": "int"
            }
        },
        "order": "random",
        "delimiter": ",",
        "allow_quota": true,
        "skip_empty_line": true,
        "skip_first_line": true
    },
    "no_of_records": 99,
    "size": 1177,
    "date_created": "2023-02-20T20:48:45.864423Z"
}
```

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

{% endtab %}
{% endtabs %}

## Delete the Test Data

<mark style="color:red;">`DELETE`</mark> `https://api.ddosify.com/v1/testdata/<TEST_DATA_ID>/`

#### Headers

| Name                                        | Type | Description  |
| ------------------------------------------- | ---- | ------------ |
| X-API-KEY<mark style="color:red;">\*</mark> | UUID | Your API KEY |

{% tabs %}
{% tab title="204: No Content " %}

{% endtab %}

{% tab title="403: Forbidden API key is not found or not valid" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="429: Too Many Requests Concurrency Limit Exceeded" %}

{% endtab %}
{% endtabs %}

#### file\_config

Here is an example of **file\_config** for [Create Test Data endpoint](#create-test-data):&#x20;

```json
{
    "delimiter": ";",
    "vars": {
        "0": {
            "tag": "year"
        },
        "1": {
            "tag": "city"
        },
        "2": {
            "tag": "sport"
        },
        "5": {
            "tag": "event"
        },
        "7": {
            "tag": "medal"
        },
        "8": {
            "tag": "no"
        }
    },
    "allow_quota": true,
    "order": "random",
    "skip_first_line": true,
    "skip_empty_line": true
}
```

This configuration defines the settings for parsing a CSV file. Here's a breakdown of each of the options specified:

* `delimiter`: The delimiter is used to separate fields in the CSV file. In this case, the delimiter is `;`
* `vars`: A mapping of column numbers to variable names. Each key represents the column number (starting from 0), and the value is an object that specifies the variable name (tag). For example, the column at index 0 (the first column) will be mapped to the variable `year`, the column at index 1 will be mapped to the variable `city`, and so on.
* `allow_quota`: A boolean value that specifies whether or not the CSV file allows the use of quotes to enclose fields. In this case, it is set to true, indicating that quotes are allowed.
* `order`: Specifies the order in which the rows in the CSV file should be parsed. In this case, it is set to `random`, indicating that the rows should be parsed in random order. **Options**: `random`, `sequential`
* `skip_first_line`: A boolean value that specifies whether or not the first line of the CSV file should be skipped during parsing. In this case, it is set to true, indicating that the first line should be skipped.
* `skip_empty_line`: A boolean value that specifies whether or not empty lines should be skipped during parsing. In this case, it is set to true, indicating that empty lines should be skipped.
