> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chamelio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Approve Task

> Submit an approval or rejection decision as the access token's user

## Endpoint

```
POST /v2/tasks/{task_id}/approve
```

## Authentication

This endpoint requires an OAuth access token. Send it as a bearer token:

```bash theme={null}
Authorization: Bearer your_access_token
```

**Required scope:** `tasks:write`

<Warning>
  The decision is submitted as the access token's user, who **must already be an eligible approver** on
  the step. If they are not, the request returns `400` - it will not add them to the approver list.
</Warning>

## Path Parameters

| Parameter | Type    | Required | Description                    |
| --------- | ------- | -------- | ------------------------------ |
| `task_id` | integer | Yes      | Unique identifier for the task |

## Request Body

The request body must be a JSON object with the following fields:

### Required Fields

| Field      | Type    | Description                                                 |
| ---------- | ------- | ----------------------------------------------------------- |
| `approved` | boolean | Whether the task is approved (`true`) or rejected (`false`) |

### Optional Fields

| Field        | Type   | Description                                                                            |
| ------------ | ------ | -------------------------------------------------------------------------------------- |
| `comment`    | string | Optional comment explaining the approval or rejection decision                         |
| `variables`  | array  | Ignored on this endpoint                                                               |
| `user_email` | string | Ignored on this endpoint. The decision is always attributed to the access token's user |

<Info>
  `variables` is accepted for compatibility but not applied - the approval step does not collect
  variable values. Send any values you need through the workflow's own steps instead.
</Info>

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://platform.chamelio.ai/v2/tasks/12345/approve" \
    -H "Authorization: Bearer your_access_token" \
    -H "Content-Type: application/json" \
    -d '{
      "approved": true,
      "comment": "Contract terms look acceptable. Approved for signing."
    }'
  ```

  ```python Python theme={null}
  import requests

  task_id = 12345

  url = f"https://platform.chamelio.ai/v2/tasks/{task_id}/approve"
  headers = {
      "Authorization": "Bearer your_access_token",
      "Content-Type": "application/json"
  }

  payload = {
      "approved": True,
      "comment": "Contract terms look acceptable. Approved for signing."
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const taskId = 12345;

  const response = await fetch(
    `https://platform.chamelio.ai/v2/tasks/${taskId}/approve`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer your_access_token',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        approved: true,
        comment: 'Contract terms look acceptable. Approved for signing.'
      })
    }
  );

  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

## Response

### Success Response

**Status Code:** `200 OK`

```json theme={null}
{
  "task_id": 12345,
  "status": "in_progress",
  "approved": true,
  "message": "Approval submitted successfully"
}
```

### Response Fields

| Field      | Type    | Description                                                                        |
| ---------- | ------- | ---------------------------------------------------------------------------------- |
| `task_id`  | integer | ID of the task                                                                     |
| `status`   | string  | Updated task status (typically `"in_progress"` as workflow continues to next step) |
| `approved` | boolean | Whether the task was approved or rejected                                          |
| `message`  | string  | Success confirmation message                                                       |

## Error Responses

### 400 Bad Request

Returned when the access token's user is not an eligible approver on the step, or when the token has
no user behind it.
`client_credentials` tokens act as the admin who created the application, so this applies only to
tokens issued before application creators were recorded.

```json theme={null}
{
  "detail": "Invalid request"
}
```

```json theme={null}
{
  "detail": "client_credentials tokens are not associated with a user"
}
```

### 401 Unauthorized

Returned when the access token is missing, unknown, revoked, or expired, or when an `X-API-Key` was
sent instead of a bearer token. See [OAuth error responses](/api-reference/oauth-apps#error-responses).

```json theme={null}
{
  "detail": "Invalid access token"
}
```

### 403 Forbidden

Returned when the token lacks the required scope:

```json theme={null}
{
  "detail": "Insufficient scope; this endpoint requires: tasks:write"
}
```

Or when the user may not act on this task:

```json theme={null}
{
  "detail": "You do not have access to this resource"
}
```

### 404 Not Found

Returned when the task does not exist.

```json theme={null}
{
  "detail": "Not found"
}
```

### 409 Conflict

Returned when the task is not at an approval step or has already been approved or rejected.

```json theme={null}
{
  "detail": "The task is not in a state that allows this operation"
}
```

### 422 Validation Error

Returned when the request body is invalid.

```json theme={null}
{
  "detail": [
    {
      "loc": ["body", "approved"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
```

### 429 Too Many Requests

Returned when your organization exceeds its per-minute request limit.

```json theme={null}
{
  "detail": "Rate limit exceeded"
}
```

### 500 Internal Server Error

Returned when submission fails due to a server error.

```json theme={null}
{
  "detail": "Failed to submit approval"
}
```

## Notes

<Info>
  When a task is approved, the workflow continues to the next step. When rejected, the workflow
  typically ends or follows a rejection path defined in the workflow.
</Info>

<Tip>
  Call [Get Approval Details](/api-reference/endpoint/v2/tasks/approval-details) first. It returns the
  eligible approver emails, so you can confirm the token's user is among them before submitting.
</Tip>

<Tip>
  Use the `comment` field to document the reasoning behind approval or rejection decisions for audit and
  compliance purposes.
</Tip>

## Use Cases

This endpoint is useful for:

* **Custom approval UIs** - Let approvers decide from your own interface, recorded as themselves
* **Chat and email integrations** - Approve from Slack, Teams, or a mobile app
* **Auditable decisions** - Guarantee the approver on record is the real person who decided
