Tests
Grafana Cloud

Tests Legacy API

Warning

The Grafana Cloud k6 endpoints under this section are deprecated and planned for removal in the near future. Migrate to the latest Load Tests API endpoints to avoid disruptions.

List load tests

Returns all tests within a specified project. If no project is specified, k6 returns the default project.

You MAY sort or query the results with query parameters.

GET https://api.k6.io/loadtests/v2/tests

Query ParametersTypeDescriptionExample
project_idintegerReturns tests associated with a given project_id/loadtests/v2/tests?project_id={project_id}
ids[]integerReturns tests with given ids./loadtests/v2/tests?ids[]={id_1}&ids[]={id_2}
order_bystringSelects the parameter to use to order the returned tests. Available parameter values: id, name, last_run_time./loadtests/v2/tests?project_id={project_id}&order_by=last_run_time
qstringReturns tests whose name property matches the queried string./loadtests/v2/tests?project_id={project_id}&q=some_string
pageintegerA page number within the paginated result set./loadtests/v2/tests?project_id={project_id}&page=2&page_size=5
page_sizeintegerNumber of results to return per page./loadtests/v2/tests?project_id={project_id}&page=2&page_size=5
json
{
  "k6-runs": [],
  "k6-tests": [
    {
      "id": 0,
      "project_id": 0,
      "user_id": 0,
      "name": "string",
      "created": "2020-08-13T18:28:45Z",
      "updated": "2020-08-13T18:28:45Z",
      "last_test_run_id": "string",
      "test_run_ids": [0],
      "script": "string"
    }
  ],
  "load_zones": [],
  "meta": {
    "count": 1
  }
}

List load tests Cloud v5

Returns all tests within a specified project.

GET /cloud/v5/projects/:projectId/load_tests

Example URL with optional parameters:

GET /cloud/v5/projects/:projectId/load_tests?$top=10&$skip=20&$count=true&$select=id,name,created&$orderby=created desc&$filter=contains(name,'heavy')

Parameters

All parameters are optional.

ParameterDescription
$selectSpecifies a comma-separated list of properties to include in the response.
$orderbySpecifies the sorting order for the returned results. It accepts one or more comma-separated properties with an optional asc (ascending) or desc (descending) keyword.
$topLimits the number of items to return in the response.
$skipSpecifies the number of items to skip in the result set before returning the remaining items. It is used for paging through a large result set.
$countIncludes a count of the total number of items in the result set in the response.
$filterFilters the result set based on specified conditions.

Example request:

http
GET https://api.k6.io/cloud/v5/projects/5276/load_tests?$count=true
Accept: application/json
Authorization: Token 56c166885f9a7fc1e588a1b3cb66f6dd

Example response

http
HTTP/1.1 200
Content-Type: application/json

{
  "@count": "3",
  "value": [
    {
      "created": "2021-05-24T12:59:18.180471Z",
      "id": 4122,
      "name": "Simple login test",
      "project_id": 5276,
      "project_name": "Heavy tests",
      "updated": "2021-05-24T12:59:18.180483Z"
    },
    {
      "created": "2020-07-20T09:32:46.071962Z",
      "id": 3535,
      "name": "Cart checkout test",
      "project_id": 5276,
      "project_name": "Heavy tests",
      "updated": "2020-07-22T08:14:05.164385Z"
    },
    {
      "created": "2020-07-17T15:18:31.274028Z",
      "id": 3533,
      "name": "Cart checkout test (increased VUs)",
      "project_id": 5276,
      "project_name": "Heavy tests",
      "updated": "2020-07-17T15:18:31.274041Z"
    },
  ]
}

Read load test

Returns details of a test with the specified ID.

GET https://api.k6.io/loadtests/v2/tests/{id}

Path ParameterTypeDescription
idintegerA unique integer value identifying this test.
json
{
  "k6-test": {
    "id": 0,
    "project_id": 0,
    "user_id": 0,
    "name": "string",
    "created": "2020-08-13T18:28:45Z",
    "updated": "2020-08-13T18:28:45Z",
    "last_test_run_id": "string",
    "test_run_ids": [],
    "script": "string"
  }
}

Update load test

Partially updates a cloud test.

PATCH https://api.k6.io/loadtests/v2/tests/{id}

Path ParameterTypeDescription
idintegerA unique integer value identifying this test.
Request Body ParameterTypeDescription
namestringName of the test.
scriptstringk6 script to use when starting test runs.
json
{
  "k6-test": {
    "id": 0,
    "project_id": 0,
    "user_id": 0,
    "name": "string",
    "created": "2020-08-13T18:28:45Z",
    "updated": "2020-08-13T18:28:45Z",
    "last_test_run_id": "string",
    "test_run_ids": [0],
    "script": "string"
  }
}

Read load test Cloud v5

Returns details of a test with the specified ID.

GET /cloud/v5/load_tests/:id

Parameters

ParameterDescription
$selectOptional: Specifies a comma-separated list of properties to include in the response.

Example Request:

http
GET https://api.k6.io/cloud/v5/load_tests/3535?$select=id,name
Accept: application/json
Authorization: Token 56c166885f9a7fc1e588a1b3cb66f6dd

Example Response:

http
HTTP/1.1 200
Content-Type: application/json

{
    "id": 3535,
    "name": "Cart checkout test",
}

Delete load test

Deletes a test with the specified test ID.

DELETE https://api.k6.io/loadtests/v2/tests/{id}

Path ParameterTypeDescription
idintegerA unique integer value identifying this test.

RESPONSE 204