---
type: api
title: Add and remove detection alert tags
description: Add tags to detection alerts, and remove them from alerts, by alert IDs or a query, in a single request.
url: https://www.elastic.co/docs/api/doc/kibana/operation/operation-setalerttags
resource: https://www.elastic.co/docs/api/doc/kibana/operation/operation-setalerttags
products:
  - Kibana
---

# Add and remove detection alert tags

Authentication: required

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

## Paths

- `POST` `/api/detection_engine/signals/tags`
- `POST` `/s/{space_id}/api/detection_engine/signals/tags`

#### Path parameters

- `space_id` (string) — optional
  An identifier for the space. If `space_id` is not provided in the URL, the default space is used. Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Description

Add tags to detection alerts, and remove them from alerts, by alert IDs or a query, in a single request.
> info
> You cannot add and remove the same alert tag in the same request.

## Request body

An object containing tags to add or remove and alert ids the changes will be applied

`application/json`

- `ids` (string[] · format: nonempty · min items: 1) — required
  A list of alerts `id`s.
- `tags` (object) — required
  Object with list of tags to add and remove.
  - `tags_to_add` (string[] · format: nonempty) — required
    List of keywords to organize related alerts into categories that you can filter and group.
  - `tags_to_remove` (string[] · format: nonempty) — required
    List of keywords to organize related alerts into categories that you can filter and group.

## Responses

#### `200`

Successful response

`application/json`

Type: `object`

#### `400`

Invalid input data response

`application/json`

One of:
- **PlatformErrorResponse**
  - `error` (string)
  - `message` (string)
  - `statusCode` (integer)
- **SiemErrorResponse**
  - `message` (string)
  - `status_code` (integer)
#### `401`

Unsuccessful authentication response

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (integer)
#### `500`

Internal server error response

`application/json`

- `message` (string)
- `status_code` (integer)
## Code examples

#### Console

```console
POST kbn:/api/detection_engine/signals/tags
{
  "ids": [
    "549c7129c76cbd554aba1bd638f8a49dde95088f5832e50218358e7eca1cf16e"
  ],
  "tags": {
    "tags_to_add": [
      "Duplicate"
    ],
    "tags_to_remove": []
  }
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/detection_engine/signals/tags" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "549c7129c76cbd554aba1bd638f8a49dde95088f5832e50218358e7eca1cf16e"
    ],
    "tags": {
      "tags_to_add": [
        "Duplicate"
      ],
      "tags_to_remove": []
    }
  }'
```

## Response examples

#### Success

`application/json`

```json
{
  "batches": "1,",
  "deleted": "0,",
  "failures": [],
  "noops": "0,",
  "requests_per_second": "-1,",
  "retries": {
    "bulk": "0,",
    "search": 0
  },
  "throttled_millis": "0,",
  "throttled_until_millis": "0,",
  "timed_out": "false,",
  "took": "68,",
  "total": "1,",
  "updated": "1,",
  "version_conflicts": "0,"
}
```

#### Bad

`application/json`

```json
{
  "error": "Bad Request",
  "message": "[request body].tags: cannot add and remove the same tag in a single request",
  "statusCode": 400
}
```

#### Unauthorized

`application/json`

```json
{
  "error": "Unauthorized",
  "message": "[security_exception\n\tRoot causes:\n\t\tsecurity_exception: unable to authenticate user [elastic] for REST request [/_security/_authenticate]]: unable to authenticate user [elastic] for REST request [/_security/_authenticate]",
  "statusCode": 401
}
```

#### Server error

`application/json`

```json
{
  "message": "Internal Server Error",
  "status_code": 500
}
```

