---
title: List all Datadog Agents
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Fleet Automation
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# List all Datadog Agents{% #list-all-datadog-agents %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                          |
| ----------------- | ----------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/fleet/agents |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/fleet/agents |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/fleet/agents      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/fleet/agents      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/fleet/agents  |
| uk1.datadoghq.com | GET https://api.uk1.datadoghq.com/api/v2/fleet/agents |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/fleet/agents     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/fleet/agents |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/fleet/agents |

### Overview



Retrieve a paginated list of Datadog Agents.

Returns agents with support for pagination, sorting, and filtering. Use `page_number` and `page_size` to navigate pages, `filter` to narrow by field values, and `tags` to filter by agent tags.
This endpoint requires the `hosts_read` permission.


### Arguments

#### Query Strings

| Name            | Type    | Description                                                                                                                                     |
| --------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| page_number     | integer | Page number for pagination, starting at 0.                                                                                                      |
| page_size       | integer | Number of agents to return per page. Maximum value is 100. Defaults to 10.                                                                      |
| filter          | string  | Filter string to narrow down agent results.                                                                                                     |
| tags            | string  | Comma-separated list of tag keys to select which tags are included in each agent's `tags` attribute. Does not filter which agents are returned. |
| sort_attribute  | string  | Agent attribute to sort results by. Must be a supported attribute name; unsupported values return a 400 error.                                  |
| sort_descending | boolean | Set to `true` to sort results in descending order. Defaults to ascending.                                                                       |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response containing a paginated list of Datadog Agents.

