> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.staple.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.staple.ai/_mcp/server.

# Add Comment On Document

POST https://api.staple.io/v2/comments/add/document/{documentId}
Content-Type: application/json

This endpoint allows you to add a comment to a specific document identified by {documentId}. The request should be sent via an HTTP POST method to the specified URL.

Reference: https://docs.staple.ai/api-reference/v2/comment/add-comment-on-document

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: v2
  version: 1.0.0
paths:
  /v2/comments/add/document/{documentId}:
    post:
      operationId: addCommentOnDocument
      summary: Add Comment On Document
      description: >-
        This endpoint allows you to add a comment to a specific document
        identified by {documentId}. The request should be sent via an HTTP POST
        method to the specified URL.
      tags:
        - comment
      parameters:
        - name: documentId
          in: path
          required: true
          schema:
            type: string
        - name: x-api-key
          in: header
          description: API key issued by Staple.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Comment_addCommentOnDocument_Response_200'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                receiverEmails:
                  type: array
                  items:
                    type: string
                message:
                  type: string
servers:
  - url: https://api.staple.io
    description: https://api.staple.io
components:
  schemas:
    Comment_addCommentOnDocument_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Comment_addCommentOnDocument_Response_200
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key issued by Staple.
    bearerAuth:
      type: http
      scheme: bearer
      description: JWT obtained from the login endpoint.

```

## Examples

### Add Comment On Document



**Request**

```json
undefined
```

**Response**

```json
{
  "createNotification": {
    "createdAt": 1719979197937,
    "id": "27776e3f-7594-4650-8526-3c2a32362502",
    "info": {
      "avatarURL": "https://staple-new-product-staging.s3.ap-southeast-1.amazonaws.com/avatar/reJjztoVJcC0jwqvtn0kW6W2un3oTHWI-tqg.png?AWSAccessKeyId=AKIATO6YT43ITVHQOBII&Expires=1719979497&Signature=joM2mxpHaON0w483I00GAa1u4r0%3D&response-content-disposition=inline%3B%20filename%3D%22avatar%2FreJjztoVJcC0jwqvtn0kW6W2un3oTHWI-tqg.png%22&response-content-type=image%2Fpng",
      "email": "sender@gmail.com",
      "firstName": "Ash",
      "lastName": "Ketchum",
      "role": "Owner",
      "roleColor": null
    },
    "message": "Message comment",
    "read": false,
    "receivers": [
      {
        "createdAt": 1719979197906,
        "id": "09109efb-ec6d-4bb3-92c5-7a7cc646df40",
        "info": {
          "avatarURL": "",
          "email": "bhanuka@staple.io",
          "firstName": "Staple",
          "lastName": "Employee",
          "role": "Admin",
          "roleColor": "#fe7d4a"
        },
        "read": false,
        "receiver": 1
      },
      {
        "createdAt": 1719979197906,
        "id": "efdf03da-9001-4f77-9a07-f4fc22407b95",
        "info": {
          "avatarURL": "",
          "email": "vvluc@staple.io",
          "firstName": "Staple",
          "lastName": "Employee",
          "role": "Member",
          "roleColor": "#5ab4ec"
        },
        "read": false,
        "receiver": 2
      }
    ],
    "sender": 10,
    "timeSinceCreated": "less than 5 seconds ago"
  }
}
```

**SDK Code**

```python Add Comment On Document
import requests

url = "https://api.staple.io/v2/comments/add/document/documentId"

headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Add Comment On Document
const url = 'https://api.staple.io/v2/comments/add/document/documentId';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: undefined
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Add Comment On Document
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/comments/add/document/documentId"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Add Comment On Document
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/comments/add/document/documentId")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'

response = http.request(request)
puts response.read_body
```

```java Add Comment On Document
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/comments/add/document/documentId")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Add Comment On Document
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/comments/add/document/documentId', [
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Add Comment On Document
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/comments/add/document/documentId");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Add Comment On Document
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/comments/add/document/documentId")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Comment_addCommentOnDocument_example



