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

# Add Comments

Use this API to add comments within a specific CommentAnnotation.

# Endpoint

`POST https://api.velt.dev/v1/commentannotations/comments/add`

# Headers

<ParamField header="x-velt-api-key" type="string" required>
  Your API key.
</ParamField>

<ParamField header="x-velt-auth-token" type="string" required>
  Your [Auth Token](/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="organizationId" type="string" required>
      Organization ID
    </ParamField>

    <ParamField body="documentId" type="string" required>
      Document ID
    </ParamField>

    <ParamField body="annotationId" type="string" required>
      Comment Annotation ID
    </ParamField>

    <ParamField body="commentData" type="Comment[]" required>
      Array of Comment Data

      <Expandable title="properties">
        <ParamField body="commentId" type="number">
          Custom Comment ID. If not provided, Velt will generate a unique ID for the comment.
        </ParamField>

        <ParamField body="commentText" type="string">
          Comment content in plain text string
        </ParamField>

        <ParamField body="commentHtml" type="string">
          Comment content in HTML string
        </ParamField>

        <ParamField body="isCommentResolverUsed" type="boolean">
          Use this for self-hosting comments data. Set this as true if you are comments resolver data provider in the SDK.
        </ParamField>

        <ParamField body="isCommentTextAvailable" type="boolean">
          Use this for self-hosting comments data. Set this as true if this comment will have text content. Sometimes, comments might only have attachments and in that case, set this as false.
        </ParamField>

        <ParamField body="from" type="User" required>
          User object from whom the comment is added
        </ParamField>

        <ParamField body="createdAt" type="number">
          Created At timestamp (in milliseconds since epoch).
        </ParamField>

        <ParamField body="lastUpdated" type="number">
          Last Updated timestamp (in milliseconds since epoch).
        </ParamField>

        <ParamField body="taggedUserContacts" type="Object[]">
          Array of tagged user contacts

          <Expandable title="properties">
            <ParamField body="text" type="string" required>
              Display text of the tagged user (e.g. "@Username")
            </ParamField>

            <ParamField body="userId" type="string" required>
              User ID of the tagged user
            </ParamField>

            <ParamField body="contact" type="Object" required>
              <Expandable title="properties">
                <ParamField body="email" type="string" required>
                  Email of the tagged user
                </ParamField>

                <ParamField body="name" type="string" required>
                  Name of the tagged user
                </ParamField>

                <ParamField body="userId" type="string" required>
                  User ID of the tagged user
                </ParamField>
              </Expandable>
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

#### 1. Add comment in a CommentAnnotation by organizationId, documentId, and annotationId

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "annotationId": "yourAnnotationId",
    "commentData": [
      {
        "commentText": "Sample Comment",
        "commentHtml": "<div>Hello</div>",
        "from": {
          "userId": "yourUserId"
        }
      }
    ]
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "Comment(s) added successfully.",
    "data": [
      778115
    ]
  }
}
```

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
```

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "Comment(s) added successfully.",
      "data": [
        778115
      ]
    }
  }
  ```
</ResponseExample>