| Parent field | Field                                  | Type     | Description                                                                                     |
| ------------ | -------------------------------------- | -------- | ----------------------------------------------------------------------------------------------- |
|              | data [*required*]                 | [object] | Array of agents matching the query criteria.                                                    |
| data         | attributes [*required*]           | object   | Attributes of a Datadog Agent in the v2 list response.                                          |
| attributes   | agent_version                          | string   | The Datadog Agent version.                                                                      |
| attributes   | api_key_name                           | string   | The name of the API key used by the agent, if available and not redacted.                       |
| attributes   | api_key_uuid                           | string   | The UUID of the API key used by the agent.                                                      |
| attributes   | cloud_provider                         | string   | The cloud provider where the agent is running.                                                  |
| attributes   | cluster_name                           | string   | The Kubernetes cluster name, if the agent runs in a cluster.                                    |
| attributes   | datadog_data_center                    | string   | The Datadog data center the agent reports to.                                                   |
| attributes   | ecs_fargate_cluster_name               | string   | The ECS Fargate cluster name, if the agent runs in an ECS Fargate environment.                  |
| attributes   | ecs_fargate_task_arn                   | string   | The ECS Fargate task ARN, if the agent runs in an ECS Fargate environment.                      |
| attributes   | enabled_products                       | [string] | Datadog products enabled on the agent.                                                          |
| attributes   | env                                    | [string] | Environments the agent is reporting from.                                                       |
| attributes   | first_seen_at                          | int64    | Unix timestamp when the agent was first seen.                                                   |
| attributes   | fleet_policies                         | [string] | Identifiers of fleet policies applied to the agent.                                             |
| attributes   | hostname                               | string   | The hostname of the agent.                                                                      |
| attributes   | instrumentation_error_counts           | int64    | Number of instrumentation errors on the agent. Absent from the response when the count is zero. |
| attributes   | instrumentation_status                 | enum     | The single-step instrumentation status of the Agent. Allowed enum values: `success,failure`     |
| attributes   | integrations                           | [string] | Names of integrations configured on the agent.                                                  |
| attributes   | ip_addresses                           | [string] | IP addresses of the agent host.                                                                 |
| attributes   | is_single_step_instrumentation_enabled | boolean  | Whether single-step instrumentation is enabled on the agent.                                    |
| attributes   | last_restart_at                        | int64    | Unix timestamp of the last agent restart.                                                       |
| attributes   | os                                     | string   | The operating system of the host.                                                               |
| attributes   | otel_collector_deployment_types        | [string] | OpenTelemetry collector deployment types associated with the agent.                             |
| attributes   | otel_collector_distributions           | [string] | OpenTelemetry collector distributions associated with the agent.                                |
| attributes   | otel_collector_versions                | [string] | All OpenTelemetry collector versions associated with the agent.                                 |
| attributes   | otel_resource_attributes               | [string] | OpenTelemetry resource attributes reported by the agent.                                        |
| attributes   | pod_name                               | string   | The Kubernetes pod name, if the agent runs as a pod.                                            |
| attributes   | remote_agent_management                | string   | The remote agent management status.                                                             |
| attributes   | remote_config_status                   | string   | The remote configuration connection status of the agent.                                        |
| attributes   | services                               | [string] | Services running on the agent.                                                                  |
| attributes   | tags                                   | [object] | Tags associated with the agent. Returned as an empty array when the agent has no tags.          |
| tags         | key                                    | string   | The tag key.                                                                                    |
| tags         | value                                  | string   | The tag value.                                                                                  |
| attributes   | team                                   | string   | The team associated with the agent.                                                             |
| data         | id [*required*]                   | string   | The unique agent key identifier.                                                                |
| data         | type [*required*]                 | enum     | The type of the agent resource. Allowed enum values: `agent`                                    |
|              | meta                                   | object   | Metadata for the v2 list of agents, including pagination information.                           |
| meta         | page                                   | object   | Pagination details for the v2 list of agents.                                                   |
| page         | total_count                            | int64    | Total number of agents in the fleet, regardless of any filter.                                  |
| page         | total_filtered_count                   | int64    | Total number of agents matching the current filter criteria.                                    |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": [
    {
      "attributes": {
        "agent_version": "7.50.0",
        "api_key_name": "Production API Key",
        "api_key_uuid": "a1b2c3d4-e5f6-4321-a123-123456789abc",
        "cloud_provider": "aws",
        "cluster_name": "production-us-east-1",
        "datadog_data_center": "us1",
        "ecs_fargate_cluster_name": "my-ecs-cluster",
        "ecs_fargate_task_arn": "arn:aws:ecs:us-east-1:123456789012:task/my-cluster/abc123",
        "enabled_products": [],
        "env": [],
        "first_seen_at": 1699900000,
        "fleet_policies": [],
        "hostname": "my-hostname",
        "instrumentation_error_counts": 3,
        "instrumentation_status": "success",
        "integrations": [],
        "ip_addresses": [],
        "is_single_step_instrumentation_enabled": true,
        "last_restart_at": 1699999999,
        "os": "linux",
        "otel_collector_deployment_types": [],
        "otel_collector_distributions": [],
        "otel_collector_versions": [],
        "otel_resource_attributes": [],
        "pod_name": "datadog-agent-abc123",
        "remote_agent_management": "enabled",
        "remote_config_status": "connected",
        "services": [],
        "tags": [
          {
            "key": "string",
            "value": "string"
          }
        ],
        "team": "platform"
      },
      "id": "my-agent-hostname",
      "type": "agent"
    }
  ],
  "meta": {
    "page": {
      "total_count": 500,
      "total_filtered_count": 42
    }
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Curl command curl -X GET "https://api.datadoghq.com/api/v2/fleet/agents" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" 
                
##### 

```python
"""
List all Datadog Agents returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.fleet_automation_api import FleetAutomationApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = FleetAutomationApi(api_client)
    response = api_instance.list_fleet_agents_v2()

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# List all Datadog Agents returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::FleetAutomationAPI.new
p api_instance.list_fleet_agents_v2()
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// List all Datadog Agents returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewFleetAutomationApi(apiClient)
	resp, r, err := api.ListFleetAgentsV2(ctx, *datadogV2.NewListFleetAgentsV2OptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `FleetAutomationApi.ListFleetAgentsV2`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `FleetAutomationApi.ListFleetAgentsV2`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// List all Datadog Agents returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.FleetAutomationApi;
import com.datadog.api.client.v2.model.FleetAgentsV2Response;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    FleetAutomationApi apiInstance = new FleetAutomationApi(defaultClient);

    try {
      FleetAgentsV2Response result = apiInstance.listFleetAgentsV2();
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling FleetAutomationApi#listFleetAgentsV2");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// List all Datadog Agents returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_fleet_automation::FleetAutomationAPI;
use datadog_api_client::datadogV2::api_fleet_automation::ListFleetAgentsV2OptionalParams;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = FleetAutomationAPI::with_config(configuration);
    let resp = api
        .list_fleet_agents_v2(ListFleetAgentsV2OptionalParams::default())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * List all Datadog Agents returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.FleetAutomationApi(configuration);

apiInstance
  .listFleetAgentsV2()
  .then((data: v2.FleetAgentsV2Response) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
