---
type: api
title: Cancel an agent action
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-post-fleet-agents-actions-actionid-cancel
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/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`

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

#### Path Parameters

- `actionId` (string)
  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.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## Request Body

`application/json`


## Responses

#### `200`

Successful response

`application/json`

- `item` (object)
  - `ack_data` (object)
  - `agents` ([] string · max: 10000)
  - `created_at` (string)
  - `data` (object)
  - `expiration` (string)
  - `id` (string)
  - `minimum_execution_duration` (number)
  - `namespaces` ([] string · max: 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 /api/fleet/agents/actions/{actionId}/cancel
{}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agents/actions/{actionId}/cancel" \
  -H "kbn-xsrf: true" \
  -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
}
```

