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

# Update agent by ID

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

## Paths

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

#### Path parameters

- `agentId` (string) — required

## Description

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

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

