> ## 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 Comment Annotations

Use this API to update comment annotations in a document within an organization.
Additional filters can be applied using location IDs, annotation IDs, or user IDs.

# Endpoint

`POST https://api.velt.dev/v1/commentannotations/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="locationIds" type="string[]">
      Array of Location IDs
    </ParamField>

    <ParamField body="userIds" type="string[]">
      Array of User IDs. These are the users who created the comment annotation.
    </ParamField>

    <ParamField body="annotationIds" type="string[]">
      Array of Annotation IDs
    </ParamField>

    <ParamField body="updatedData" type="Object[]">
      <Expandable title="properties">
        <ParamField body="location" type="Object">
          <Expandable title="properties">
            <ParamField body="id" type="string" required>
              Location ID
            </ParamField>

            <ParamField body="locationName" type="string">
              Location Name
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="targetElement" type="Object">
          Target Element

          <Expandable title="properties">
            <ParamField body="elementId" type="string">
              Element DOM Id
            </ParamField>

            <ParamField body="targetText" type="string">
              Target Text. Provide this if you want to add comment annotation on the provided text content.
            </ParamField>

            <ParamField body="occurrence" type="number">
              Occurrence. Provide this if you want to add comment annotation on a text content.
            </ParamField>

            <ParamField body="selectAllContent" type="boolean">
              Select All Content. Provide this if you want to select and add comment annotation on the entire text content of the target elementId.
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="from" type="User">
          User object from whom the Comment Annotation is added
        </ParamField>

        <ParamField body="status" type="Status">
          Status

          <Expandable title="properties">
            <ParamField body="id" type="string" required>
              Status ID
            </ParamField>

            <ParamField body="name" type="string" required>
              Status Name
            </ParamField>

            <ParamField body="type" type="'default' | 'ongoing' | 'terminal'" required>
              Type.
            </ParamField>

            <ParamField body="color" type="string">
              Text and comment pin color
            </ParamField>

            <ParamField body="lightColor" type="string">
              Background color on the status indicator
            </ParamField>

            <ParamField body="svg" type="string">
              Raw SVG of the icon.
            </ParamField>

            <ParamField body="iconUrl" type="string">
              Icon URL.
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="assignedTo" type="User">
          User object to whom the comment is assigned
        </ParamField>

        <ParamField body="context" type="Object">
          Custom key/value metadata object
        </ParamField>

        <ParamField body="priority" type="Object">
          Priority

          <Expandable title="properties">
            <ParamField body="id" type="string" required>
              Priority ID
            </ParamField>

            <ParamField body="name" type="string" required>
              Priority Name
            </ParamField>

            <ParamField body="color" type="string">
              Priority Color
            </ParamField>

            <ParamField body="lightColor" type="string">
              Priority Light Color
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="updateUsers" type="Object[]">
      <Expandable title="properties">
        <ParamField body="oldUser" type="User" required>
          <Expandable title="properties">
            <ParamField body="userId" type="string" required>
              Old user's ID
            </ParamField>

            <ParamField body="name" type="string">
              Old user's name
            </ParamField>

            <ParamField body="email" type="string">
              Old user's email
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="newUser" type="User" required>
          <Expandable title="properties">
            <ParamField body="userId" type="string" required>
              New user's ID
            </ParamField>

            <ParamField body="name" type="string">
              New user's name
            </ParamField>

            <ParamField body="email" type="string">
              New user's email
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

#### 1. Update all comment annotations by organizationId and documentId

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "updatedData" : {
      "status": {
        "type": "ongoing"
      }
    }
  }
}
```

#### 2. Update comment annotations by organizationId, documentId and locationIds

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "locationIds": [
      "locationx"
    ],
    "updatedData" : {
      "status": {
        "type": "ongoing"
      }
    }
  }
}
```

#### 3. Update annotations by organizationId, documentId, locationIds and userIds

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "locationIds": [
      "locationx"
    ],
    "userIds": [
      "yourUserId"
    ],
    "updatedData" : {
      "status": {
        "type": "ongoing"
      }
    }
  }
}
```

#### 4. Update comment annotations by organizationId, documentId and userIds

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "userIds": [
      "yourUserId"
    ],
    "updatedData" : {
      "status": {
        "type": "ongoing"
      }
    }
  }
}
```

#### 5. Update comment annotations by organizationId, documentId and annotationIds

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "annotationIds": [
      "yourAnnotationId1",
      "yourAnnotationId2"
    ],
    "updatedData" : {
      "status": {
        "type": "ongoing"
      }
    }
  }
}
```

#### 6. Update comment annotations by organizationId, documentId, locationIds and annotationIds

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "locationIds": [
      "locationx"
    ],
    "annotationIds": [
      "yourAnnotationId1",
      "yourAnnotationId2"
    ],
    "updatedData" : {
      "status": {
        "type": "ongoing"
      }
    }
  }
}
```

#### 7. Update Users in existing comment annotations

```JSON theme={null}
{
  "data": {
    "organizationId": "yourOrganizationId",
    "documentId": "yourDocumentId",
    "annotationIds": [
      "yourAnnotationId1",
      "yourAnnotationId2"
    ],
    "updateUsers" : [
      {
        "oldUser": {
          "userId": "oldUserId",
        },
        "newUser": {
          "userId": "newUserId",
          "name": "newUserName",
          "email": "newUserEmail"
        }
      }
    ]
  }
}
```

# Response

#### Success Response

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

#### Failure Response

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

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