# Complete a task

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

This performs a real approval. `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 encounter an already completed task.

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

## Parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | integer | Yes | Positive task ID from [list](./list.md) |
| `status` | string | Yes | approve / reject / ok / cancel |
| `comment` | string | No | Decision comment; required when the task form requires it |
| `fields` | object | No | Values keyed by task field code from parameters.Fields[].Id. File values use [filename, base64]. Default request body limit: 1 MiB |

## 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/42/complete" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"status":"approve","comment":"VIBE-PROBE"}'
```

### cURL OAuth

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

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

```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 YOUR_SESSION_TOKEN", "Content-Type": "application/json" },
  body: JSON.stringify({"status":"approve","comment":"VIBE-PROBE"})
});
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)
