---
type: api
title: Create a Comment
description: Creates a comment for the given Resource.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/cloud-enterprise/v4/operation/operation-create-comment
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/cloud-enterprise/v4/operation/operation-create-comment
products:
  - Elastic Cloud Enterprise
---

# Create a Comment

## Paths

- `POST` `/comments/{resource_type}/{resource_id}`

#### Path parameters

- `resource_type` (string) — required
  The kind of Resource that a Comment belongs to. Should be one of [elasticsearch, kibana, apm, appsearch, enterprise_search, integrations_server, allocator, constructor, runner, proxy].
- `resource_id` (string) — required
  Id of the Resource that a Comment belongs to.

## Description

Creates a comment for the given Resource.

## Authentication

- Basic: `Authorization: Basic <credentials>`
- Api key: `Authorization: <value>`

## Request body

Data for comment creation

`application/json`

- `message` (string) — required
  The message for the Comment.

## Responses

#### `201`

The Comment that was just created.

`application/json`

- `id` (string)
  The id of this Comment
- `user_id` (string)
  The user id of the user who wrote this Comment
- `message` (string)
  The message content of this Comment
##### Response headers

- `x-cloud-resource-version` (string)
  The resource version, which is used to avoid update conflicts with concurrent operations
- `x-cloud-resource-created` (string)
  The date-time when the resource was created (ISO format relative to UTC)
- `x-cloud-resource-last-modified` (string)
  The date-time when the resource was last modified (ISO format relative to UTC)

#### `401`

Your current session does not have a user id associated with it. (code: `comments.no_user_id`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `404`

No Resource of the given type and id exist. (code: `comments.resource_does_not_exist`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `409`

A Comment already exists with the generated id. Please try again. (code: `comments.id_already_exists`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

## Code examples

#### curl

```curl
curl -X POST "${API_URL}/comments/${RESOURCE_TYPE}/${RESOURCE_ID}" \
  -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "string"
  }'
```

