> ## 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.

# Attach Comment

Use this API to attach a comment a person wrote to a check. The attached comment counts in the check's open count and pages, lists under the check in [List Check Comments](https://velt.dev/docs/api-reference/rest-apis/v2/agents/checks/comments/list.md), and resolves and verifies with it. Attaching a comment that is already attached to another check moves it.

Only a person's comment can be attached. An agent comment already belongs to its check and is refused. The engine never attaches a comment on its own. See [Checks Overview](https://velt.dev/docs/api-reference/rest-apis/v2/agents/checks/overview.md#comment).

# Endpoint

`POST https://api.velt.dev/v2/agents/checks/comments/attach`

# Headers

**x-velt-api-key** `string` *required*

Your API key.

**x-velt-auth-token** `string` *required*

Your [Auth Token](https://velt.dev/docs/security/auth-tokens.md).

# Body

#### Params

**data** `object` *required*

**properties**

**organizationId** `string` *required*

1 to 512 characters. The organization of the project.

**documentId** `string` *required*

1 to 512 characters. The document of the project.

**annotationId** `string` *required*

The person's comment annotation id. 1 to 512 characters, no `/`, and not `.` or `..`.

**ruleKey** `string` *required*

The check. `[a-z0-9:-]`, at most 120 characters.

**userId** `string` *required*

1 to 512 characters. Recorded as the person who attached the comment.

The schema uses `.strict()`: unknown fields are rejected.

## **Example Requests**

```JSON theme={null}
{
  "data": {
    "organizationId": "org_acme",
    "documentId": "acme-marketing-site",
    "annotationId": "H3vN6pQ1zT8kWmB5xYcR",
    "ruleKey": "link-broken",
    "userId": "user_sam"
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "Comment attached",
    "data": {
      "attached": true,
      "ruleKey": "link-broken"
    }
  }
}
```

| Field | Type | Description |
| - | - | - |
| `data.attached` | boolean | Always `true`. |
| `data.ruleKey` | string | The check the comment is now attached to. |

The comment's [`checkInfo`](https://velt.dev/docs/api-reference/sdk/models/data-models#checkinfo) now holds `attached: true` and `attachedRuleKey`.

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "An agent comment cannot be attached to or detached from a check",
    "status": "FAILED_PRECONDITION",
    "details": {
      "reason": "CHECKS_AGENT_COMMENT_NOT_ATTACHABLE"
    }
  }
}
```

**Errors:** `INVALID_ARGUMENT` (a body outside the schema: a missing or malformed `annotationId` or `ruleKey`, a missing `userId`, or an unknown field) / `NOT_FOUND` with `CHECKS_COMMENT_NOT_FOUND` (no such comment in the project) or `CHECKS_WORKSPACE_NOT_FOUND` (the workspace has no store database) / `FAILED_PRECONDITION` with `CHECKS_AGENT_COMMENT_NOT_ATTACHABLE` (an agent comment).

```js theme={null}
{
  "result": {
    "status": "success",
    "message": "Comment attached",
    "data": {
      "attached": true,
      "ruleKey": "link-broken"
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.