---
type: api
title: Get agents by action ids
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-post-fleet-agents
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-post-fleet-agents
products:
  - Kibana
---

# Get agents by action ids

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

## Paths

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

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/authentication#basicauth)

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Retrieve agents associated with specific action IDs.<br/><br/>[Required authorization] Route required privileges: fleet-agents-read.

## Request Body

`application/json`

- `actionIds` ([] string · max: 1000) — required

## Responses

#### `200`

Successful response

`application/json`

- `items` ([] string · max: 10000)
#### `400`

Bad Request

`application/json`

- `attributes` (object)
- `error` (string)
- `errorType` (string)
- `message` (string)
- `statusCode` (number)
## Code Examples

#### Console

```console
POST /api/fleet/agents
{
  "actionIds": [
    "action-id-1",
    "action-id-2"
  ]
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agents" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "actionIds": [
    "action-id-1",
    "action-id-2"
  ]
}'
```

## Response Examples

#### Post get agents by actions

Agents associated with the given actions

```json
{
  "items": [
    {
      "active": true,
      "id": "agent-id-1",
      "policy_id": "agent-policy-id-1",
      "status": "online"
    }
  ],
  "total": 1
}
```

#### Generic error response

Example of a generic error response

```json
{
  "error": "Bad Request",
  "message": "An error message describing what went wrong",
  "statusCode": 400
}
```

