# Delegate tasks

`POST /v1/bizproc-tasks/delegate`

Bitrix24 authorizes task delegation. The method may delegate some tasks and then return an error for others. Re-read tasks before retrying; a refusal does not guarantee rollback of every change.

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

## Parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `taskIds` | integer[] | Yes | Non-empty list of positive task IDs from [list](./list.md) |
| `fromUserId` | integer | Yes | Current assignee; positive ID from [users](/docs/entities/users) |
| `toUserId` | integer | Yes | New assignee; positive ID from [users](/docs/entities/users) |

## Response fields

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

## Examples

### cURL API 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

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

### JavaScript API 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

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

## Response example

Response shape from a behavior test. No live approval was performed.

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

Invalid parameters are refused before calling Bitrix24:

```json
{"success":false,"error":{"code":"INVALID_PARAMS","message":"Invalid request parameters"}}
```

## Errors

| HTTP | Code | Condition |
|---|---|---|
| 400 | `INVALID_PARAMS` | Malformed or missing parameters |
| 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 for the current user |
| 422 | `BITRIX_ERROR` | Bitrix24 business refusal; original sanitized message |
| 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)
- [Workflow instances](/docs/automation/workflows)
