---
type: api
title: Update agent by ID
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-update-agent
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-update-agent
products:
  - Kibana
---

# Update agent by ID

Authentication: required

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

## Paths

- `PUT` `/api/fleet/agents/{agentId}`
- `PUT` `/s/{space_id}/api/fleet/agents/{agentId}`

#### 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.
- `agentId` (string) — required

## Header parameters

- `kbn-xsrf` (string) — required
  Kibana's anti Cross-Site Request Forgery token. Can be any string value.

## Request body

`application/json`

- `tags` (string[]) — optional
- `user_provided_metadata` (object) — optional

## Responses

#### `200`

OK

`application/json`

- `item` (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)
#### `400`

Generic Error

`application/json`

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

#### Console

```console
PUT kbn:/api/fleet/agents/AGENT_ID
{}
```

#### curl

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

## 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
{
  "item": {
    "access_api_key": "string",
    "access_api_key_id": "string",
    "active": false,
    "components": [
      {
        "id": "string",
        "message": "string",
        "status": "starting",
        "type": "string",
        "units": [
          {
            "id": "string",
            "message": "string",
            "status": "starting",
            "type": "input"
          }
        ]
      }
    ],
    "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": {}
  }
}
```

#### 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
}
```

