## Delegate task

`POST /v1/tasks/:taskId/delegate`

Assigns a new responsible person to a task on behalf of the key's user.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `taskId` (path) | number | yes | Task ID. List: [`GET /v1/tasks`](/docs/entities/tasks/list) |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `userId` | number | yes | ID of the new responsible person. List: [`GET /v1/users`](/docs/entities/users/list) |
| `params` | object | no | Additional action parameters. Passed to Bitrix24 unchanged |

Any field other than `userId` and `params` is rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl -X POST 'https://vibecode.bitrix24.com/v1/tasks/289/delegate' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"userId":42}'
```

### curl — OAuth application

```bash
curl -X POST 'https://vibecode.bitrix24.com/v1/tasks/289/delegate' \
  -H 'X-Api-Key: YOUR_APP_KEY' \
  -H 'Authorization: Bearer USER_SESSION_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"userId":42}'
```

### JavaScript — personal key

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/tasks/289/delegate', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"userId":42}),
})
const result = await response.json()
console.log(result.data.task.responsibleId)
```

### JavaScript — OAuth application

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/tasks/289/delegate', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"userId":42}),
})
const result = await response.json()
console.log(result.data.task.responsibleId)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` on success |
| `data.task` | object | The full task object after the action. Values arrive in raw form: numbers as strings (`"id": "289"`), flags as `Y` or `N` (`"taskControl": "N"`). [`GET /v1/tasks/:id`](/docs/entities/tasks/get) returns the same fields as numbers and `true`/`false` |
| `data.task.id` | string | Task ID |
| `data.task.responsibleId` | string | ID of the responsible person after the call |
| `data.task.action` | object | Which actions the key's user can take after the call: the key is the action name (`start`, `pause`, `complete`, `approve`, `disapprove`, `defer`, `renew` and others), the value is `true` or `false` |

## Response example

Only the main fields of the task object are shown.

```json
{
  "success": true,
  "data": {
    "task": {
      "id": "289",
      "title": "Prepare the quarterly report",
      "status": "2",
      "createdBy": "1",
      "responsibleId": "42",
      "changedDate": "2026-10-19T17:52:59+02:00",
      "taskControl": "N",
      "action": {
        "start": true,
        "pause": false,
        "complete": true,
        "approve": false,
        "disapprove": false,
        "defer": true,
        "renew": false
      }
    }
  }
}
```

## Error response example

400 — `userId` is missing:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "userId must be a positive integer"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `taskId` is not a positive integer: `taskId must be a positive integer` |
| 400 | `INVALID_PARAMS` | The request body is not a JSON object: `body must be an object` |
| 400 | `INVALID_PARAMS` | The body contains fields other than `userId` and `params`: `body contains unsupported fields` |
| 400 | `INVALID_PARAMS` | `userId` is missing or is not a positive integer: `userId must be a positive integer` |
| 400 | `INVALID_PARAMS` | `params` is not an object: `params must be an object` |
| 401 | `MISSING_API_KEY` | `X-Api-Key` is missing |
| 401 | `INVALID_API_KEY` | The key is not found |
| 401 | `TOKEN_MISSING` | The key has no valid Bitrix24 token |
| 403 | `SCOPE_DENIED` | The key lacks the `task` or `tasks` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only |
| 403 | `BITRIX_ACCESS_DENIED` | The key's user has no rights to the task |
| 422 | `BITRIX_ERROR` | No task exists with this `taskId`: `Action unavailable` |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the delegation for another reason |

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

## Known specifics

- **A missing task does not return `404`.** An unknown `taskId` gets `422 BITRIX_ERROR` with the message `Action unavailable`. To check whether a task exists, request it with [`GET /v1/tasks/:id`](/docs/entities/tasks/get): for a missing task it returns `404`.

## See also

- [Add task accomplices](/docs/entities/tasks/add-accomplices)
- [Add task auditors](/docs/entities/tasks/add-auditors)
- [Get task](/docs/entities/tasks/get)
- [Tasks](/docs/entities/tasks)
