# Comments

Comments are discussions around content and can be added to a folder or file in Onehub. You can **create**, **delete**, and **list** comments. Comments are identified by a unique, random ID.

## Create a Comment

<mark style="color:green;">`POST`</mark> `https://ws-api.onehub.com/:item/:item_id/comments`

Creates a comment on the `:item` (folder or file) specified via `:item_id`.

#### Path Parameters

| Name      | Type    | Description                                                                     |
| --------- | ------- | ------------------------------------------------------------------------------- |
| :item     | string  | The type of item. Can either be `folders` or `files`.                           |
| :item\_id | integer | The unique identifier of the item that you would like to create the comment on. |

#### Request Body

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| body | string | The text of the comment. |

{% tabs %}
{% tab title="201 Returns the newly created comment object and a 201 if the call succeeds." %}

```yaml
{
  "comment": {
    "id": 9417,
    "user_id": 481,
    "discussion_id": 468087,
    "body": "This is an example comment.",
    "updated_at": "2016-01-15T16:24:37-08:00",
    "user_name": "Matthew Anderson",
    "owner_type": "file",
    "owner_id": 849607
  }
}
```

{% endtab %}

{% tab title="422 Returns a 422 with an error in the message body it a non-existent id is provided." %}

```yaml
// 
```

{% endtab %}
{% endtabs %}

## Delete a Comment

<mark style="color:red;">`DELETE`</mark> `https://ws-api.onehub.com/:item/:item_id/comments/:id`

Deletes the comment specified via `:id` from the `:item` (folder or file) specified via `:item_id`.

#### Path Parameters

| Name      | Type    | Description                                                                  |
| --------- | ------- | ---------------------------------------------------------------------------- |
| :item     | string  | The type of item. Can either be `folders` or `files`.                        |
| :item\_id | integer | The unique identifier of the item you would like to delete the comment from. |
| :id       | integer | The unique identifier of the comment you would like to delete.               |

{% tabs %}
{% tab title="204 Returns an empty message body and a 204 if the call succeeds." %}

```
```

{% endtab %}
{% endtabs %}

## List all Comments

<mark style="color:blue;">`GET`</mark> `https://ws-api.onehub.com/:item/:item_id/comments`

Lists all comment for the `:item` (folder or file) specified via `:item_id`.

#### Path Parameters

| Name      | Type    | Description                                                                  |
| --------- | ------- | ---------------------------------------------------------------------------- |
| :item     | string  | The type of item. Can either be `folders` or `files`.                        |
| :item\_id | integer | The unique identifier of the item that you would like to list comments from. |

{% tabs %}
{% tab title="200 Returns a paged array of comment objects and a 200 if the call succeeds." %}

```yaml
{
  "total_entries": 1,
  "current_page": 1,
  "total_pages": 1,
  "per_page": 15,
  "items": [
    {
      "comment": {
        "id": 9417,
        "user_id": 481,
        "discussion_id": 468087,
        "body": "This is an example comment.",
        "updated_at": "2016-01-15T16:24:37-08:00",
        "user_name": "Matthew Anderson",
        "owner_type": "file",
        "owner_id": 849607
      }
    }
  ]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.onehub.com/methods/comments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
