---
type: api
title: List agents
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-get-agents
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-get-agents
products:
  - Kibana
---

# List agents

Authentication: required

- Server: `https://{kibana_url}`

## Paths

- `GET` `/api/fleet/agents`
- `GET` `/s/{space_id}/api/fleet/agents`

#### Path parameters

- `space_id` (string) — optional
  An identifier for the space. If `space_id` is not provided in the URL, the default space is used. Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Query string parameters

- `perPage` (integer · default: 20) — optional
  The number of items to return
- `page` (integer · default: 1) — optional
- `kuery` (string) — optional
- `showInactive` (boolean) — optional
- `showUpgradeable` (boolean) — optional
- `sortField` (string) — optional
- `sortOrder` (enum) — optional
  Values: `asc`, `desc`
- `withMetrics` (boolean) — optional
  Return agent metrics, false by default
- `getStatusSummary` (boolean) — optional

## Responses

#### `200`

OK

`application/json`

- `items` (object[])
  - `access_api_key` (string)
  - `access_api_key_id` (string)
  - `active` (boolean)
  - `components` (object[])
    - `id` (string)
    - `message` (string)
    - `status` (enum)
      Values: `starting`, `configuring`, `healthy`, `degraded`, `failed`, `stopping`, `stopped`
    - `type` (string)
    - `units` (object[])
      - `id` (string)
      - `message` (string)
      - `payload` (object)
      - `status` (enum)
        Values: `starting`, `configuring`, `healthy`, `degraded`, `failed`, `stopping`, `stopped`
      - `type` (enum)
        Values: `input`, `output`
  - `default_api_key` (string)
  - `default_api_key_id` (string)
  - `enrolled_at` (string)
  - `id` (string)
  - `last_checkin` (string)
  - `local_metadata` (object)
  - `metrics` (object)
    - `cpu_avg` (number)
      Average agent CPU usage during the last 5 minutes, number between 0-1
    - `memory_size_byte_avg` (number)
      Average agent memory consumption during the last 5 minutes
  - `policy_id` (string)
  - `policy_revision` (number)
  - `status` (enum)
    Values: `offline`, `error`, `online`, `inactive`, `warning`
  - `type` (enum)
    Values: `PERMANENT`, `EPHEMERAL`, `TEMPORARY`
  - `unenrolled_at` (string)
  - `unenrollment_started_at` (string)
  - `user_provided_metadata` (object)
- `list` (object[]) — deprecated
  Same fields as `items`
- `page` (number)
- `perPage` (number)
- `statusSummary` (object)
  - `degraded'` (number)
  - `enrolling` (number)
  - `error` (number)
  - `inactive` (number)
  - `offline` (number)
  - `online` (number)
  - `unenrolled` (number)
  - `unenrolling` (number)
  - `updating` (number)
- `total` (number)
#### `400`

Generic Error

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (number)
## Code examples

#### Console

```console
GET kbn:/api/fleet/agents
```

#### curl

```curl
curl -X GET "${KIBANA_URL}/api/fleet/agents" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "items": [
    {
      "access_api_key": "string",
      "access_api_key_id": "string",
      "active": false,
      "components": [
        {
          "id": "string",
          "message": "string",
          "status": "starting",
          "type": "string",
          "units": []
        }
      ],
      "default_api_key": "string",
      "default_api_key_id": "string",
      "enrolled_at": "string",
      "id": "string",
      "last_checkin": "string",
      "local_metadata": {},
      "metrics": {
        "cpu_avg": 0,
        "memory_size_byte_avg": 0
      },
      "policy_id": "string",
      "policy_revision": 0,
      "status": "offline",
      "type": "PERMANENT",
      "unenrolled_at": "string",
      "unenrollment_started_at": "string",
      "user_provided_metadata": {}
    }
  ],
  "list": [
    {
      "access_api_key": "string",
      "access_api_key_id": "string",
      "active": false,
      "components": [
        {
          "id": "string",
          "message": "string",
          "status": "starting",
          "type": "string",
          "units": []
        }
      ],
      "default_api_key": "string",
      "default_api_key_id": "string",
      "enrolled_at": "string",
      "id": "string",
      "last_checkin": "string",
      "local_metadata": {},
      "metrics": {
        "cpu_avg": 0,
        "memory_size_byte_avg": 0
      },
      "policy_id": "string",
      "policy_revision": 0,
      "status": "offline",
      "type": "PERMANENT",
      "unenrolled_at": "string",
      "unenrollment_started_at": "string",
      "user_provided_metadata": {}
    }
  ],
  "page": 0,
  "perPage": 0,
  "statusSummary": {
    "degraded\u0027": 0,
    "enrolling": 0,
    "error": 0,
    "inactive": 0,
    "offline": 0,
    "online": 0,
    "unenrolled": 0,
    "unenrolling": 0,
    "updating": 0
  },
  "total": 0
}
```

#### 400

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "error": "string",
  "message": "string",
  "statusCode": 0
}
```

