---
type: api
title: Find and/or aggregate detection alerts
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-searchalerts
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-searchalerts
products:
  - Kibana
---

# Find and/or aggregate detection alerts

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

## Paths

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

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

## Description

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

Find and/or aggregate detection alerts that match the given query.

## Request Body

`application/json`

Search and/or aggregation query

- `_source` (union boolean | string | [] string) — optional
- `aggs` (object) — optional
- `fields` ([] string) — optional
- `query` (object) — optional
- `runtime_mappings` (object) — optional
- `size` (integer · min: 0) — optional
- `sort` (union) — optional
  One of: `AlertsSortCombinations[]` or `AlertsSortCombinations`
- `track_total_hits` (boolean) — optional

## 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 /api/detection_engine/signals/search
{
  "aggs": {
    "alertsByGrouping": {
      "terms": {
        "field": "host.name",
        "size": 10
      }
    },
    "missingFields": {
      "missing": {
        "field": "host.name"
      }
    }
  },
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "filter": [
              {
                "match_phrase": {
                  "kibana.alert.workflow_status": "open"
                }
              }
            ],
            "must": [],
            "must_not": [
              {
                "exists": {
                  "field": "kibana.alert.building_block_type"
                }
              }
            ],
            "should": []
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": "2025-01-17T08:00:00.000Z",
              "lte": "2025-01-18T07:59:59.999Z"
            }
          }
        }
      ]
    }
  },
  "runtime_mappings": {},
  "size": 0
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/detection_engine/signals/search" \
  -H "Content-Type: application/json" \
  -d '{
  "aggs": {
    "alertsByGrouping": {
      "terms": {
        "field": "host.name",
        "size": 10
      }
    },
    "missingFields": {
      "missing": {
        "field": "host.name"
      }
    }
  },
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "filter": [
              {
                "match_phrase": {
                  "kibana.alert.workflow_status": "open"
                }
              }
            ],
            "must": [],
            "must_not": [
              {
                "exists": {
                  "field": "kibana.alert.building_block_type"
                }
              }
            ],
            "should": []
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": "2025-01-17T08:00:00.000Z",
              "lte": "2025-01-18T07:59:59.999Z"
            }
          }
        }
      ]
    }
  },
  "runtime_mappings": {},
  "size": 0
}'
```

## Response Examples

#### Success

```json
{
  "_shards": {
    "failed": 0,
    "skipped": 0,
    "successful": 1,
    "total": 1
  },
  "aggregations": {
    "alertsByGrouping": {
      "buckets": [
        {
          "doc_count": 5,
          "key": "Host-f43kkddfyc"
        }
      ],
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0
    },
    "missingFields": {
      "doc_count": 0
    }
  },
  "hits": {
    "hits": [],
    "max_score": "null",
    "total": {
      "relation": "eq",
      "value": 5
    }
  },
  "timed_out": false,
  "took": 0
}
```

#### Bad

```json
{
  "error": "Bad Request",
  "message": "Failed to parse search request: unknown query clause in bool filter",
  "statusCode": 400
}
```

#### Unauthorized

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

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

