---
type: api
title: Create a service annotation
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-createannotation
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/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`

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

#### Path Parameters

- `serviceName` (string)
  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.

## Request Body

`application/json`

- `@timestamp` (string) — required
  The date and time of the annotation. It must be in ISO 8601 format.
- `message` (string) — optional
  The message displayed in the annotation. It defaults to `service.version`.
- `service` (object) — required
  The service that identifies the configuration to create or update.
  - `environment` (string) — optional
    The environment of the service.
  - `version` (string) — required
    The version of the service.
- `tags` ([] string) — optional
  Tags are used by the Applications UI to distinguish APM annotations from other annotations. Tags may have additional functionality in future releases. It defaults to `[apm]`. While you can add additional tags, you cannot remove the `apm` tag.

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

#### curl

```curl
curl -X POST \
http://localhost:5601/api/apm/services/opbeans-java/annotation \
-H 'Content-Type: application/json' \
-H 'kbn-xsrf: true' \
-H 'Authorization: Basic YhUlubWZhM0FDbnlQeE6WRtaW49FQmSGZ4RUWXdX' \
-d '{
    "@timestamp": "2020-05-08T10:31:30.452Z",
    "service": {
        "version": "1.2"
    },
    "message": "Deployment 1.2"
    }'
```

## Request Examples

#### Create annotation request1

Run `POST /api/apm/services/{serviceName}/annotation` to create a deployment annotation for a service.

```json
{
  "@timestamp": "2024-01-15T12:00:00.000Z",
  "message": "Deployment 1.2.0",
  "service": {
    "environment": "production",
    "version": "1.2.0"
  },
  "tags": [
    "apm",
    "deployment"
  ]
}
```

## Response Examples

#### Create annotation response1

An example of a successful response from `POST /api/apm/services/opbeans-java/annotation`, which creates an annotation for a service named `opbeans-java`.

```json
{
  "_id": "Lc9I93EBh6DbmkeV7nFX",
  "_index": "observability-annotations",
  "_primary_term": 1,
  "_seq_no": 12,
  "_source": {
    "@timestamp": "2020-05-08T10:31:30.452Z",
    "annotation": {
      "type": "deployment"
    },
    "event": {
      "created": "2020-05-09T02:34:43.937Z"
    },
    "message": "Deployment 1.2",
    "service": {
      "name": "opbeans-java",
      "version": "1.2"
    },
    "tags": [
      "apm",
      "elastic.co",
      "customer"
    ]
  },
  "_version": 1,
  "found": true
}
```

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

#### Forbidden

An example of a 403 Forbidden response, returned when the authenticated user lacks the required APM and User Experience privileges.

```json
{
  "error": "Forbidden",
  "message": "Insufficient privileges to perform this action. The APM and User Experience feature requires \u0060all\u0060 privileges.",
  "statusCode": 403
}
```

#### Not found

An example of a 404 Not Found response, returned when the requested resource does not exist or the feature is not available on the current deployment.

```json
{
  "error": "Not Found",
  "message": "Not Found",
  "statusCode": 404
}
```

