# Delegate tasks

`POST /v1/bizproc-tasks/delegate`

Bitrix24 checks whether you are allowed to delegate tasks. The method may delegate some tasks and then return an error for the rest. Re-read the task list before retrying; a refusal does not guarantee rollback of every change.

Bitrix24 API: `bizproc.task.delegate`
Scope: `bizproc`

## Request fields (body)

| Field | Type | Required | Description |
|---|---|---|---|
| `taskIds` | integer[] | yes | Non-empty array of positive IDs from the [task list](/docs/automation/bizproc-tasks/list) |
| `fromUserId` | integer | yes | Current assignee. Positive ID from the [employee list](/docs/entities/users/list) |
| `toUserId` | integer | yes | New assignee. Positive ID from the [employee list](/docs/entities/users/list) |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/bizproc-tasks/delegate" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"taskIds":[42],"fromUserId":1,"toUserId":2}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/bizproc-tasks/delegate" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"taskIds":[42],"fromUserId":1,"toUserId":2}'
```

### JavaScript — personal key

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/bizproc-tasks/delegate", {
  method: "POST",
  headers: { "X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({"taskIds":[42],"fromUserId":1,"toUserId":2})
});
console.log(await response.json());
```

### JavaScript — OAuth application

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/bizproc-tasks/delegate", {
  method: "POST",
  headers: { "X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN", "Content-Type": "application/json" },
  body: JSON.stringify({"taskIds":[42],"fromUserId":1,"toUserId":2})
});
console.log(await response.json());
```

## Response fields

| Field | Type | Description |
|---|---|---|
| `success` | boolean | `true` |
| `data` | boolean | `true`, only if Bitrix24 returned `true` |

## Response example

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

## Error response example

400 — `taskIds` is empty or contains values that are not positive integers:

```json
{"success":false,"error":{"code":"INVALID_PARAMS","message":"taskIds must be a non-empty array of positive safe integers"}}
```

## Errors

| HTTP | Code | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | `taskIds`, `fromUserId` or `toUserId` is missing, a value is not a positive integer, or the body contains other fields |
| 401 | `TOKEN_MISSING` | No Bitrix24 credentials |
| 403 | `SCOPE_DENIED` | Missing `bizproc` scope |
| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denies access |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | Key blocks writes |
| 404 | `ENTITY_NOT_FOUND` | Task not found |
| 422 | `BITRIX_ERROR` | Bitrix24 business refusal, for example no permission to delegate. The Bitrix24 code is in the `b24Code` field. The message is preserved with secrets removed |
| 502 | `BITRIX_RESPONSE_INVALID` | Unexpected response shape or action result |

Common refusals and limits: [API errors](/docs/errors).

## See also

- [Business-process tasks](/docs/automation/bizproc-tasks)
- [List tasks](/docs/automation/bizproc-tasks/list)
- [List employees](/docs/entities/users/list)
- [Workflows](/docs/automation/workflows)
