---
type: api
title: Request agent diagnostics
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v9/operation/operation-post-fleet-agents-agentid-request-diagnostics
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v9/operation/operation-post-fleet-agents-agentid-request-diagnostics
products:
  - Kibana
---

# Request agent diagnostics

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

## Paths

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

#### Path parameters

- `agentId` (string) — required
  The agent ID

## Description

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

Request a diagnostics bundle from a specific agent.

## Required authorization

- Privileges: `fleet-agents-read`

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

- `additional_metrics` (enum[] · max items: 1) — optional
  Values: `CPU`

## Responses

#### `200`

Successful response

`application/json`

Any of:
- **{ actionId }**
  - `actionId` (string)
- **{ count }**
  - `count` (number)
#### `400`

Bad Request

`application/json`

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

#### Console

```console
POST kbn:/api/fleet/agents/AGENT_ID/request_diagnostics
{
  "additional_metrics": [
    "CPU"
  ]
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/fleet/agents/${AGENT_ID}/request_diagnostics" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "additional_metrics": [
      "CPU"
    ]
  }'
```

## Response examples

#### Post request diagnostics

Diagnostics action result

```json
{
  "actionId": "action-id-1"
}
```

#### Generic error response

Example of a generic error response

```json
{
  "error": "Bad Request",
  "message": "Agent agent-id-1 does not support request diagnostics action.",
  "statusCode": 400
}
```

