# Create a comment

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/v2/pcv-1/idempotency)

Create a new comment for an entity. The newly added comment will be shown in the web interface as well.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/comments \
     -u {site_api_key}:\
     -d entity_id="__test__KyVnHhSBWm65N2rx" \
     -d entity_type="SUBSCRIPTION" \
     -d notes="This is a test comment"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;
using ChargeBee.Models.Enums;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Comment.Create()
		.EntityId("__test__KyVnHhSBWm65N2rx")
		.EntityType(EntityTypeEnum.Subscription)
		.Notes("This is a test comment")
		.Request();

Comment comment = result.Comment;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    commentAction "github.com/chargebee/chargebee-go/v3/actions/comment"
    "github.com/chargebee/chargebee-go/v3/models/comment"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := commentAction.Create(&comment.CreateRequestParams{
        EntityId : "__test__KyVnHhSBWm65N2rx",
        EntityType : enum.EntityTypeSubscription,
        Notes : "This is a test comment",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Comment := res.Comment
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.CommentCreateRequest{
    EntityId : "__test__KyVnHhSBWm65N2rx",
    EntityType : chargebee.EntityTypeSubscription,
    Notes : "This is a test comment",
}
  res, err := client.Comment.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Comment := res.Comment
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Comment.create()
            .entityId("__test__KyVnHhSBWm65N2rx")
            .entityType(EntityType.SUBSCRIPTION)
            .notes("This is a test comment")
            .request();

        Comment comment = result.comment();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.comment.Comment;
import com.chargebee.v4.models.comment.params.CommentCreateParams;
import com.chargebee.v4.models.comment.responses.CommentCreateResponse;

public class CommentCreate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        CommentCreateParams params = CommentCreateParams.builder()
            .entityId("__test__KyVnHhSBWm65N2rx")
            .entityType(CommentCreateParams.EntityType.SUBSCRIPTION)
            .notes("This is a test comment")
            .build();

        CommentCreateResponse response = client.comments().create(params);

        Comment comment = response.getComment();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.comment.create({
        entity_id: "__test__KyVnHhSBWm65N2rx",
        entity_type: "subscription",
        notes: "This is a test comment"
    });

    console.log(result);
    const comment = result.comment;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->comment()->create([
    "entity_id" => "__test__KyVnHhSBWm65N2rx",
    "entity_type" => "subscription",
    "notes" => "This is a test comment"
]);
$comment = $result->comment;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Comment.create(
    cb_client.Comment.CreateParams(
        entity_id="__test__KyVnHhSBWm65N2rx",
        entity_type=chargebee.EntityType.SUBSCRIPTION,
        notes="This is a test comment"
    )
)
comment = response.comment
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Comment.create({
  :entity_id => "__test__KyVnHhSBWm65N2rx",
  :entity_type => "SUBSCRIPTION",
  :notes => "This is a test comment"
})

comment = result.comment
```

## Sample Response

```json
{
  "comment": {
    "added_by": "full_access_key_v1",
    "created_at": 1517505963,
    "entity_id": "__test__KyVnHhSBWm65N2rx",
    "entity_type": "subscription",
    "id": "cmt___test__KyVnHhSBWm69N2s4",
    "notes": "This is a test comment",
    "object": "comment",
    "type": "user"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/comments

## Input Parameters

- `entity_type` (required, enumerated string)
  Type of the entity to create the comment for.
  Possible enum values:
    - `customer`
      Entity that represents a customer
    - `subscription`
      Entity that represents a subscription of a customer
    - `invoice`
      Invoice description
    - `quote`
      Entity that represents a quote
    - `credit_note`
      Credit note description
    - `transaction`
      Entity that represents a transaction.
    - `plan`
      Entity that represents a subscription plan
    - `addon`
      Entity that represents an addon
    - `coupon`
      Entity that represents a discount coupon
    - `order`
      Entity that represents an order
    - `business_entity`
      Entity that represents item of type business entity

- `entity_id` (required, string, max chars=100)
  Unique identifier of the entity.

- `notes` (required, string, max chars=1000)
  Actual notes for the comment.

- `added_by` (optional, string, max chars=100)
  The user who created the comment. If created via API, this contains the name given for the API key used.

## Returns

- `comment` (Comment object)
  Resource object representing comment
