# Ask an agent to review a pull request.

> Starts the reviewer role on the pull request's head commit, on a machine, as a step Koidog adds to the pull request's crew (it is not counted as the crew's work): it reads the change with the rules in the repository's `AGENTS.md` and `CLAUDE.md` at that commit and writes findings (category, `blocker|major|minor|nit`, confidence, file and line).
> https://koi.dog/docs/api/pull-requests/start-review-agent/

`POST /api/v1/pull-requests/{id}/review-agent` · Scope: `crews`

It changes nothing: its checkout is discarded. Findings arrive at `GET /pull-requests/{id}/findings`; nothing is posted to GitHub. A direct crew's task pull request only: a managed crew's pull request already has its independent reviewer (`409 managed_crew`). One review per head commit at a time (`409 review_running`). The head must be the commit Koidog holds for the branch (`409 head_not_in_mirror`). Reopens an ended crew while it runs; the crew's own result does not change. The timeline records the key ID, action and outcome.

## Path parameters.

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

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Body.

An omitted body is read as `{}`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `connectionId` | `string` | no | The model connection the review agent runs on. Default: the crew's reviewer connection, else its builders'. At least 5 characters. |
| `model` | `string` | no | The model to review with. Default: the crew's reviewer model, else the connection's own. At least 1 character. |

## Response.

202 Accepted · JSON object. Follow progress on the timeline.

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

```sh
curl -X POST "https://api.koi.dog/api/v1/pull-requests/$ID/review-agent" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)"
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/pull-requests/${process.env.ID}/review-agent`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
  },
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    f"https://api.koi.dog/api/v1/pull-requests/{os.environ['ID']}/review-agent",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "pullRequestId": "string",
  "headSha": "string",
  "state": "queued",
  "stateReason": "string",
  "taskId": "string",
  "agentId": "string",
  "connectionId": "string",
  "model": "string",
  "rules": [],
  "verdict": "approve",
  "summary": "string",
  "findings": 0,
  "by": {
  },
  …
}
```
