---
type: api
title: Search for annotations
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana-serverless/operation/operation-getannotation
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana-serverless/operation/operation-getannotation
products:
  - Kibana
---

# Search for annotations

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

## Paths

- `GET` `/api/apm/services/{serviceName}/annotation/search`
- `GET` `/s/{space_id}/api/apm/services/{serviceName}/annotation/search`

#### Path parameters

- `serviceName` (string) — required
  The name of the service

## Description

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

Search for annotations related to a specific service.

## Authentication

- Api key: `Authorization: <value>`
  You must create an API key and use the encoded value in the request header. To learn about creating keys, go to [API keys](https://www.elastic.co/docs/current/serverless/api-keys).

## Query string parameters

- `environment` (string) — optional
  The environment to filter annotations by
- `start` (string · format: date-time) — optional
  The start date for the search
  Example: `2024-01-01T00:00:00.000Z`
- `end` (string · format: date-time) — optional
  The end date for the search
  Example: `2024-01-31T23:59:59.999Z`

## Header parameters

- `elastic-api-version` (enum · default: 2023-10-31) — required
  The version of the API to use
  Values: `2023-10-31`

## Responses

#### `200`

Successful response

`application/json`

- `annotations` (object[])
  Annotations
  - `@timestamp` (number)
  - `id` (string)
  - `text` (string)
  - `type` (enum)
    Values: `version`
#### `400`

Bad Request response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
#### `401`

Unauthorized response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
#### `500`

Internal Server Error response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
## Code examples

#### Console

```console
GET kbn:/api/apm/services/SERVICE_NAME/annotation/search
```

#### curl

```curl
curl -X GET "${KIBANA_URL}/api/apm/services/${SERVICE_NAME}/annotation/search" \
  -H "elastic-api-version: 2023-10-31" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

#### Get annotation response1

An example of a successful response from `GET /api/apm/services/{serviceName}/annotation/search`, which returns the annotations associated with a service over the given time range.

```json
{
  "annotations": [
    {
      "@timestamp": 1735689600000,
      "id": "opbeans-node@2.0.0",
      "text": "opbeans-node@2.0.0",
      "type": "version"
    },
    {
      "@timestamp": 1736294400000,
      "id": "opbeans-node@2.1.0",
      "text": "opbeans-node@2.1.0",
      "type": "version"
    }
  ]
}
```

#### Bad request

An example of a 400 Bad Request response, returned when the request payload or query parameters fail validation.

```json
{
  "error": "Bad Request",
  "message": "[request body]: expected value of type [string] but got [undefined]",
  "statusCode": 400
}
```

#### Unauthorized

An example of a 401 Unauthorized response, returned when the request is missing valid authentication credentials.

```json
{
  "error": "Unauthorized",
  "message": "[security_exception]: missing authentication credentials for REST request",
  "statusCode": 401
}
```

#### Internal server error

An example of a 500 Internal Server Error response, returned when an unexpected error occurs while processing the request.

```json
{
  "error": "Internal Server Error",
  "message": "An internal server error occurred. Check the Kibana server logs for details.",
  "statusCode": 500
}
```

