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

# Update Comments

Use this API to update comments within a specific CommentAnnotation.

# Endpoint

`POST https://api.velt.dev/v2/commentannotations/comments/update`

# 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="commentIds" type="number[]" required>
      Comment IDs
    </ParamField>

    <ParamField body="updatedData" type="object" required>
      Comment data

      <Expandable title="properties">
        <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="context" type="object">
          Custom key/value metadata object. This is used to store any additional information about the comment.
        </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="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>

        <ParamField body="attachments" type="object[]">
          Array of attachments to include with the comment. See [Attachment](/api-reference/sdk/models/data-models#attachment) for full schema details.

          <Expandable title="properties">
            <ParamField body="attachmentId" type="number" required>
              Unique identifier for the attachment
            </ParamField>

            <ParamField body="name" type="string">
              File name of the attachment
            </ParamField>

            <ParamField body="bucketPath" type="string">
              Path to the file in storage bucket
            </ParamField>

            <ParamField body="size" type="number">
              File size in bytes
            </ParamField>

            <ParamField body="type" type="string">
              File type (e.g., "image", "video", "document")
            </ParamField>

            <ParamField body="url" type="string">
              Download URL of the attachment
            </ParamField>

            <ParamField body="thumbnail" type="string">
              Thumbnail URL of the attachment
            </ParamField>

            <ParamField body="mimeType" type="string">
              MIME type of the attachment (e.g., "image/png", "video/mp4")
            </ParamField>

            <ParamField body="metadata" type="object">
              Custom metadata for the attachment (e.g., dimensions, timestamps, etc.)
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

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

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "annotationId": "yourAnnotationId",
    "commentIds": [
      153783,
      607395
    ],
    "updatedData": {
      "commentText": "Sample Updated Comment",
      "commentHtml": "<div>Hello Updated</div>"
    }
  }
}
```

#### 2. Update comment with attachments

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "annotationId": "yourAnnotationId",
    "commentIds": [
      123456
    ],
    "updatedData": {
      "commentText": "Updated comment text with new attachments",
      "commentHtml": "<p>Updated comment text with <em>new attachments</em></p>",
      "attachments": [
        {
          "attachmentId": 100001,
          "name": "updated-screenshot.png",
          "bucketPath": "attachments/org-123/doc-456/updated-screenshot.png",
          "size": 1536000,
          "type": "image",
          "url": "https://storage.googleapis.com/bucket/updated-screenshot.png",
          "thumbnail": "https://storage.googleapis.com/bucket/updated-screenshot_thumb.png",
          "mimeType": "image/png",
          "metadata": {
            "width": 1920,
            "height": 1080,
            "updatedAt": 1696122000000
          }
        }
      ]
    }
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "Comment updated successfully.",
    "data": {
      "607395": {
        "success": true,
        "id": 607395,
        "message": "Updated successfully"
      }
    }
  }
}
```

#### Failure Response

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

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "Comment updated successfully.",
      "data": {
        "607395": {
          "success": true,
          "id": 607395,
          "message": "Updated successfully"
        }
      }
    }
  }
  ```
</ResponseExample>
