Hosts
manage your hosts via the API
get
https://api.cloudradar.io
/v1/hosts/
Get Hosts
Bash
Powershell
Python
curl -X GET \
https://api.cloudradar.io/v1/hosts/ \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
$headers = @{'Authorization' = 'Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'}
$response = Invoke-RestMethod -Headers $headers -Uri "https://api.cloudradar.io/v1/hosts/"
$response.hosts
#!/usr/bin/env python
import requests
import sys
token = '33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
url = 'https://api.cloudradar.io/v1/hosts/'
headers = { 'Authorization': 'Bearer '+token }
response = requests.request("GET", url, headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text)
sys.exit(response.status_code)
# Decode the json object to a python list
hosts = response.json()['hosts']
# Iterate over the list
for host in hosts:
print("Name: %s, Connect: %s, Muted: %s" % (host['name'],host['connect'],host['muted']))
post
https://api.cloudradar.io
/v1/hosts/
Create a host
Bash
Powershell
curl -X POST \
https://api.cloudradar.io/v1/hosts/ \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b' \
-H 'Content-Type: application/json' \
-d '{
"name":"host.example.com",
"connect":"host.example.com",
"description":"Nice host. Isn'\''t it?",
"tags": ["Tag 1","Tag 2","Berlin","Server"],
"cagent":true,
"dashboard":true
}'
$newhost = @{
'name' = 'host.example.com'
'connect' = 'host.example.com'
'description' = 'Nice host'
'cagent' = $true
'dashboard' = $true
}
$json = $newhost | ConvertTo-Json
$headers = @{
'Authorization' = 'Bearer ad42b039ef8c8e3b2d3e2fa396eae3f1c332503999575515'
'Content-Type' = 'application/x-www-form-urlencoded'
}
$response = Invoke-RestMethod -Headers $headers -Method Post -Body $json -ContentType 'application/json' -Uri "https://api.cloudradar.io/v1/hosts/"
$response.host
delete
https://api.cloudradar.io
/v1/hosts/<HOST_UUID>
Delete a host
curl -X DELETE \
'https://api.cloudradar.io/v1/hosts/4ad9936f-f6ff-4484-b1ae-fd2c2e0e3d10?purgeFromReports=1' \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
patch
https://api.cloudradar.io
/v1/hosts/<HOST_UUID>
Update host properties
curl -X PATCH \
https://api.cloudradar.io/v1/hosts/be9b90f4-5dff-4fec-8ef4-bb2bea07bf5c \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b' \
-H 'Content-Type: application/json' \
-d '{
"name":"host2.example.com",
"connect":"1.1.1.1",
"tags":[],
"active": true,
"cagent": false
}'
The following example shows how to mute a host from the command line with a simple python script. The host UUID is expected as a command line parameter, for example python mute-host.py d25ad016-d40a-46e8-9aaa-b7df6929cfe0

The following example uses Powershell to create a host via the API, download the agent, and install it with the credentials of the newly created host.
$cagent_version="1.4.0"
$newhost = @{
'name' = $env:computername
'connect' = $null
'cagent' = $true
'dashboard' = $true
}
$json = $newhost | ConvertTo-Json
$headers = @{
'Authorization' = 'Bearer ad42b039ef8c8e3b2d3e2fa396eae3f1c332503999575515'
'Content-Type' = 'application/json'
}
$response = Invoke-RestMethod `
-Headers $headers `
-Method Post `
-Body $json `
-ContentType 'application/json' `
-Uri "https://api.cloudradar.io/v1/hosts/"
$response
$TempDir = [System.IO.Path]::GetTempPath()
cd $TempDir
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url="https://repo.cloudradar.io/windows/cagent/cagent-plus_$($cagent_version)_Windows_64.msi"
Invoke-WebRequest -Uri $url `
-OutFile "cagent-plus_$($cagent_version)_Windows_64.msi"
msiexec /i cagent-plus_$($cagent_version)_Windows_64.msi `
/q /quiet `
HUB_URL="https://hub.cloudradar.io/ctrapper/" `
HUB_USER="$($response.host.uuid)" `
HUB_PASSWORD="$($response.host.hub_password)"
del .\cagent-plus_$($cagent_version)_Windows_64.msi

mute-host.py
#!/usr/bin/env python
import requests
import sys
import json
hostUUID = sys.argv[1]
token = '33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
url = 'https://api.cloudradar.io/v1/hosts/' + sys.argv[1]
headers = { 'Authorization': 'Bearer '+token }
payload = { 'muted': True }
response = requests.request("PATCH", url, data=json.dumps(payload), headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text + "\n")
sys.exit(response.status_code)
print("Request sent.")

mute-all-hosts.py
#!/usr/bin/env python
import requests
import sys
import json
token = '33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
url = 'https://api.cloudradar.io/v1/hosts/'
headers = { 'Authorization': 'Bearer '+token }
#
# Get list of all hosts
#
response = requests.request("GET", url, headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text)
sys.exit(response.status_code)
# Decode the json object to a python list
hosts = response.json()['hosts']
payload = { 'muted': True }
# Iterate over the list
for host in hosts:
url = 'https://api.cloudradar.io/v1/hosts/' + host['uuid']
response = requests.request("PATCH", url, data=json.dumps(payload), headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text + "\n")
sys.exit(response.status_code)
print("Host %s muted" % host['name'])
Copy link
On this page
get
Get Hosts
post
Create a host
delete
Delete a host
patch
Update host properties
Examples