---
title: "Create Comment"
description: "Creates new comment for particular document."
---

> Documentation Index
> Fetch the complete documentation index at: /api-docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Comment

<div class="endpoint-signature"><span data-method="POST">POST</span><code>/api/v1_2/documents/:document_id/comments</code></div>

Creates new comment for particular document.

Please check example request body to see required structure.

## Path parameters

| Name | Example | Description |
|---|---|---|
| `document_id` | — | — |

## Request body

```json
{
  "comment": {
"text": "new comment"
  }
}
```

## Code examples

### cURL

```curl
curl --request POST 'https://app.datamolino.com/api/v1_2/documents/98765/comments' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer demo_access_token' \
  --data '{
  "comment": {
"text": "new comment"
  }
}'
```
### HTTP

```http
POST /api/v1_2/documents/98765/comments HTTP/1.1
Host: app.datamolino.com
Content-Type: application/json
Authorization: Bearer demo_access_token

{
  "comment": {
"text": "new comment"
  }
}
```
### JavaScript Fetch

```javascript
const response = await fetch("https://app.datamolino.com/api/v1_2/documents/98765/comments", {
  method: "POST",
  headers: {
"Content-Type": "application/json",
"Authorization": "Bearer demo_access_token"
  },
  body: JSON.stringify({
"comment": {
  "text": "new comment"
}
  }),
});

const data = await response.json();
```
### Node.js Axios

```javascript
import axios from "axios";

const response = await axios({
  method: "post",
  url: "https://app.datamolino.com/api/v1_2/documents/98765/comments",
  headers: {
"Content-Type": "application/json",
"Authorization": "Bearer demo_access_token"
  },
  data: {
"comment": {
  "text": "new comment"
}
  }
});

console.log(response.data);
```
### Python Requests

```python
import requests

url = "https://app.datamolino.com/api/v1_2/documents/98765/comments"
headers = {
  "Content-Type": "application/json",
  "Authorization": "Bearer demo_access_token"
}
payload = {
  "comment": {
"text": "new comment"
  }
}

response = requests.request("POST", url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())
```
### Ruby Net::HTTP

```ruby
require 'json'
require 'net/http'

uri = URI("https://app.datamolino.com/api/v1_2/documents/98765/comments")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer demo_access_token"
request.body = <<~JSON
{
  "comment": {
"text": "new comment"
  }
}
JSON

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end

puts JSON.parse(response.body)
```
### Ruby on Rails

```ruby
# app/services/datamolino_client.rb
require 'json'
require 'net/http'

class DatamolinoClient
  BASE_URL = "https://app.datamolino.com"

  def initialize(access_token: Rails.application.credentials.dig(:datamolino, :access_token))
@access_token = access_token
  end

  def request_create_comment
uri = URI("#{BASE_URL}/api/v1_2/documents/98765/comments")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{@access_token}"
request.body = <<~JSON
  {
    "comment": {
      "text": "new comment"
    }
  }
JSON

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

JSON.parse(response.body)
  end
end
```
### PHP Guzzle

```php
<?php

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('POST', 'https://app.datamolino.com/api/v1_2/documents/98765/comments', [
'headers' => json_decode('{"Content-Type":"application/json","Authorization":"Bearer demo_access_token"}', true),
'json' => json_decode('{"comment":{"text":"new comment"}}', true)
]);

echo $response->getBody();
```
### Java OkHttp

```java
OkHttpClient client = new OkHttpClient();

RequestBody body = RequestBody.create("{\n  \"comment\": {\n    \"text\": \"new comment\"\n  }\n}", MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("https://app.datamolino.com/api/v1_2/documents/98765/comments")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer demo_access_token")
.method("POST", body)
.build();

Response response = client.newCall(request).execute();
```
### C# HttpClient

```csharp
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://app.datamolino.com/api/v1_2/documents/98765/comments");
request.Headers.Add("Authorization", "Bearer demo_access_token");
request.Content = new StringContent("{\n  \"comment\": {\n    \"text\": \"new comment\"\n  }\n}", Encoding.UTF8, "application/json");

using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```
### Go Native

```go
client := &http.Client{}
req, err := http.NewRequest("POST", "https://app.datamolino.com/api/v1_2/documents/98765/comments", strings.NewReader("{\n  \"comment\": {\n    \"text\": \"new comment\"\n  }\n}"))
if err != nil { panic(err) }
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer demo_access_token")

res, err := client.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()

body, err := io.ReadAll(res.Body)
if err != nil { panic(err) }
fmt.Println(string(body))
```
### Swift URLSession

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://app.datamolino.com/api/v1_2/documents/98765/comments")!)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("Bearer demo_access_token", forHTTPHeaderField: "Authorization")
request.httpBody = "{\n  \"comment\": {\n    \"text\": \"new comment\"\n  }\n}".data(using: .utf8)

let (data, _) = try await URLSession.shared.data(for: request)
print(String(data: data, encoding: .utf8)!)
```

## Responses

### 201 Created

Content type: `application/json`

```json
{
  "comment": {
"uuid": "7f3a2d4e-9a1b-4c6d-8e0f-123456789abc"
  }
}
```

Source: /api-docs/reference/comment/create-comment/index.md