**Request**

```json
{
  "receiverEmails": [
    "test1@gmail.com",
    "test2@gmail.com"
  ],
  "message": "Message comment"
}
```

**Response**

```json
{
  "createNotification": {
    "createdAt": 1719979197937,
    "id": "27776e3f-7594-4650-8526-3c2a32362502",
    "info": {
      "avatarURL": "https://staple-new-product-staging.s3.ap-southeast-1.amazonaws.com/avatar/reJjztoVJcC0jwqvtn0kW6W2un3oTHWI-tqg.png?AWSAccessKeyId=AKIATO6YT43ITVHQOBII&Expires=1719979497&Signature=joM2mxpHaON0w483I00GAa1u4r0%3D&response-content-disposition=inline%3B%20filename%3D%22avatar%2FreJjztoVJcC0jwqvtn0kW6W2un3oTHWI-tqg.png%22&response-content-type=image%2Fpng",
      "email": "sender@gmail.com",
      "firstName": "Ash",
      "lastName": "Ketchum",
      "role": "Owner",
      "roleColor": null
    },
    "message": "Message comment",
    "read": false,
    "receivers": [
      {
        "createdAt": 1719979197906,
        "id": "09109efb-ec6d-4bb3-92c5-7a7cc646df40",
        "info": {
          "avatarURL": "",
          "email": "bhanuka@staple.io",
          "firstName": "Staple",
          "lastName": "Employee",
          "role": "Admin",
          "roleColor": "#fe7d4a"
        },
        "read": false,
        "receiver": 1
      },
      {
        "createdAt": 1719979197906,
        "id": "efdf03da-9001-4f77-9a07-f4fc22407b95",
        "info": {
          "avatarURL": "",
          "email": "vvluc@staple.io",
          "firstName": "Staple",
          "lastName": "Employee",
          "role": "Member",
          "roleColor": "#5ab4ec"
        },
        "read": false,
        "receiver": 2
      }
    ],
    "sender": 10,
    "timeSinceCreated": "less than 5 seconds ago"
  }
}
```

**SDK Code**

```python Comment_addCommentOnDocument_example
import requests

url = "https://api.staple.io/v2/comments/add/document/documentId"

payload = {
    "receiverEmails": ["test1@gmail.com", "test2@gmail.com"],
    "message": "Message comment"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Comment_addCommentOnDocument_example
const url = 'https://api.staple.io/v2/comments/add/document/documentId';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"receiverEmails":["test1@gmail.com","test2@gmail.com"],"message":"Message comment"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Comment_addCommentOnDocument_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/comments/add/document/documentId"

	payload := strings.NewReader("{\n  \"receiverEmails\": [\n    \"test1@gmail.com\",\n    \"test2@gmail.com\"\n  ],\n  \"message\": \"Message comment\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Comment_addCommentOnDocument_example
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/comments/add/document/documentId")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"receiverEmails\": [\n    \"test1@gmail.com\",\n    \"test2@gmail.com\"\n  ],\n  \"message\": \"Message comment\"\n}"

response = http.request(request)
puts response.read_body
```

```java Comment_addCommentOnDocument_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/comments/add/document/documentId")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"receiverEmails\": [\n    \"test1@gmail.com\",\n    \"test2@gmail.com\"\n  ],\n  \"message\": \"Message comment\"\n}")
  .asString();
```

```php Comment_addCommentOnDocument_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/comments/add/document/documentId', [
  'body' => '{
  "receiverEmails": [
    "test1@gmail.com",
    "test2@gmail.com"
  ],
  "message": "Message comment"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Comment_addCommentOnDocument_example
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/comments/add/document/documentId");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"receiverEmails\": [\n    \"test1@gmail.com\",\n    \"test2@gmail.com\"\n  ],\n  \"message\": \"Message comment\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Comment_addCommentOnDocument_example
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "receiverEmails": ["test1@gmail.com", "test2@gmail.com"],
  "message": "Message comment"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/comments/add/document/documentId")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```