## Create a task result from a chat message

`POST /v1/task-results/from-chat-message`

Turns a message from a task's chat into a result of that task: the method takes the result text from the message and determines the task from the chat where the message was posted.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `fields` | object | yes | Object with the message ID |
| `fields.messageId` | number | yes | ID of a message in the task chat. List: [`GET /v1/tasks/:taskId/chat/messages`](/docs/entities/tasks/chat). Number only: for the string `"43121"` the method returns `400` |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/task-results/from-chat-message" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fields": {
      "messageId": 43121
    }
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/task-results/from-chat-message" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fields": {
      "messageId": 43121
    }
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/task-results/from-chat-message', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: {
      messageId: 43121,
    },
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/task-results/from-chat-message', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: {
      messageId: 43121,
    },
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` if the result was created |
| `data` | object | Wrapper with the created result |
| `data.item` | object | The created result |
| `data.item.id` | number | Result ID. Needed to [update](/docs/entities/tasks/results-v3-update) and [delete](/docs/entities/tasks/results-v3-delete) the result |
| `data.item.taskId` | number | ID of the task whose chat the message belongs to |
| `data.item.text` | string | Result text — the text of the message |
| `data.item.authorId` | number | ID of the result author. List: [`GET /v1/users`](/docs/entities/users/list) |
| `data.item.createdAt` | string | Creation date and time in ISO 8601 format with a time zone offset |
| `data.item.updatedAt` | string | Date and time of the last change, in the same format |
| `data.item.status` | string | Result status. A new result has `open` |
| `data.item.fileIds` | null | Result files. A result without files has `null` |
| `data.item.rights` | object | Permissions on the result |
| `data.item.rights.edit` | boolean | `true` — the result text can be changed |
| `data.item.rights.remove` | boolean | `true` — the result can be deleted |
| `data.item.messageId` | number | ID of the message the result was created from |

## Response example

```json
{
  "success": true,
  "data": {
    "item": {
      "id": 23,
      "taskId": 4205,
      "text": "The report is ready, the files are in the project folder",
      "authorId": 1295,
      "createdAt": "2026-10-16T09:44:58+00:00",
      "updatedAt": "2026-10-16T09:44:58+00:00",
      "status": "open",
      "fileIds": null,
      "rights": {
        "edit": true,
        "remove": true
      },
      "messageId": 43121
    }
  }
}
```

## Error response example

403 — the message was not posted in a task chat:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ACCESS_DENIED",
    "message": "Access denied",
    "hint": "Bitrix24 reports an access-rights refusal for tasks.task.result.addfromchatmessage, not a scope error. The Bitrix24 user this call runs as lacks access; ask a portal admin to grant it, or call under a user who has it.",
    "cause": "b24_permission",
    "method": "tasks.task.result.addfromchatmessage",
    "fix": {
      "action": "grant_b24_rights",
      "via": "portal_admin"
    }
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | The body is not a JSON object or has no `fields` object. Message: `fields must be an object` |
| 400 | `INVALID_PARAMS` | `messageId` is passed as a string. The reason is in `error.validation` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `BITRIX_ACCESS_DENIED` | No message with this `messageId` exists, or it was not posted in a task chat |
| 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 non-empty body with a `Content-Type` other than `application/json` |
| 422 | `BITRIX_ERROR` | `fields` has no `messageId`. The missing field is named in `error.validation` |
| 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 repeated call creates another result.** Each request with the same `messageId` adds a new result with the same text to the task. Results already created are listed by [`GET /v1/tasks/:taskId/results`](/docs/entities/tasks/results).

## See also

- [Task results: REST 3.0](/docs/entities/tasks/results-v3)
- [Add a task result](/docs/entities/tasks/results-v3-create)
- [Update a task result](/docs/entities/tasks/results-v3-update)
- [Delete a task result](/docs/entities/tasks/results-v3-delete)
- [Task results: legacy REST](/docs/entities/tasks/results)
- [Task chat](/docs/entities/tasks/chat)
