
## Add a comment

`POST /v1/posts/:id/comments`

Adds a comment to a Feed post. The post is identified by the ID in the path, and the comment text is passed in the request body.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` | number | yes | Post ID (path parameter). List: [GET /v1/posts](/docs/feed/posts/list) |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `text` | string | yes | Comment text. Supports BB-code |

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/posts/118/comments \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Approved, starting work."
  }'
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/posts/118/comments \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Approved, starting work."
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/posts/118/comments', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    text: 'Approved, starting work.',
  }),
})

const { success, data } = await res.json()
console.log('Comment ID:', data)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/posts/118/comments', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    text: 'Approved, starting work.',
  }),
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `data` | number | ID of the created comment |

## Response example

```json
{
  "success": true,
  "data": 41
}
```

## Error response example

404 — post not found:

```json
{
  "success": false,
  "error": {
    "code": "POST_NOT_FOUND",
    "message": "No post found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `MISSING_PARAMS` | The `text` parameter is missing |
| 403 | `COMMENT_ACCESS_DENIED` | No permission to comment on this post |
| 404 | `POST_NOT_FOUND` | No post found with the given `id` |
| 409 | `DUPLICATE_COMMENT` | A repeated comment with the same text |
| 403 | `SCOPE_DENIED` | The API key lacks the `log` scope |
| 401 | `TOKEN_MISSING` | The API key has no access tokens configured |

The full list of common API errors — [Errors](/docs/errors).

## See also

- [Delete a comment](/docs/feed/comments/delete)
- [Comments](/docs/feed/comments)
- [Posts](/docs/feed/posts)
- [Errors](/docs/errors)
