# Complete a task

`POST /v1/bizproc-tasks/:id/complete`

This is a real approval, not a test run. `approve`, `reject`, `ok`, `cancel` are sent as 1, 2, 3, 4. Bitrix24 checks which decisions the task type allows. Re-read the list after a timeout: a retry may be refused because the task is already completed.

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

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` (path) | integer | yes | Positive task ID from the [task list](/docs/automation/bizproc-tasks/list) |

## Request fields (body)

| Field | Type | Required | Description |
|---|---|---|---|
| `status` | string | yes | Decision: `approve`, `reject`, `ok` or `cancel` |
| `comment` | string | no | Decision comment. Required when the task form demands one |
| `fields` | object | no | Values keyed by field code from the task's `parameters.Fields[].Id` in the [task list](/docs/automation/bizproc-tasks/list). A file is `[name, base64]`. Request body limit: 1 MiB |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/bizproc-tasks/42/complete" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"status":"approve","comment":"VIBE-PROBE"}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/bizproc-tasks/42/complete" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"status":"approve","comment":"VIBE-PROBE"}'
```

### JavaScript — personal key

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/bizproc-tasks/42/complete", {
  method: "POST",
  headers: { "X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({"status":"approve","comment":"VIBE-PROBE"})
});
console.log(await response.json());
```

### JavaScript — OAuth application

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/bizproc-tasks/42/complete", {
  method: "POST",
  headers: { "X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN", "Content-Type": "application/json" },
  body: JSON.stringify({"status":"approve","comment":"VIBE-PROBE"})
});
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

404 — no task with this `id` among the current user's tasks:

```json
{"success":false,"error":{"code":"ENTITY_NOT_FOUND","message":"Task not found or inaccessible"}}
```

## Errors

| HTTP | Code | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer, `status` is not in the list, `comment` is not a string, `fields` is not an object, 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 for the current user |
| 422 | `BITRIX_ERROR` | Bitrix24 business refusal. 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)
- [Workflows](/docs/automation/workflows)
