# Approve or deny a pending approval.

> An approval action.
> https://koi.dog/docs/api/approvals/decide-approval/

`POST /api/v1/approvals/{id}/decide` · Scope: `approve`

Deciding one that is no longer pending answers `409 conflict`. A `plan` approval (a managed crew launched with `limits.review.planApproval`) takes three answers: `approve: true` starts its tasks; `approve: false, changes: true` with a `note` sends the note to the manager, which plans again (within the crew's `planRevisions`); `approve: false` alone cancels the crew with the note as the reason. `changes` on any other approval answers `400`. When an API key calls it, the timeline records who did what and the outcome. No query parameters.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The approval's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Makes a retry safe: the same key with the same request returns the first answer and does nothing else. |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `approve` | `boolean` | yes | `true` approves, `false` denies. |
| `note` | `string` | no | Why, in your words. Kept with the decision and shown on the timeline. Default empty. |
| `changes` | `boolean` | no | Plan approvals only, with `approve: false`: ask the manager for a new plan instead of canceling the crew. `note` is required and goes to the manager. Refused on any other approval. |

## Response.

200 OK: a `Approval`. The example has placeholder values.

- **422 validation_failed**: The body does not match its schema; each problem is in `details`.

## Request.

```sh
curl -X POST "https://app.koi.dog/api/v1/approvals/$ID/decide" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
      "approve": true,
      "note": "Looks right."
    }'
```

```js
const res = await fetch(`https://app.koi.dog/api/v1/approvals/${process.env.ID}/decide`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    approve: true,
    note: "Looks right.",
  }),
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    f"https://app.koi.dog/api/v1/approvals/{os.environ['ID']}/decide",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "approve": True,
        "note": "Looks right.",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "kind": "merge",
  "title": "string",
  "detail": "string",
  "state": "pending",
  "createdAt": "string",
  "decidedBy": {
  },
  …
}
```
