---
type: api
title: Create agent action
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-new-agent-action
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/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`

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

- `action` (union oneOf) — 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 kbn:/api/fleet/agents/AGENT_ID/actions
{}
```

#### curl

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

