Create/Update/Delete Tests Using the ThousandEyes API
The ThousandEyes API supports creating, editing, and deleting tests programmatically.
This feature is restricted to users with Account Admin privileges or higher. Users without account admin privileges will receive an HTTP/403 error when attempting to post a write request.
The NEW, UPDATE and DELETE endpoints have been added to each test endpoint. Content must be submitted using a POST request, and all POST requests must contain a "Content-Type: application/JSON" header.
1
/tests/network/new
2
/tests/network/{testId}/update
3
/tests/network/{testId}/delete
4
5
/tests/dns-trace/new
6
/tests/dns-trace/{testId}/update
7
/tests/dns-trace/{testId}/delete
8
9
/tests/dns-server/new
10
/tests/dns-server/{testId}/update
11
/tests/dns-server/{testId}/delete
12
13
/tests/dns-dnssec/new
14
/tests/dns-dnssec/{testId}/update
15
/tests/dns-dnssec/{testId}/delete
16
17
/tests/http-server/new
18
/tests/http-server/{testId}/update
19
/tests/http-server/{testId}/delete
20
21
/tests/page-load/new
22
/tests/page-load/{testId}/update
23
/tests/page-load/{testId}/delete
24
25
/tests/transactions/{testId}/update
26
/tests/transactions/{testId}/delete
Copied!
To show a basic example of an add request, using cURL:
1
curl https://api.thousandeyes.com/tests/network/new.json?authToken=<my_authToken> \
2
-d '{"interval": 300, "agents": [{"agentId": 113}], "testName": "API network test addition for www.thousandeyes.com", "server": "www.thousandeyes.com"}' \
3
-H "Content-Type: application/json"
Copied!
this will return successfully once the test has been created:
1
{
2
"test": [
3
{
4
"enabled":1,
5
"testId":1586,
6
"testName":"API network test addition for www.thousandeyes.com",
7
"interval":300,
8
"server":"www.thousandeyes.com:80",
9
"agents":[
10
{
11
"agentId":113,
12
"agentName":"Bucharest, Romania",
13
"location":"Bucuresti, Romania",
14
"countryId":"RO",
15
"ipAddress":"89.36.27.146",
16
"prefix":"89.36.24.0/21",
17
"network":"HOSTWAY ROMANIA SRL (AS 39756)",
18
"public":1
19
}
20
],
21
"createdBy":"Dave Fraleigh ([email protected])",
22
"createdDate":"2013-06-12 01:22:40"
23
}
24
]
25
}
Copied!
I can then update the same request by modifying the JSON data:
1
curl https://api.thousandeyes.com/tests/network/1586/update.json?authToken=<my_authtoken> \
2
-d '{"interval": 900, "agents": [{"agentId": 113}], "testName": "this is a new name and interval for my test"}' \
3
-H "Content-Type:application/json"
Copied!
Note that only certain fields can be updated in an update request:
    interval
    testName
    agents
1
{
2
"test": [
3
{
4
"enabled":1,
5
"testId":1586,
6
"testName":"this is a new name and interval for my test",
7
"interval":900,
8
"server":"www.thousandeyes.com:80",
9
"agents":[
10
{
11
"agentId":113,
12
"agentName":"Bucharest, Romania",
13
"location":"Bucuresti, Romania",
14
"countryId":"RO",
15
"ipAddress":"89.36.27.146",
16
"prefix":"89.36.24.0/21",
17
"network":"HOSTWAY ROMANIA SRL (AS 39756)",
18
"public":1
19
}
20
],
21
"createdBy":"Dave Fraleigh ([email protected])",
22
"createdDate":"2013-06-12 01:22:40",
23
"modifiedBy":"Dave Fraleigh ([email protected])",
24
"modifiedDate":"2013-06-12 02:10:13",
25
}
26
]
27
}
Copied!
Then, to delete the same test, run the following command:
1
curl https://api.thousandeyes.com/tests/network/1586/delete.json?authToken=<my_authToken> \
2
-d '' \
3
-H "Content-Type:application/json"
Copied!
You'll get an empty JSON response back, and the test will be gone from the front end.
Last modified 1yr ago
Copy link