---
type: api
title: Create agent action
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-new-agent-action
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-new-agent-action
products:
  - Kibana
---

# Create agent action

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

## Paths

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

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

## Description

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

## Request Body

`application/json`

- `action` (union) — optional
  - **{ ack_data }**
    - `ack_data` (string) — optional
    - `data` (string) — optional
    - `type` (enum) — optional
      Values: `UNENROLL`, `UPGRADE`, `POLICY_REASSIGN`
  - **object**
    - `data` (object) — optional
      - `log_level` (enum) — optional — nullable
        Values: `debug`, `info`, `warning`, `error`
    - `type` (string) — optional

## Responses

#### `200`

OK

`application/json`

- `body` ([] number)
- `headers` (string)
- `statusCode` (number)
#### `400`

Generic Error

`application/json`

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

#### Console

```console
POST /api/fleet/agents/{agentId}/actions
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agents/{agentId}/actions" \
  -H "kbn-xsrf: true"
```

