Export Agents using curl script

Updated 1 year ago by admin

This article describes how to connect to the Platform API and download a list of agents as shown in the Web Security -> Deployment section.

You will need:

  • an admin user credential that has been assigned the Agent Installer role (see Administrators)
  • access to curl command (see external article for further information)

Step 1 - Authentication with the API

This example does not use MFA however you can use the MFA endpoints to complete the flow if required.

Copy and paste the following curl command and replace <USERNAME> and <PASSWORD> with the credential for your Agent Installer user.

curl --location 'https://apiv2.clouduss.com/auth' \
--form 'username="<USERNAME>"' \
--form 'password="<PASSWORD"'

If successful, you will receive a JSON response containing an access_token and accounts_id as shown below:

{
"access_token": "879958cf752c9f79538ad9932efe90ad80a939a7",
"token_type": "Bearer",
"expires_in": 86400,
"accounts_id": "b441390e-xxxx-xxxx-xxxx-36d7839f6153",
...all other metadata...
}

Copy the access_token and accounts_id for use in the next step.

Step 2 - Request Agents list

To obtain the list of agents displayed in the Deployment view, use the following curl command with the access_token and accounts_idfrom Step 1:

curl --location 'https://apiv2.clouduss.com/web/agents' \
--header 'X-Uss-Account-Id: <ACCOUNTS_ID>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <ACCESS_TOKEN>'

If successful, you will receive a JSON response containing all of the agents registered to the account.

{
"data": [
{
"id": 264888,
"guid": "cdbe2585-7384-c894-241f-763b97934392",
"name": "Acme Inc Chromebook",
"agent_type": "chromebook",
"last_poll": "2023-10-03T09:24:01+00:00",
"version_old": null,
"version_new": "1.0.0",
"update_status": null,
"v2_switched": 0,
"last_ipv4": "",
"last_ipv6": "",
"last_mac": "",
"last_status": "running",
"last_status_timestamp": "2021-01-20 20:14:14.831398",
"last_username": "timqatest@censornetqa.com",
"fail_open_status": 0,
"last_icap_ip": "169.50.135.56",
"network_detection": 0,
"disable_reason": "enabled",
"agent_chromebook_profile_id": 481,
"agent_profile_id": 481,
"agent_profile_name": "Default Chromebook Profile"
},
...all other results...
],
"meta": {
"page": 1,
"total": 58
}
}

You can then copy and paste the response into online JSON parsing tools, such as JSON Grid (external link) or JSON to CSV (external link), and explore and manipulate the data further, e.g:

More advanced users can automate the use of the JSON data further with additional code and scripts.

Additional Options

You can also use the limit, start and page parameters in the curl request to obtain more specific data.

The sort parameter can be used by specificying the direction and sort property: [{"property":"last_status_timestamp","direction":"DESC"}]

The filter parameter can be used to search by GUID [{"property":"guid","value":"d3fb992b-afad-105d-c0b3-d46224441d49","anyMatch":true,"caseSensitive":false}]

or by hostname [{"property":"name","value":"USSGW","anyMatch":true,"caseSensitive":false}]


How did we do?