## Create a task result from a comment

`POST /v1/task-results/from-comment/:commentId`

Turns a comment from the old task card into a result of that task: the method takes the result text from the comment and determines the task from it.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `commentId` (path) | number | yes | ID of a comment on the old task card, a positive integer. List: [`GET /v1/tasks/:taskId/comments`](/docs/entities/task-comments/list) — it returns old-card comments for a task without a chat |

## Request fields (body)

The body is optional. The method accepts no fields other than `params`.

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `params` | object | no | Additional data in the response |
| `params.WITH_FILE_INFO` | string | no | `Y` — add `fileInfo` with file data to the result. `N` or omitted — do not add it |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/task-results/from-comment/8611" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/task-results/from-comment/8611" \
  -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/task-results/from-comment/8611', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/task-results/from-comment/8611', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

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

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` if the request succeeded |
| `data` | object \| null | The created result or `null`. `null` comes back for a system comment, such as the automatic message about task completion: no result is created, and there is no error |
| `data.id` | number | Result ID. Needed to [update](/docs/entities/tasks/results-v3-update) and [delete](/docs/entities/tasks/results-v3-delete) the result |
| `data.taskId` | number | ID of the task the comment belongs to |
| `data.commentId` | number | Comment ID from the path |
| `data.createdBy` | number | ID of the employee on whose behalf the call is made, not of the comment author. List: [`GET /v1/users`](/docs/entities/users/list) |
| `data.createdAt` | string | Date and time of the comment, not of the call, in ISO 8601 format with a time zone offset |
| `data.updatedAt` | string | Date and time of the last change, in the same format. For a new result it matches `createdAt` |
| `data.status` | number | Result status: `0` — open, `1` — closed |
| `data.text` | string | Comment text. May contain BB code markup |
| `data.formattedText` | string | The same text with BB code markup converted to HTML |
| `data.files` | array \| null | IDs of the result files. A result without files has `null`, or an empty array with `params.WITH_FILE_INFO` = `Y`. File data is in `fileInfo` |
| `data.fileInfo` | object | Only with `params.WITH_FILE_INFO` = `Y`. File data, keyed by file ID. A result without files has an empty array `[]` |

## Response example

Result created:

```json
{
  "success": true,
  "data": {
    "id": 33,
    "taskId": 2079,
    "commentId": 8611,
    "createdBy": 1295,
    "createdAt": "2023-12-22T10:41:45+00:00",
    "updatedAt": "2023-12-22T10:41:45+00:00",
    "status": 0,
    "text": "22745",
    "formattedText": "22745",
    "files": null
  }
}
```

System comment, no result created:

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

## Error response example

422 — no comment with this `commentId` exists:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Comment not found.",
    "b24Code": "0"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `commentId` is not a positive integer. Message: `commentId must be a positive integer` |
| 400 | `INVALID_PARAMS` | The body is not a JSON object. Message: `body must be an object` |
| 400 | `INVALID_PARAMS` | The body has a field other than `params`. Message: `body contains unsupported fields` |
| 400 | `INVALID_PARAMS` | `params` is not an object. Message: `params must be an object` |
| 400 | `INVALID_PARAMS` | `params` has a field other than `WITH_FILE_INFO`, or `WITH_FILE_INFO` is neither `Y` nor `N`. Message: `params only accepts WITH_FILE_INFO as Y or N` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key has no `task` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode. `error.details.switchUrl` contains the URL of the section where the mode is changed |
| 415 | `FST_ERR_CTP_INVALID_MEDIA_TYPE` | A body with a `Content-Type` the API does not parse, such as `application/xml` |
| 422 | `BITRIX_ERROR` | No comment with this `commentId` exists. Message: `Comment not found.` |
| 422 | `BITRIX_ERROR` | A result has already been created from the comment, and it is open. Message: `Result already exists.` |
| 422 | `BITRIX_ERROR` | The employee on whose behalf the call is made cannot read the task, or is neither the comment author nor a Bitrix24 account administrator. Message: `Access denied.` |
| 429 | `RATE_LIMITED` | Request rate exceeded. The effective cap is in the `x-ratelimit-limit` header |

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

## Known specifics

**A chat message ID does not work here.** For a task with a chat, the comment list returns chat message IDs, while this method looks up an old-card comment by ID across all tasks of the Bitrix24 account. To turn a chat message into a result, use [`POST /v1/task-results/from-chat-message`](/docs/entities/tasks/results-v3-from-chat-message).

**The call also changes the comment itself.** The comment gets a result mark, and the task history — [`GET /v1/tasks/:taskId/history`](/docs/task-history) — gets a `RESULT` entry with the comment ID.

## See also

- [Task results: legacy REST](/docs/entities/tasks/results)
- [Get the ID of the first task result](/docs/entities/tasks/results-first)
- [Get the ID of the last task result](/docs/entities/tasks/results-last)
- [Create a task result from a chat message](/docs/entities/tasks/results-v3-from-chat-message)
- [Task results: REST 3.0](/docs/entities/tasks/results-v3)
- [Tasks](/docs/entities/tasks)
