---
type: api
title: Create a service annotation
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-createannotation
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-createannotation
products:
  - Kibana
---

# Create a service annotation

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

## Paths

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

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

Create a new annotation for a specific service.

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

- `elastic-api-version` (enum · default: 2023-10-31) — required
  The version of the API to use
  Values: `2023-10-31`
- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

- `@timestamp` (string) — required
  Timestamp
- `message` (string) — optional
  Message
- `service` (object) — required
  Service
  - `environment` (string) — optional
  - `version` (string) — required
- `tags` (string[]) — optional
  Tags

## Responses

#### `200`

Annotation created successfully

`application/json`

- `_id` (string)
  Identifier
- `_index` (string)
  Index
- `_source` (object)
  Response
  - `@timestamp` (string)
  - `annotation` (object)
    - `title` (string)
    - `type` (string)
  - `event` (object)
    - `created` (string)
  - `message` (string)
  - `service` (object)
    - `environment` (string)
    - `name` (string)
    - `version` (string)
  - `tags` (string[])
#### `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
#### `403`

Forbidden response

`application/json`

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

Not found response

`application/json`

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

#### Console

```console
POST kbn:/api/apm/services/SERVICE_NAME/annotation
{
  "@timestamp": "string",
  "service": {
    "version": "string"
  }
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/apm/services/${SERVICE_NAME}/annotation" \
  -H "elastic-api-version: 2023-10-31" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "@timestamp": "string",
    "service": {
      "version": "string"
    }
  }'
```

