
## Comment fields

`GET /v1/tasks/:taskId/comments/fields`

Returns the task comment field schema: for each of the five fields — its type, a read-only flag, a label, and a description. Useful for code generation and AI-agent hints.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `taskId` (path) | number | yes | Task ID. The value is not validated — the schema is the same for any value, including a nonexistent task |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/tasks/289/comments/fields" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/tasks/289/comments/fields" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/289/comments/fields', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/289/comments/fields', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

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

## Response fields

`data.fields` is an object keyed by field name; each value is `{ type, readonly, label, description }`.

| Field | Type | RO | Description |
|------|-----|----|---------|
| `id` | number | yes | Comment identifier. May come back as `null` in the create response on a new card |
| `taskId` | number | yes | Parent task identifier. Taken from the URL path |
| `authorId` | number | yes | Comment author. Employee list: `GET /v1/users` |
| `message` | string | | Comment text, up to 65,535 characters. The only writable field, required on create. Supports BB-code |
| `createdAt` | datetime | yes | Creation date and time, UTC ISO 8601 |

The RO fields (`readonly: true`) are set by the platform and are not accepted on create or update. Only `message` is writable.

## Response example

```json
{
  "success": true,
  "data": {
    "fields": {
      "id": { "type": "number", "readonly": true, "label": "ID", "description": "Comment identifier.", "nullable": true },
      "taskId": { "type": "number", "readonly": true, "label": "Task ID", "description": "Identifier of the parent task (from the URL path)." },
      "authorId": { "type": "number", "readonly": true, "label": "Author ID", "description": "ID of the user who posted the comment — an ID from GET /v1/users." },
      "message": { "type": "string", "readonly": false, "label": "Message", "description": "Comment text. Required on create." },
      "createdAt": { "type": "datetime", "readonly": true, "label": "Created at", "description": "Creation date, UTC ISO 8601." }
    }
  }
}
```

## Error response example

403 — the key lacks the `task` scope:

```json
{
  "success": false,
  "error": {
    "code": "SCOPE_DENIED",
    "message": "This endpoint requires 'task' scope"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 403 | `SCOPE_DENIED` | The API key does not have the `task` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not provided |

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

## See also

- [List comments](./list.md)
- [Create comment](./create.md)
- [Employees](/docs/entities/users)
- [Tasks](/docs/entities/tasks)
