Comments are additional information that you can add to your resources. Comments can be added to provide context for any operation that was performed.

When you make an API call on any resource eg., Subscriptions -> Change term end, you can add more context to that operation by calling the comments API as a follow up call.

Besides the user generated comments, ChargeBee also generates "System" comments when a change for a resource happens at the backend. These comments are all read-only.

Sample comment [ JSON ]

{ "id": "cmt_8asyvQLqqkjp1", "entity_type": "subscription", "entity_id": "sub__8avQOOQY1Bn3I", "notes": "This is a test comment", "added_by": "full_access_key_v1", "created_at": 1496825856, "type": "user", "object": "comment" }

API Index URL GET

https://{site}.chargebee.com/api/v2/comments
id
Unique identifier for the comment.
string, max chars=40
entity_type
Type of the entity this comment generated for.
enumerated string
Possible values are
customerEntity that represents a customer.subscriptionEntity that represents a subscription of a customer.invoiceEntity that represents an invoice.credit_noteEntity that represents a credit note.transactionEntity that represents a transaction.planEntity that represents a subscription plan.addonEntity that represents an addon.couponEntity that represents a discount coupon.
added_by
The user who created the comment. If created via API, this contains the name given for the API key used.
optional, string, max chars=100
notes
Actual notes for the comment.
string, max chars=1000
created_at
The time at which this comment was created.
timestamp(UTC) in seconds
type
Type of comment this is.
enumerated string, default=user
Possible values are
userComment generated by user either via API or Admin console.systemComment generated by Chargebee when any backend changes happen for an entity.
entity_id
Unique identifier of the entity.
string, max chars=100
Create a new comment for an entity. The newly added comment will be shown in the web interface as well.
Sample Request
curl  https://{site}.chargebee.com/api/v2/comments \
     -u {site_api_key}: \
     -d entity_type="subscription" \
     -d notes="This is a test comment"
copy
curl  https://{site}.chargebee.com/api/v2/comments \
     -u {site_api_key}: \
     -d entity_type="subscription" \
     -d notes="This is a test comment"

Sample Response [ JSON ]

{"comment": { "id": "cmt_8asyvQLqr6L01o", "entity_type": "subscription", "entity_id": "5cDfREwp3I5lJ", "notes": "This is a test comment", "added_by": "full_access_key_v1", "created_at": 1496825939, "type": "user", "object": "comment" }}

URL Format POST

https://{site}.chargebee.com/api/v2/comments
entity_type
Type of the entity to create the comment for.
required, enumerated string
Possible values are
customerEntity that represents a customer.subscriptionEntity that represents a subscription of a customer.invoiceEntity that represents an invoice.credit_noteEntity that represents a credit note.transactionEntity that represents a transaction.planEntity that represents a subscription plan.addonEntity that represents an addon.couponEntity that represents a discount coupon.
entity_id
Unique identifier of the entity.
required, string, max chars=100
notes
Actual notes for the comment.
required, string, max chars=1000
added_by
The user who created the comment. If created via API, this contains the name given for the API key used.
optional, string, max chars=100
Resource object representing comment.
always returned
Retrieve a comment for an entity identified by comment id.
Sample Request
curl  https://{site}.chargebee.com/api/v2/comments/cmt_8asyvQLqqkjp1 \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/comments/cmt_8asyvQLqqkjp1 \
     -u {site_api_key}:

Sample Response [ JSON ]

{"comment": { "id": "cmt_8asyvQLqqkjp1", "entity_type": "subscription", "entity_id": "sub__8avQOOQY1Bn3I", "notes": "This is a test comment", "added_by": "full_access_key_v1", "created_at": 1496825856, "type": "user", "object": "comment" }}

URL Format GET

https://{site}.chargebee.com/api/v2/comments/{comment_id}
Resource object representing comment.
always returned

Retrieve the list of comments sorted by the recent ones on the top.

If you want to retrieve the list of comments for an entity eg., subscription you can filter them by passing the entity type and unique identifier for that entity eg., subscription id.

Sample Request
curl  https://{site}.chargebee.com/api/v2/comments \
     -G  \
     -u {site_api_key}: \
     --data-urlencode limit="5" \
     --data-urlencode created_at[after]="1456332678" \
     --data-urlencode sort_by[asc]="created_at"
copy
curl  https://{site}.chargebee.com/api/v2/comments \
     -G  \
     -u {site_api_key}: \
     --data-urlencode limit="5" \
     --data-urlencode created_at[after]="1456332678" \
     --data-urlencode sort_by[asc]="created_at"

Sample Response [ JSON ]

{ "list": [ {"comment": { "id": "cmt_8asyvQLqr6L01o", "entity_type": "subscription", "entity_id": "5cDfREwp3I5lJ", "notes": "This is a test comment", "added_by": "full_access_key_v1", "created_at": 1496825939, "type": "user", "object": "comment" }}, {..} ], "next_offset": "[\"1496825939000\",\"75000000010\"]" }

URL Format GET

https://{site}.chargebee.com/api/v2/comments
limit
Limits the number of resources to be returned.
optional, integer, default=10, min=1, max=100
offset
Allows you to fetch the next set of resources. The value used for this parameter must be the value returned for next_offset parameter in the previous API call.
optional, string, max chars=1000
sort_by[<sort-order>]
Sorts based on the specified attribute.
Supported attributes : created_at
Supported sort-orders : asc, desc

Example sort_by[asc] = "created_at"
This will sort the result based on the 'created_at' attribute in ascending(earliest first) order.
optional, string filter
Filter Params
For operator usages, see the Pagination and Filtering section.
entity_type
Type of the entity this comment generated for.
optional, enumerated string
Possible values are
customerEntity that represents a customer.subscriptionEntity that represents a subscription of a customer.invoiceEntity that represents an invoice.credit_noteEntity that represents a credit note.transactionEntity that represents a transaction.planEntity that represents a subscription plan.addonEntity that represents an addon.couponEntity that represents a discount coupon.
entity_id
Unique identifier of the entity.
optional, string, max chars=100
created_at[<operator>]
To filter based on Comment Created At.
Supported operators : after, before, on, between

Example created_at[after] = "1456332678"
optional, timestamp(UTC) in seconds filter
Resource object representing comment.
always returned
next_offset
This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.
optional, string, max chars=1000

Delete a comment for an entity identified by comment id.

Only the comments that are added via Admin console and API can be deleted. ChargeBee generated "System" comments cannot be deleted.

Sample Request
curl  https://{site}.chargebee.com/api/v2/comments/cmt_8asyvQLqqkjp1/delete \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/comments/cmt_8asyvQLqqkjp1/delete \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"comment": { "id": "cmt_8asyvQLqqkjp1", "entity_type": "subscription", "entity_id": "sub__8avQOOQY1Bn3I", "notes": "This is a test comment", "added_by": "full_access_key_v1", "created_at": 1496825856, "type": "user", "object": "comment" }}

URL Format POST

https://{site}.chargebee.com/api/v2/comments/{comment_id}/delete
Resource object representing comment.
always returned