How to Use the Agent Collection API Endpoint

Hello, API enthusiasts! Today, we’re diving into the Agent Collection API endpoint. With this powerful API, you can fetch a collection of agents, filter, order, and paginate the result set. In this post, we’ll walk you through examples of how to use it and discuss some useful use-cases you can implement with it.

GET /agents

Base URL:

Bearer Token

How to Use the Agent Collection API Endpoint

Let’s explore some examples on how to interact with the API endpoint.

1. Fetching All Agents

To fetch all agents without any filters or pagination, use the following request:

GET https://[HOSTNAME]/agents?type=beta
Authorization: Bearer <Your-API-Token>

2. Fetching Agents with Filters

The API provides various filter options to fetch agents based on different criteria, such as name, category, agent class, active status, and more. Here’s an example of fetching agents with specific filters:

GET https://[HOSTNAME]/agents?type=beta&filter[name]=example name&filter[category]=network_agent&filter[active]=true
Authorization: Bearer <Your-API-Token>

This request will fetch agents with a name containing “example name,” belonging to the “network_agent” category, and are currently active.

3. Paginating and Sorting Agents

To paginate and sort the agents, use the “page[offset],” “page[limit],” “order[attributes],” and “order[direction]” parameters. The following example fetches agents sorted by name in descending order, with a limit of 10 agents per page and the offset set to the second page:

GET https://[HOSTNAME]/agents?type=beta&page[offset]=2&page[limit]=10&order[attributes]=name&order[direction]=desc
Authorization: Bearer <Your-API-Token>


Here are some useful use-cases you can implement using the Agent Collection API endpoint:

  1. Agent Monitoring Dashboard: Build a monitoring dashboard to display agent status, active incidents, and alert counts. You can use filters like filter[active], filter[warning_alerts][min],filter[warning_alerts][max], filter[critical_alerts][min],filter[critical_alerts][max] to fetch specific agent data.

  2. Resource Allocation and Planning: Analyze agent data to optimize resource allocation, such as determining if any agents are reaching their target test limit or scheduled test limit.

  3. Network Infrastructure Analysis: Investigate network interfaces, access points, and agent types to gain insights into your network infrastructure, identify bottlenecks, and improve overall network performance.

  4. Agent Inventory Management: Keep track of agent categories, classes, software versions, and other attributes to manage agent inventory and plan future updates or expansions.

Don’t forget to replace [HOSTNAME] with your actual API hostname and <Your-API-Token> with your valid API token.

That’s it! Now you have a better understanding of how to interact with the Agent Collection API endpoint and some useful use-cases to implement. Explore the API further, and feel free to share your experiences or ask questions in the community! Happy coding!