---
type: api
title: Cancel an agent action
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-actions-actionid-cancel
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v9/operation/operation-post-fleet-agents-actions-actionid-cancel
products:
  - Kibana
---

# Cancel an agent action

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

## Paths

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

#### Path parameters

- `actionId` (string) — required
  The ID of the action to cancel

## Description

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

Cancel a pending action for a specific agent.

## Required authorization

- Privileges: `fleet-agents-all`

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


## Responses

#### `200`

Successful response

`application/json`

- `item` (object)
  - `ack_data` (object)
  - `agents` (string[] · max items: 10000)
  - `created_at` (string)
  - `data` (object)
  - `expiration` (string)
  - `id` (string)
  - `minimum_execution_duration` (number)
  - `namespaces` (string[] · max items: 100)
  - `rollout_duration_seconds` (number)
  - `sent_at` (string)
  - `source_uri` (string)
  - `start_time` (string)
  - `total` (number)
  - `type` (string)
#### `400`

Bad Request

`application/json`

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

#### Console

```console
POST kbn:/api/fleet/agents/actions/ACTION_ID/cancel
{}
```

#### curl

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

## Response examples

#### Post cancel action

Cancellation action created

```json
{
  "item": {
    "agents": [
      "agent-id-1"
    ],
    "created_at": "2024-01-01T00:00:00.000Z",
    "id": "cancel-action-id-1",
    "type": "CANCEL"
  }
}
```

#### Generic error response

Example of a generic error response

```json
{
  "error": "Bad Request",
  "message": "An error message describing what went wrong",
  "statusCode": 400
}
```

