# HTTP API

URL: https://codepanel.ai/docs/api

Reference for the /api/v1 HTTP API: authentication, scopes, limits, errors, every endpoint with its parameters and response, and the review payload.

The [MCP server](/docs/mcp-server) and the [CLI](/docs/cli) are thin clients over this API. For the loop an agent runs on top of it, see the [Agent playbook](/docs/agents).

## Overview

| | |
| --- | --- |
| Base URL | `https://codepanel.ai/api/v1` (a self-hosted deployment: its own site, or its `.convex.site` address; the token dialog in **Settings → API tokens** shows it, and `codepanel login` saves it) |
| Auth | `Authorization: Bearer cpk_...`, a personal API token |
| Format | JSON in, JSON out, `cache-control: no-store` |
| Limits | 120 requests per minute per token; see [Limits and errors](#limits-and-errors) |

```bash
export CODEPANEL_URL="https://codepanel.ai"
export CODEPANEL_TOKEN=cpk_...
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/me"
```

The API is RPC over fixed paths, with no path parameters:

- `GET` inputs come from the query string. `POST` inputs come from a JSON object body of at most 65,536 characters. The content type is not checked, and an empty body counts as `{}`.
- Integer inputs (`pr`, `limit`, `days`) and booleans also accept strings such as `"123"` and `"true"`. `maxAutoRounds`, `botMaxRounds`, `stepBackAfterRounds` and `budgetUsd` must be JSON numbers.
- A `repo` is `owner/name`.

Provider keys and cards cannot be set over the API. Keys are entered in the browser so they never pass through an agent's context; the API reports only their status. A card is saved in Stripe's own pages.

### Endpoints

| Endpoint | Scope | Purpose |
| --- | --- | --- |
| [`GET /me`](#get-me) | any | Who the token belongs to, and whether its account can run reviews |
| [`GET /repos`](#get-repos) | `read` | Connected repositories |
| [`GET /github/repos`](#get-githubrepos) | `read` | GitHub repositories you can connect |
| [`POST /repos/connect`](#post-reposconnect) | `repos:write` | Connect a repository |
| [`POST /repos/disconnect`](#post-reposdisconnect) | `repos:write` | Disconnect a repository |
| [`POST /repos/settings`](#post-repossettings) | `repos:write` | Auto-review, round limits, panel, gate, inline suggestions, agent files, review switches |
| [`GET /repos/switches`](#get-reposswitches) | `read` | The review switches a repository sets, and the ones its next round uses |
| [`GET /budget`](#get-budget) | `read` | The monthly budget and a repository's cap: spend, holds and what is left |
| [`POST /budget`](#post-budget) | `budget:write` | Set the monthly budget or a repository's cap |
| [`GET /auto-reload`](#get-auto-reload) | `read` | Credits auto-reload: its settings, this month's reloads, and why it last turned itself off |
| [`POST /auto-reload`](#post-auto-reload) | `budget:write` | Turn credits auto-reload on or off, or change it |
| [`GET /credits-first`](#get-credits-first) | `read` | Whether reviews spend credits before your own provider keys |
| [`POST /credits-first`](#post-credits-first) | `budget:write` | Turn credits first on or off |
| [`GET /account/sharing`](#get-accountsharing) | `read` | Whether your findings count toward the public model and agent stats |
| [`POST /account/sharing`](#post-accountsharing) | `repos:write` | Opt in or out of the public model and agent stats |
| [`GET /panels`](#get-panels) | `read` | Panels with members and readiness |
| [`GET /models`](#get-models) | `read` | Models your keys, or CodePanel credits, can reach |
| [`GET /roles`](#get-roles) | `read` | Reviewer roles |
| [`POST /panels/reviewers/add`](#post-panelsreviewersadd) | `panel:write` | Add a reviewer |
| [`POST /panels/reviewers/remove`](#post-panelsreviewersremove) | `panel:write` | Remove a reviewer |
| [`POST /panels/members/update`](#post-panelsmembersupdate) | `panel:write` | Change a member's name, model, effort, instructions or path scope |
| [`POST /panels/orchestrator`](#post-panelsorchestrator) | `panel:write` | Set the orchestrator |
| [`POST /panels/update`](#post-panelsupdate) | `panel:write` | Rename a panel, set its per-PR limit |
| [`GET /panels/recommend`](#get-panelsrecommend) | `read` | Recommend a panel for a cost and quality goal |
| [`POST /panels/apply`](#post-panelsapply) | `panel:write` | Apply that recommendation, to one repository or a panel |
| [`POST /panels/restore`](#post-panelsrestore) | `panel:write` | Undo an apply |
| [`GET /keys`](#get-keys) | `read` | Provider key status, never the key |
| [`GET /knowledge`](#get-knowledge) | `read` | A repository's rules, notes and verdicts as one Markdown document |
| [`POST /knowledge`](#post-knowledge) | `repos:write` | Replace the rules and notes from that document |
| [`GET /learnings`](#get-learnings) | `read` | A repository's learnings |
| [`POST /learnings`](#post-learnings) | `reviews:write` | Add a learning |
| [`POST /learnings/feedback`](#post-learningsfeedback) | `reviews:write` | Confirm or turn off a learning |
| [`GET /plans`](#get-plans) | `read` | Your tracked plans |
| [`GET /plans/get`](#get-plansget) | `read` | One tracked plan with its steps, sub-plans, history and next action |
| [`POST /plans`](#post-plans) | `reviews:write` | Save a tracked plan or sub-plan |
| [`POST /plans/steps`](#post-planssteps) | `reviews:write` | Add steps to a plan |
| [`POST /plans/step`](#post-plansstep) | `reviews:write` | Move a step to a new status, or edit it |
| [`POST /plans/update`](#post-plansupdate) | `reviews:write` | Edit, abandon or reactivate a plan |
| [`POST /reviews/trigger`](#post-reviewstrigger) | `reviews:write` | Start a review now |
| [`POST /reviews/handoff`](#post-reviewshandoff) | `reviews:write` | Leave the author agent's handoff for the next round |
| [`GET /review-brief`](#get-review-brief) | `read` | The brief for reviewing a change yourself before you push; free |
| [`POST /reviews/local`](#post-reviewslocal) | `reviews:write` | Send back what the brief found, shown as your claim; free |
| [`POST /reviews/rounds`](#post-reviewsrounds) | `reviews:write` | Set a pull request's automatic round limit |
| [`GET /review`](#get-review) | `read` | The review snapshot and payload for a pull request |
| [`GET /reviews/status`](#get-reviewsstatus) | `read` | Whether the latest review has finished |
| [`GET /sessions`](#get-sessions) | `read` | Recent review sessions |
| [`GET /sessions/get`](#get-sessionsget) | `read` | One session |
| [`GET /findings`](#get-findings) | `read` | Findings on a pull request |
| [`POST /findings/dismiss`](#post-findingsdismiss) | `reviews:write` | Dismiss a finding; from an agent, dispute it |
| [`POST /findings/reopen`](#post-findingsreopen) | `reviews:write` | Reopen a dismissed finding |
| [`POST /feedback`](#post-feedback) | `reviews:write` | Rate findings or the review |
| [`POST /reviews/ask`](#post-reviewsask) | `reviews:write` | Ask the orchestrator about the review or a finding |
| [`GET /reviews/ask`](#get-reviewsask) | `read` | Read a question and its answer |
| [`GET /quality`](#get-quality) | `read` | Verified review precision, and how the review loop converges |
| [`GET /spend`](#get-spend) | `read` | This month's model costs on a repository by role, provider and model, with suggestions |
| [`GET /precision-audit`](#get-precision-audit) | `read` | The weekly random sample of posted findings a person audits, and its precision |
| [`GET /escapes`](#get-escapes) | `read` | What reviews missed: reviewed lines a later fix or revert commit changed, and the rate |
| [`POST /escapes/mark`](#post-escapesmark) | `reviews:write` | Mark an escape as not an escape, or take the mark back |
| [`POST /device/code`](#post-devicecode), [`POST /device/token`](#post-devicetoken) | none | Device login |

The read-only `GET /api/review` endpoint for CI (outside `/api/v1`) is documented in [Merge gate](/docs/merge-gate).

## Authentication

Send `Authorization: Bearer cpk_...`. A personal token is `cpk_` followed by 43 characters. It is shown once when created and stored only as a SHA-256 hash, so a lost token cannot be recovered: create a new one.

You create tokens in **Settings → API tokens**, choosing a name, an expiry (30 days, 90 days, 1 year or no expiry) and scopes. Tokens are revocable; an expired or revoked token is rejected. Only a signed-in browser session can create or revoke tokens, so a leaked token cannot mint more. The one other way to get a token is [device login](#device-login), which also needs a person to approve it in the browser.

A repository webhook secret is not accepted. A CI token (the read-only, single-repository token used by the [merge gate](/docs/merge-gate)) gets `403` on `/api/v1`.

### Scopes

| Scope | Grants |
| --- | --- |
| `read` | Every `GET`: repositories, panels, models, key status, knowledge, learnings, tracked plans, sessions, reviews, findings, questions, quality, spend |
| `repos:write` | Connect, disconnect and configure repositories; replace a repository's knowledge; choose whether their findings count toward the public model and agent stats |
| `panel:write` | Add, remove and edit reviewers, set the orchestrator, rename a panel, set its per-PR limit |
| `reviews:write` | Trigger reviews (they spend your provider keys or credits), leave handoffs, set rounds, dismiss, reopen and rate findings, ask questions, add and rate learnings, save and update tracked plans |
| `budget:write` | Set, raise or remove the monthly budget, repository caps and the agents' day and per-ticket caps (`/autopilot/day-cap`), set credits auto-reload, which charges your saved card, and turn credits first on or off. No other scope includes it, so a token that runs reviews cannot raise its own limit or charge your card unless you add it. A token a tool asks for gets it only when you tick it on the approval page, so an agent cannot lift the limits that stop its own spending |
| `agents:write` | Create, edit, duplicate and remove the agent app's coding agents (`/autopilot/agents`), add or remove its MCP connections (`/autopilot/connections`), and resume agents after Stop everything (`/autopilot/resume`). No other scope includes it, so a token that runs reviews cannot change an agent's model, mode ceiling, rules or kill switch unless you add it. A token a tool asks for gets it only when you tick it on the approval page, since a higher mode ceiling lets runs ask less and resuming lifts the kill switch |
| `tasks:write` | Queue and cancel the agent app's tasks, and record their runs (`/tasks`). No other scope includes it, so a token that reviews or edits agents cannot hand an agent work unless you add it. It does not answer what runs wait on |
| `interrupts:answer` | Answer what the agent app's runs wait on: allow or deny a permission, reply to a question (`/tasks/runs/answer`, `/inbox/answer`). A token you make in Settings gets it with `tasks:write` unless you untick it. A token a tool asks for (`codepanel login`, a connector) gets it only when you tick it on the approval page, so an agent that hands out work cannot approve what that work asks. Without it, an answer is refused with `missing_scope` and a `nextAction`. A token made before 2026-11-21 with `tasks:write` keeps answering, and Settings marks the scope as carried over |
| `rules:write` | Make standing permission rules: always allow one exact command in a repository (`POST /autopilot/permissions`). No token gets it by default, and a token a tool asks for gets it only when you tick it on the approval page, since a standing allow means the run never asks you |

Write scopes do not imply `read`. Give a token only the scopes it needs.

## Device login

How `codepanel login` gets a token, and how any tool you build can. It follows the OAuth device grant (RFC 8628). Neither route takes a token.

1. `POST /device/code` returns a `user_code`, a `verification_uri` and a `verification_uri_complete` that carries the code.
2. Show the user the code and open `verification_uri_complete` in their browser (print it when you cannot). The page fills the code in, keeps it through sign-in, and shows it with the client name and the requested scopes. The user checks it matches, may narrow the scopes, and approves or denies. Opened without a code, `/device` asks for one.
3. Poll `POST /device/token` with the `device_code` every `interval` seconds until it returns a token or a final error.

The token appears in **Settings → API tokens** under the client name, where it can be revoked. Only approve a code you started yourself.

### POST /device/code

Starts a login.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `client_name` | string | no | Shown to the user when they approve |
| `scope` | string | no | Space-separated scopes. Default `read reviews:write` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/device/code" -d '{"client_name":"my-tool","scope":"read reviews:write"}'
```

```json
{
  "device_code": "...",
  "user_code": "BCDF-2GHJ",
  "verification_uri": "https://codepanel.ai/device",
  "verification_uri_complete": "https://codepanel.ai/device?user_code=BCDF-2GHJ",
  "expires_in": 600,
  "interval": 5
}
```

An unknown scope is `400` "unknown scope: <name>". Over a limit (20 an hour per caller address, 200 an hour across all callers) it returns `429 {"error": "temporarily_unavailable"}` with `retry-after`.

### POST /device/token

Exchanges an approved code for a token.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `device_code` | string | yes | From `POST /device/code` |
| `grant_type` | string | no | If sent, must be `urn:ietf:params:oauth:grant-type:device_code` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/device/token" -d '{"device_code":"..."}'
```

```json
{ "access_token": "cpk_...", "token_type": "bearer", "scope": "read reviews:write", "expires_in": 7776000 }
```

The token (90 days) is returned exactly once. Errors are `400 {"error", "error_description"}`:

| `error` | Meaning |
| --- | --- |
| `authorization_pending` | Not approved yet; keep polling |
| `slow_down` | Polling too fast; use the larger `interval` in the response (also the `429` code past 240 polls a minute per address) |
| `access_denied` | The user denied it. Stop |
| `expired_token` | The code expired. Start again |
| `invalid_grant` | Unknown or already used code. Stop |
| `unsupported_grant_type` | `grant_type` is not the device grant |

## Limits and errors

### Rate limits

| Limit | Value |
| --- | --- |
| Requests | 120 per minute per token (shared with `GET /api/review`) |
| `POST /reviews/trigger` | 20 per hour per token, on top of the request limit |
| `POST /reviews/ask` | 10 questions per hour per pull request |
| Request body | 65,536 characters |

Over a limit you get `429` with a `retry-after` header in seconds. Checks run in this order: authentication, the per-minute limit, the scope, then the endpoint's own limit. A request refused with `403` still counts toward the 120 per minute; a request with a missing or invalid token does not.

A `429` from these checks means the request did nothing, so making it again after `retry-after` is safe. The CLI, the stdio MCP server and the local runner wait it out for you, at most four tries and two minutes per call, with a little jitter: every `GET`, and the runner's run updates, interrupts, diff and registration, which repeat without changing anything. Other writes report the `429` for you to decide.

### Error shape

```json
{ "error": "this token lacks the reviews:write scope", "code": "missing_scope", "scope": "reviews:write" }
```

Branch on `code`, which is stable; `error` is for people and may be reworded. `rate_limited` adds `retryAfter` (seconds), `missing_scope` adds `scope`, and a `precondition` with a stable cause adds `reason`.

| `code` | Status | Meaning |
| --- | --- | --- |
| `invalid_input` | `400`, `413` | A field is missing, malformed or out of range. Fix the request; retrying it unchanged fails again |
| `unauthorized` | `401` | No token, or one that is invalid, revoked or expired |
| `forbidden` | `403` | A CI token, or an action the token may not take |
| `missing_scope` | `403` | The token lacks a scope; `scope` names it |
| `not_found` | `404` | The thing does not exist or is not yours |
| `rate_limited` | `429` | Over a limit; `retryAfter` matches the `retry-after` header |
| `precondition` | `400` | Well formed, but something must change first, such as "Add a working provider API key in Settings first." `reason` is `plan_required`, `plan_limit`, `credits_required`, `credits_exhausted`, `provider_key_missing` or `provider_key_invalid` when the cause has a stable name ([Billing](/docs/billing)) |
| `internal` | `500` | `{"error": "internal error"}`. Details are logged server-side, never echoed. Retrying later may work |

### Messages

| Status | Messages |
| --- | --- |
| `400` | "request body must be JSON"; "request body must be a JSON object"; field errors that name the field, such as "repo must be owner/name" or "pr must be a positive integer"; and preconditions, such as "No working API key for openai. Add one in Settings first." or "GitHub token not found" |
| `401` | "missing bearer token"; "not a CodePanel API token; create one in Settings → API tokens" (also what a webhook secret gets); "invalid, revoked or expired token" |
| `403` | "this token lacks the <scope> scope"; "this is a CI token for one repository; create a personal token in Settings → API tokens" |
| `404` | A repository, pull request, review, panel, reviewer, finding, session or question that does not exist or is not yours. Both get the same answer, so the API cannot probe other accounts |
| `413` | "request body too large" |
| `429` | "rate limit exceeded; retry in <n>s" |

## Identity

### GET /me

The token's owner.

Scope: any valid token.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/me"
```

```json
{
  "githubUsername": "octocat",
  "token": "laptop CLI",
  "scopes": ["read", "reviews:write"],
  "subscription": { "required": true, "active": false, "plan": null, "nextAction": "Ask the account's owner to subscribe at https://codepanel.ai/settings?tab=billing; until then every review is refused with plan_required." }
}
```

With a plan, `subscription.plan` is:

```json
{ "id": "solo", "name": "Solo", "prsPerMonth": 300, "prsThisMonth": 245, "allowance": "near", "concurrentRounds": 2, "feeFreeCreditsUsd": 0, "feeFreeLeftUsd": 0, "grandfathered": false }
```

`githubUsername` can be `null`. `token` is the token's name. `subscription` says whether reviews here need the [subscription](/docs/billing) (`required`) and whether the account has one (`active`, always `true` where none is required). Without one, every review is refused with `plan_required`, and `nextAction` says what to pass on to the account's owner, since subscribing happens in the browser; it is `null` when `active` is `true`. `active` is `null` when CodePanel could not read the subscription; `required` still says whether one is needed.

`plan` is `null` without one. `prsThisMonth` is the distinct pull requests that started a round this calendar month (UTC), and `allowance` is `within`, `near` (from 80% of `prsPerMonth`), `grace` (past it, still reviewing) or `paused` (new pull requests are refused with `plan_limit` until the 1st). For `near`, `grace` and `paused`, `nextAction` carries the notice, including the plan to upgrade to; pass it on to the account's owner. `concurrentRounds` is how many rounds run at once (more wait and start on their own), `feeFreeCreditsUsd` the credits a month bought without the purchase fee (the plan's price on Team and Scale, 0 on Solo), and `feeFreeLeftUsd` how many of them are left this month. `grandfathered` is `true` for a subscription started before the plans: Solo's limits at its original price, given up for good by a plan change.

## Repositories

A repository object has `_id`, `githubOwner`, `githubName`, `githubFullName`, `githubRepoId`, `defaultBranch`, `isActive`, `settings` (`autoReview`, `maxAutoRounds`, `botMaxRounds`, `trustedBotAuthors`, `stepBackAfterRounds`, `idleNudgeHours`, `inlineSuggestions`, `modelOverrides`, `triggers`, `panelId`, `gate`, `agentFiles`, `reviewSwitches`, `escalation`, `crossFamilyReview`, `autoFix`, `autoApproveOnPass`, `convergence`), `webhookId`, `createdAt` and `updatedAt`. No secrets are included.

### GET /repos

Your connected repositories, as an array of repository objects.

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/repos"
```

### GET /github/repos

The GitHub repositories you can push to.

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/github/repos"
```

```json
[{ "fullName": "acme/api", "private": true, "defaultBranch": "main", "canInstallWebhook": true }]
```

Connecting needs `canInstallWebhook`, which means admin access.

### POST /repos/connect

Connects a repository and installs or adopts its webhook.

Scope: `repos:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/repos/connect" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"repo":"acme/api"}'
```

```json
{
  "repoId": "j57...",
  "fullName": "acme/api",
  "webhookInstalled": true,
  "nextSteps": ["Set this repository up for coding agents in one pull request that adds .codepanel/rules.md ..."]
}
```

`nextSteps` is empty once the default branch has both `.codepanel/rules.md` and the CodePanel section in AGENTS.md or CLAUDE.md. Otherwise it says how to add the missing ones with the [Repository setup](/docs/agent-setup) prompt; a file GitHub could not read counts as missing. Needs admin permission on the repository. GitHub supplies the repository id and default branch. Errors: "Repository not found, or your GitHub account cannot access it."; "GitHub token not found. Sign out and sign in again."

### POST /repos/disconnect

Stops reviewing a repository. Past reviews are kept.

Scope: `repos:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/repos/disconnect" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"repo":"acme/api"}'
```

```json
{ "ok": true }
```

The GitHub webhook stays installed. Only **Disconnect** on the repository's **Settings** tab in the dashboard also removes it.

### POST /repos/settings

Changes a repository's review settings. Fields you leave out are unchanged.

A token can tighten the merge protections (`gate`, `trustedBotAuthors`, `escalation`, `crossFamilyReview`, `autoApproveOnPass`) but not loosen them. A lower `gate`, an added App, a removed escalation contact, cross-family review turned off and auto-approve turned on are refused with 403 (`forbidden`): `fields` names each one, nothing in the update is applied, and `nextAction` is the repository's settings page in the dashboard, where a person makes the change. See [Who can loosen the gate](/docs/merge-gate#who-can-loosen-the-gate).

Scope: `repos:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `autoReview` | boolean | no | Review pull requests automatically |
| `maxAutoRounds` | integer or `null` | no | Automatic rounds per pull request, 1 to 50; `null` removes the limit. Past it, `/review` and agent triggers are refused except the round that confirms an agent's answer on a critical; **Review now** on the dashboard always runs |
| `botMaxRounds` | integer or `null` | no | Rounds in all a bot's `/rounds` comment may extend a pull request to, 0 to 50; 0 stops bots adding rounds, `null` returns to the default of 5 |
| `trustedBotAuthors` | array of strings or `null` | no | Up to 10 exact GitHub App logins, such as `"my-agent[bot]"`, reviewed like a member ([trusted bot authors](/docs/triggering-reviews#trusted-bot-authors)); `[]` or `null` trusts none. A prefix or a person's login is refused with 400. A token can remove Apps but not add one (403) |
| `stepBackAfterRounds` | integer or `null` | no | The round from which the review comment and `payload.stepBack` advise the author to reconsider the approach, 0 to 50; 0 turns it off, `null` returns to the default of 3. It stops nothing and never changes the gate. See [Round limits](/docs/triggering-reviews#step-back) |
| `idleNudgeHours` | integer or `null` | no | Hours without a push, comment, rating or read after which CodePanel posts one comment naming the pull request's `nextAction`, when that action is its author's, 0 to 23; 0 turns it off, `null` returns to the default of 6. See [Idle nudge](/docs/triggering-reviews#idle-nudge) |
| `panelId` | string or `null` | no | Pin the repository to a panel; `null` returns it to your default |
| `gate` | string | no | `off`, `critical`, `warning_high`, `warning` or `all`: the least severe finding that must be answered before the `CodePanel` commit status passes. `warning_high` holds criticals and high-confidence warnings. `off` clears the status and stops posting it. Unset means `warning`. A token can raise it but not lower it (403), except that it may set `warning_high` from `warning` or `all`. See [Merge gate](/docs/merge-gate) |
| `convergence` | object | no | Switches that settle a pull request after its gate has passed, each off unless set: `settleAfterGreen`, `orchestratorAdvisory`, `disputeLearnings` and `doneWarnsPush`. `true` turns one on, `false` or `null` off; names you leave out stay as they are. A token may set any of them; `settleAfterGreen` and `orchestratorAdvisory` narrow what blocks. See [Convergence switches](/docs/merge-gate#convergence-switches) |
| `inlineSuggestions` | boolean | no | Also post blocking findings' patches as suggestion comments on the diff, which turns patches on for the repository's rounds. Off by default. See [Findings](/docs/findings) |
| `autoApproveOnPass` | `false` | no | Stop posting an approving GitHub review when the `CodePanel` status passes. `true` is refused with 403 (`forbidden`): it is turned on only in the dashboard, since an approval can satisfy a required review. See [Auto-approve](/docs/merge-gate#auto-approve) |
| `agentFiles` | boolean | no | Read the repository's `AGENTS.md` and `CLAUDE.md` into reviews. When absent from `settings`, CodePanel's default applies: off. See [Repo context](/docs/repo-context) |
| `escalation` | object or `null` | no | Hand findings no agent can settle to people: `contacts` (1 to 5 GitHub logins, a leading `@` is dropped) and optional `triggers` (`upheld_critical`, `round_limit`, `step_back`, `novel`; `upheld_critical` and `round_limit` when left out). `null` clears it; unset, nothing escalates. A token can add contacts but not remove them (403). See [Merge gate](/docs/merge-gate#escalate-to-a-person) |
| `crossFamilyReview` | object or `null` | no | Never judge a change only by the model family that wrote it: `enabled`, optional `fullLanePaths` (up to 50 globs over changed files) and optional `fullLaneMarker` (a phrase or heading in the pull request description). While `enabled`, and when the author's family is known, the round's orchestrator, which carries the verdict, runs on a usable model of another family; a full-lane pull request (a changed file matches a glob, or the description holds the marker) also gets a frontier model. `null` clears it; unset, rounds run as the panel is configured. A token can turn it on but not off (403). See [Cross-family verdicts](/docs/reviewers#cross-family-verdicts) |
| `reviewSwitches` | object | no | [Review switches](/docs/review-switches) for this repository, over CodePanel's defaults: `REVIEW_CACHEABLE_PROMPTS`, `REVIEW_REVIEWER_TOOLS`, `REVIEW_PRECISION_RULES`, `REVIEW_CHANGED_LINES`, `REVIEW_BASE_MERGE_SCOPE`, `REVIEW_LEARNING_ATTRIBUTION`, `REVIEW_PROOF_GRADING`, `REVIEW_NOVEL_ESCALATION`, `REVIEW_HOLD_LATER_SUGGESTIONS`, `REVIEW_CONFIRM_FIXES` ([fix check](/docs/merge-gate#fix-check-past-the-round-limit)), `REVIEW_PREFIX_DIAGNOSTICS`, `REVIEW_ORCHESTRATOR_CACHE`, `REVIEW_CURRENT_PRACTICE` and `REVIEW_UNREVIEWED_FILES`. Each is `true`, `false`, or `null` to follow CodePanel's setting again; names you leave out stay as they are. `REVIEW_CACHEABLE_PROMPTS` and `REVIEW_HOLD_LATER_SUGGESTIONS` ([suggestions after round 1](/docs/triggering-reviews#suggestions-after-round-1)) are on by default, so `false` is how a repository turns one off. Any other name is refused |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/repos/settings" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","maxAutoRounds":5,"gate":"warning"}'
```

```json
{ "ok": true, "reviewSwitches": { "REVIEW_CACHEABLE_PROMPTS": { "deployment": true, "override": null, "effective": true, "source": "default" } } }
```

`reviewSwitches` lists every switch: `deployment` (CodePanel's value: the switch's default unless CodePanel's environment sets it; on for `REVIEW_CACHEABLE_PROMPTS` and `REVIEW_HOLD_LATER_SUGGESTIONS`, off for the others), `override` (the repository's own, `null` for none), `effective` (what its next round uses) and `source` (`repository`, `deployment` when CodePanel's environment sets the switch, or `default`: where `effective` comes from). Each round records the switches it ran with in its pipeline stamp.

### GET /repos/switches

The review switches a repository sets for itself, in the shape `POST /repos/settings` returns.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/repos/switches?repo=acme/api"
```

```json
{ "repo": "acme/api", "reviewSwitches": {
  "REVIEW_CACHEABLE_PROMPTS": { "deployment": true, "override": false, "effective": false, "source": "repository" },
  "REVIEW_REVIEWER_TOOLS": { "deployment": false, "override": null, "effective": false, "source": "default" } } }
```

## Monthly budget

The account's monthly budget and a repository's own cap ([Budgets and spending limits](/docs/budgets-and-limits)). Both count spend on your own provider keys only; credits and the per-PR limit are not read or changed here.

### GET /budget

Each limit, this month's spend and holds against it, and what is left.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | no | `owner/name`, to include its cap and what its next round meets |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/budget?repo=acme/api"
```

| Field | Notes |
| --- | --- |
| `month` | The calendar month (UTC) counted, `YYYY-MM` |
| `enforced` | Always `true`: every limit's `status` is what a round meets |
| `account` | `limitUsd` (`null` for no budget), `source` (`default`, `custom` or `none`), `spentUsd`, `heldUsd` (estimates held by running rounds), `remainingUsd` and `status` (`unlimited`, `open`, `reached`, or `uncountable` when the account has too many repositories or running rounds to count) |
| `repo` | With `repo`: `repo`, `capUsd` (`null` when only the account budget applies), the same counts and `status`, and `review`: what the next round on it meets, with `status`, `remainingUsd`, `limitedBy` (`repo` or `account`) and the `refusal` it would get |

### POST /budget

Sets the account budget, a repository's cap, or both.

Scope: `budget:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `monthlyUsd` | number, `"default"` or `null` | no | The account budget: an amount in USD, `"default"` for the $25 default, or `null` for no budget |
| `repo` | string | no | `owner/name`; needed with `capUsd` |
| `capUsd` | number or `null` | no | The repository's own monthly cap; `null` removes it, so only the account budget applies. A cap is checked as well as the account budget, not instead of it |

Give at least one of `monthlyUsd` and `capUsd`. An amount must be positive.

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/budget" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","capUsd":20}'
```

Returns `{ "before": {...}, "after": {...}, "changed": ["repo"] }`, `before` and `after` in the shape of `GET /budget`. Both use one count of this month's spend, so they differ only in the limits.

### GET /spend

This calendar month's (UTC) recorded model costs on one repository. Subscription fees are not in it.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/spend?repo=acme/api" \
  | jq '{totalUsd, ownKeyUsd, creditsUsd, complete, byModel: [.byModel[] | {role, modelId, usd, failedCalls}]}'
```

The response:

| Field | Meaning |
| --- | --- |
| `repo`, `month` | The repository and the month, as `YYYY-MM` |
| `totalUsd`, `ownKeyUsd`, `creditsUsd` | Everything spent, the part on your own provider keys (what the [monthly budget](#monthly-budget) counts), and the part paid from CodePanel credits |
| `calls`, `unpricedCalls` | Model calls recorded, and how many had no price to count |
| `byModel` | One row per `role`, `provider` and `modelId`: `usd`, `calls` and `failedCalls`. Failed calls are in it because they can cost money too |
| `itemizedCalls`, `complete`, `groupLimitReached` | How many calls `byModel` accounts for; `complete` is `false` when older calls were not itemized, and `groupLimitReached` `true` when there were more rows than it shows |
| `suggestions` | Advice drawn from the numbers, each with `id`, `title`, `evidence` and `action`, such as an orchestrator taking most of the spend, or many failed calls |
| `nextAction` | Whether the breakdown can be trusted as the whole month, and what to do if not |
| `account` | The whole account, as the desktop app's Spend page shows it (below) |

`account` covers every repository and the spend with none:

| Field | Meaning |
| --- | --- |
| `days` | The last 30 UTC days, oldest first: `usd`, `creditsUsd`, `calls` and `mergedPrs` each |
| `recordedSince` | The first day CodePanel kept for the account, or `null`. Days before it read as zero because they were not recorded, not because nothing was spent; `month` still counts them |
| `window` | The 30 days summed: `usd`, `creditsUsd`, `ownKeyUsd`, `calls`, `unpricedCalls`, `mergedPrs` (pull requests CodePanel reviewed that merged; one it never reviewed is not counted), `usdPerMergedPr` (all spend over those merges, `null` with none), `inputTokens`, `cacheReadTokens`, `cacheReadShare` (the share of prompt tokens read from a provider's cache) and `cacheSavedUsd` (what that cache saved at each model's listed prices, net of the cache-write premium) |
| `month` | This UTC month from the running totals: `usd`, `creditsUsd`, `ownKeyUsd`, `projectedUsd` and `projectedBudgetedUsd` (at the month's pace, `null` on its first day), `budget` (as in `GET /budget`), `byModel` (per `provider` and `modelId`, roles together) and `modelsComplete` |

Read it with [`GET /quality`](#get-quality) before you change models: a cheaper model is a saving only if its findings stay as good. Over MCP, `get_optimization` combines the two with panel alternatives.

## Credits auto-reload

When it is on, a credit balance below your threshold charges your saved card for a credit pack plus the purchase fee, up to a monthly cap ([Billing](/docs/billing#auto-reload)).

### GET /auto-reload

Scope: `read`. No inputs.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/auto-reload"
```

| Field | Notes |
| --- | --- |
| `enabled` | Whether it is on |
| `status` | `off`, `on`, `pending` (a charge is running), `turned_off` (by a failure; see `offReason`) or `capped` (this month's cap stopped a reload) |
| `thresholdUsd`, `packUsd`, `monthlyCapUsd` | The settings; before the first change, the defaults it turns on with: $5, $25 and $100 |
| `chargeUsd` | What one reload charges now: the pack plus the purchase fee on any part of it past `feeFreeUsd` |
| `month`, `reloadedUsd` | The calendar month (UTC) the cap counts, and the credits its reloads bought, a running one included |
| `pendingSince`, `lastReloadAt`, `capReachedAt` | Timestamps in milliseconds, or `null` |
| `retryAfter` | Stripe was unavailable for the last attempt; the next waits until this time (milliseconds), else `null` |
| `offReason`, `offAt` | While it stays off after a failure: `card_declined`, `authentication_required` (the bank asked to confirm the charge), `no_payment_method`, `payment_failed`, `disputed`, `stalled` (a charge did not finish within an hour) or `billing_error` (CodePanel's own Stripe setup refused the charge, or Stripe stayed unavailable through every retry) |
| `disputeOpen` | A payment to CodePanel is under dispute; turning auto-reload on is refused (400) until it closes |
| `message` | For `turned_off` and `capped`, and while `disputeOpen`, what to do next |
| `packOptionsUsd` | The amounts `packUsd` can be |
| `feeFreeUsd` | The plan's fee-free credits left this month; `chargeUsd` has no fee on that part of the pack |

### POST /auto-reload

Scope: `budget:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean | no | Turn it on or off. Turning it on needs a subscription and no open dispute, and clears `offReason` |
| `thresholdUsd` | number | no | Reload when the balance falls below this; positive |
| `packUsd` | number | no | Credits each reload buys: one of `packOptionsUsd` |
| `monthlyCapUsd` | number | no | The most credits reloads may buy per calendar month (UTC); at least `packUsd` |

Give at least one. A value left out keeps its saved setting, or the default. If it is on and the balance is already below the threshold, the change starts a reload at once.

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/auto-reload" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"enabled":true,"thresholdUsd":10,"packUsd":50,"monthlyCapUsd":200}'
```

Returns `{ "before": {...}, "after": {...} }`, each in the shape of `GET /auto-reload`.

## Credits first

Whether review rounds spend your CodePanel credits before your own provider keys ([Billing](/docs/billing#which-key-a-call-uses)). On by default. With it on, a reviewer whose provider has both your valid key and CodePanel's runs on credits while your balance covers its reservation, and on your key once it does not; a model with no known price always runs on your key. Off, your own key always wins. Each round decides once, before any model is called; `payload.keys` in [`GET /review`](#get-review) says which key paid for each reviewer.

### GET /credits-first

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/credits-first"
```

```json
{ "creditsFirst": true, "source": "default" }
```

| Field | Notes |
| --- | --- |
| `creditsFirst` | Whether the next review round spends credits before your own keys |
| `source` | `default` until you choose, then `set` |

### POST /credits-first

Scope: `budget:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean or `null` | yes | `true` or `false`, or `null` to go back to the default (on) |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/credits-first" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"enabled":false}'
```

Returns `{ "before": {...}, "after": {...} }`, each in the shape of `GET /credits-first`. It applies from the next round.

## Public model stats

Whether your account's findings count toward the totals on [Benchmarks](/benchmarks) and the [agent pages](/agents) ([Public model stats](/docs/security#public-model-stats)). On unless you turn it off.

### GET /account/sharing

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/account/sharing"
```

```json
{ "shareModelStats": true, "source": "default", "appliesAt": "2026-10-17T05:31:00.000Z" }
```

| Field | Notes |
| --- | --- |
| `shareModelStats` | Whether the next refresh counts your findings |
| `source` | `default` until you choose, then `set` |
| `appliesAt` | When the published numbers are next rebuilt, and so follow this setting |

### POST /account/sharing

Scope: `repos:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `shareModelStats` | boolean or `null` | yes | `false` keeps every repository's findings out, `true` counts them, `null` goes back to the default (counted) |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/account/sharing" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"shareModelStats":false}'
```

Returns `{ "before": {...}, "after": {...} }`, each in the shape of `GET /account/sharing`.

## Panels and models

### GET /panels

Your panels with their members and whether each can run.

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/panels"
```

```json
[{
  "_id": "k17...", "name": "Default", "isDefault": true, "ready": true,
  "budgetUsd": 5, "budgetIsDefault": true,
  "orchestrator": { "_id": "...", "name": "Sonnet 5.5", "provider": "anthropic", "providerName": "Anthropic", "modelId": "claude-sonnet-5-5", "reasoningEffort": "medium", "callable": true, "priced": true, "totalReviews": 12, "totalCostUsd": 1.07 },
  "reviewers": [{ "_id": "...", "name": "Bugs & Security", "provider": "anthropic", "modelId": "claude-haiku-5-5", "callable": true, "priced": true }]
}]
```

| Field | Meaning |
| --- | --- |
| `ready` | The orchestrator is callable and at least one reviewer is |
| `budgetUsd` | The per-PR limit in force; absent when turned off. `budgetIsDefault` is true when the panel never set one |
| `callable` | False when the provider key behind the member is missing or broken |
| `priced` | False when CodePanel has no price for the model, so its calls cannot count toward a spending limit |
| `failure` | Present while the member keeps failing: `consecutiveFailures`, `reason` (the provider's error) and `lastFailureAt`. Reviews still post without it; switching its model clears it |
| `followTier` | The tier whose newest model the member is kept on; absent when it is pinned to its model |
| `lastMove` | The latest automatic model change: `fromModelId`, `toModelId`, `reason` (`upgrade` or `replaced`) and `movedAt` |
| Other member fields | `slug`, `description`, `avatar`, `systemPrompt`, `isDefault`, `totalReviews`, `totalCostUsd`; the orchestrator also has `instructions`, your additions to its built-in prompt |

`orchestrator` is `null` when the panel has none.

### GET /models

The models panel members can use: those your valid keys reach, then, if you may spend CodePanel credits, those CodePanel's keys reach for providers you have no key for.

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/models"
```

```json
[{ "provider": "anthropic", "providerName": "Anthropic", "id": "claude-haiku-5-5", "displayName": "Claude Haiku 5.5", "source": "own_key", "inputUsdPerMTok": 0.1, "outputUsdPerMTok": 0.5, "typicalCallUsd": 0.00355, "tiers": ["economy"] }]
```

`source` is `own_key` or `credits` ([Billing](/docs/billing)). `inputUsdPerMTok` and `outputUsdPerMTok` are list prices per million tokens, `typicalCallUsd` is one reviewer call of production's median size (26K tokens in, 1.9K out), and `tiers` are the cost tiers that pick the model for its provider; the prices are `null` for a model CodePanel has no price for.

### GET /roles

The reviewer roles, which are what a reviewer looks for. See [Reviewers and panels](/docs/reviewers).

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/roles"
```

```json
[{ "id": "bugs-security", "name": "Bugs & Security", "summary": "...", "tier": "economy", "effort": "low", "isDefault": true }]
```

`tier` is the cost tier the role is suggested on, `effort` its suggested reasoning effort, and `isDefault` marks the starter panel's roles. The ids are `bugs-security`, `tests-maintainability`, `security`, `performance`, `api-migrations`, `conventions` (Docs & Best Practices) and `design-ux`.

### POST /panels/reviewers/add

Adds a reviewer, from a role or with a model you choose.

Scope: `panel:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `panelId` | string | yes | From `GET /panels` |
| `role` | string | no | A role `id` from `GET /roles`. Fills in the name, instructions and effort, and suggests a model on the role's tier. An unknown id is a `400` listing the valid ones |
| `provider` | string | without `role` | From `GET /models`. With a `role`, picks which provider's model is suggested |
| `modelId` | string | without `role` | Exactly as `GET /models` reports it. Needs `provider` |
| `reasoningEffort` | string | no | `none`, `low`, `medium`, `high`, `xhigh` or `max` |
| `name` | string | no | Defaults to the role's name, else the model's label |
| `systemPrompt` | string | no | Instructions for this reviewer; replaces the role's |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/panels/reviewers/add" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"panelId":"k17...","role":"security"}'
```

```json
{ "agentId": "...", "member": { "_id": "...", "name": "...", "provider": "...", "modelId": "..." } }
```

Explicit `name`, `systemPrompt` and `reasoningEffort` win over the role's. Without a role and a model: "Pass provider and modelId, or a role."

### POST /panels/reviewers/remove

Removes a reviewer. A panel keeps at least one.

Scope: `panel:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `panelId` | string | yes | From `GET /panels` |
| `agentId` | string | yes | The reviewer's `_id` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/panels/reviewers/remove" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"panelId":"k17...","agentId":"..."}'
```

```json
{ "ok": true }
```

### POST /panels/members/update

Changes a reviewer's or the orchestrator's model, effort, or a reviewer's instructions.

Scope: `panel:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `agentId` | string | yes | A reviewer or the orchestrator |
| `provider`, `modelId` | string | no | Pass together to change the model |
| `reasoningEffort` | string | no | `none`, `low`, `medium`, `high`, `xhigh` or `max` |
| `systemPrompt` | string | no | New instructions for a reviewer. On the orchestrator it fails: "The orchestrator's built-in prompt can't be replaced. Pass instructions instead of systemPrompt." |
| `followTier` | string or null | no | `economy`, `balanced` or `frontier` keeps the member on that tier's newest model and moves it now if there is a better one; `null` pins it to its model. Changing the model without `followTier` also pins it. See [Follow the newest model](/docs/choosing-models#follow-the-newest-model) |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/panels/members/update" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"agentId":"...","reasoningEffort":"high"}'
```

```json
{ "ok": true, "applied": true, "member": { "_id": "...", "name": "...", "provider": "...", "modelId": "...", "reasoningEffort": "high" } }
```

Optional `name` renames the existing seat without changing its id or history. `instructions` adds to the orchestrator's protected prompt; `systemPrompt` replaces a reviewer's instructions. An empty string clears either. `pathScope` is a reviewer-only `{include: string[], exclude: string[]}` object, or `null` to clear it. Omitted fields stay unchanged.

Updates are atomic. Success returns `{ok: true, applied: true, member: {...}}` with the saved seat and any pricing warnings. A refused member edit returns `applied: false`, `fields` listing requested changes, and an actionable `error`; none of those changes committed. Correct the request and resubmit it.

### POST /panels/orchestrator

Sets the model that consolidates the reviews and posts to GitHub.

Scope: `panel:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `panelId` | string | yes | From `GET /panels` |
| `provider` | string | yes | From `GET /models` |
| `modelId` | string | yes | Exactly as `GET /models` reports it |
| `reasoningEffort` | string | no | `none`, `low`, `medium`, `high`, `xhigh` or `max` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/panels/orchestrator" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"panelId":"k17...","provider":"anthropic","modelId":"claude-sonnet-5-5"}'
```

```json
{ "agentId": "...", "member": { "_id": "...", "name": "...", "provider": "...", "modelId": "..." } }
```

### POST /panels/update

Renames a panel or sets its per-pull-request spending limit.

Scope: `panel:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `panelId` | string | yes | From `GET /panels` |
| `name` | string | no | The new name |
| `budgetUsd` | number or `null` | no | Per-PR limit in USD, positive; `null` turns it off. A panel that never set one uses the $5 default |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/panels/update" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"panelId":"k17...","budgetUsd":2.5}'
```

```json
{ "ok": true }
```

See [Budgets and spending limits](/docs/budgets-and-limits).

### GET /panels/recommend

Recommends reviewers and an orchestrator for a goal, priced for a round and a pull request. It changes nothing. How the goal maps to roles and tiers: [Ask for a panel by goal](/docs/reviewers#ask-for-a-panel-by-goal).

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `cost` | string | no | `low`, `medium` (default) or `high`. Picks the model tiers |
| `quality` | string | no | `low`, `medium` (default) or `high`. Picks the roles and reasoning effort |
| `repo` | string | no | `owner/name`. Recommends for that repository alone and prices it from its own recent rounds |
| `panelId` | string | no | Without `repo`: the panel to compare with and change. Defaults to your default panel |
| `roles` | string | no | Comma-separated role ids from `GET /roles`, instead of the goal's roles |
| `provider` | string | no | Keep every seat on this provider |
| `maxUsdPerPr` | number | no | Cut roles and tiers until the estimate fits this many dollars a pull request |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  "$CODEPANEL_URL/api/v1/panels/recommend?cost=low&quality=medium&repo=owner/name"
```

```json
{
  "goal": { "cost": "low", "quality": "medium" },
  "repo": "owner/name",
  "target": { "panelId": null, "scope": "repo", "note": "Applying gives owner/name its own panel; ..." },
  "reviewers": [{ "role": "bugs-security", "name": "Bugs & Security", "tier": "economy", "provider": "anthropic", "modelId": "claude-haiku-5-5", "model": "Haiku 5.5", "reasoningEffort": "medium", "source": "own_key", "usdPerRound": 0.0036, "reason": "Economy tier: ..." }],
  "orchestrator": { "tier": "balanced", "provider": "anthropic", "modelId": "claude-sonnet-5-5", "reasoningEffort": "medium", "usdPerRound": 0.0425, "reason": "..." },
  "estimate": { "usdPerRound": 0.057, "usdPerPr": 0.16, "roundsPerPr": 2.8, "basis": "typical", "sampleRounds": 0, "unpriced": [], "note": "..." },
  "budget": { "maxUsdPerPr": null, "fits": null, "changes": [] },
  "current": { "reviewers": [{ "name": "Bugs & Security", "provider": "anthropic", "modelId": "claude-haiku-5-5", "reasoningEffort": "medium" }], "orchestrator": { "...": "..." } },
  "unchanged": false,
  "nextAction": "apply"
}
```

| Field | Meaning |
| --- | --- |
| `reviewers`, `orchestrator` | Each seat's role, model, effort, `source` (`own_key`, or `credits` when no key of yours reaches the tier), `usdPerRound` (`null` when the model has no price) and `reason`, which cites what CodePanel's evals measured or says it is unmeasured |
| `estimate` | `basis` is `repo_history` (medians of the repository's last 30 rounds, with `sampleRounds`) or `typical` (production's median call sizes and 2.8 rounds a pull request). List prices without prompt-cache discounts, counting only calls that succeeded, so retries are not in it. Models in `unpriced` are left out of the totals |
| `budget` | With `maxUsdPerPr`: whether the plan `fits` and each cut made in `changes`. Bugs & Security is never cut. `fits` is `null`, and nothing is cut, when a seat's model has no known price |
| `target` | The panel apply would change: `scope` is `repo` (that repository's own panel; `panelId` is `null` when it has none yet), `default` or `panel` |
| `current`, `unchanged`, `nextAction` | The target's members now; `unchanged` is true, and `nextAction` `none`, when it already runs this setup. Otherwise `nextAction` is `apply` |

### POST /panels/apply

Applies `GET /panels/recommend` for the same fields. The recommendation is computed again, then the panel's reviewers are replaced and the orchestrator's model and effort set in one step. With `repo`, only that repository changes, and it gets its own panel if it has none. With `maxUsdPerPr`, that becomes the panel's per-PR limit, even when `budget.fits` is `false`: reviews then stop at the limit rather than run past it. Check `fits` before applying. When the panel already runs the setup, only that limit is written, and without `maxUsdPerPr` nothing is, so a repository with no panel of its own is not given one.

Scope: `panel:write`.

The body takes the same fields as `GET /panels/recommend`.

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/panels/apply" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"cost":"low","quality":"medium","repo":"owner/name"}'
```

```json
{
  "panelId": "k17...",
  "repo": "owner/name",
  "recommendation": { "...": "as GET /panels/recommend" },
  "undo": { "panelId": "k17...", "reviewerIds": ["..."], "orchestrator": { "provider": "anthropic", "modelId": "claude-sonnet-5-5", "reasoningEffort": "medium" }, "budgetUsd": "default" }
}
```

Keep `undo`: it is the panel as apply found it, and `POST /panels/restore` puts it back.

### POST /panels/restore

Puts a panel back as `POST /panels/apply` found it: its earlier reviewers, the orchestrator's model and effort, and the per-PR limit.

Scope: `panel:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `undo` | object | yes | Apply's `undo`. Its fields may also be passed at the top level |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/panels/restore" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"undo":{"panelId":"k17...","reviewerIds":["..."],"orchestrator":null,"budgetUsd":"default"}}'
```

```json
{ "ok": true }
```

`budgetUsd` is an amount, `null` for no limit, or `"default"` for the default limit.

### GET /keys

Provider key health, never the key.

Scope: `read`.

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/keys"
```

```json
[{ "provider": "anthropic", "name": "Anthropic", "configured": true, "status": "valid", "lastValidatedAt": 1760000000000, "lastError": null, "modelCount": 9, "consoleUrl": "https://platform.claude.com/settings/keys", "health": { "status": "rate_limited", "at": 1760000300000 }, "platform": null }]
```

`status` is `valid`, `invalid`, or `null` when no key is stored: what the key's last save or test found. `lastError` is redacted: anything resembling a key is masked, since some providers echo part of a rejected key.

`health` adds what real calls found since that test, from reviews and the model proxy: `status` is `valid`, `invalid`, `expired` or `rate_limited`, and `at` is when the call that set it failed (`null` when the test set it). A 401, or a 400 or 403 that names the API key, is `invalid`, or `expired` when the provider says so; a 429 or a quota is `rate_limited`. `invalid` and `expired` hold until the key is saved or re-tested; `rate_limited` shows for an hour after the last one. Only the class and the time are stored, never the provider's text. `health` is `null` when no key is stored.

`platform` is the same for CodePanel's own key for that provider, which calls on credits use: class and time only, for an hour after a rate limit or a day after a refusal, else `null`. A person cannot fix it; it explains why calls on credits fail or wait while calls on your own key do not.

A stored key also turns `invalid` on its own when a panel member on it fails two rounds in a row because the account is out of credit or the key was revoked (HTTP 401 or 402, or a provider's out-of-credit message). `lastError` then starts `Turned off after reviews failed with:` and quotes the provider. Until the key is saved again or re-tested in Settings, rounds skip its members instead of paying for calls that fail the same way, and the review comment lists each one as `skipped`. A person has to fix this at the provider's console (`consoleUrl`); an agent cannot.

## Knowledge and learnings

A repository's knowledge is everything reviewers are told about it beyond the diff, as one Markdown document: its review rules, notes, your account-wide rules, the verdicts on past findings and its learnings. See [Repo context and custom rules](/docs/repo-context).

### GET /knowledge

The knowledge document, and the same data structured.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/knowledge?repo=acme/api"
```

```json
{ "repo": "acme/api", "markdown": "...", "rules": [], "accountRules": [], "notes": [], "verdicts": [], "learnings": [] }
```

### POST /knowledge

Replaces the repository's rules and notes with the `## Rules` and `## Notes` sections of an edited document.

Scope: `repos:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `markdown` | string | yes | The whole document `GET /knowledge` returned, edited |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/knowledge" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d "$(jq -n --arg md "$(cat knowledge.md)" '{repo:"acme/api",markdown:$md}')"
```

```json
{ "rules": { "added": 1, "updated": 2, "removed": 0 }, "notes": { "added": 0, "updated": 0, "removed": 1 } }
```

- Each `###` heading in those two sections is one entry. Anything left out of them is removed. A rule heading ending in `(disabled)` is kept but not used.
- Other sections (account rules, verdicts, learnings) are ignored. Change a verdict by re-rating the finding; change learnings with the endpoints below.
- A document that does not parse, or one read before the knowledge last changed, gets `400` with the reason and changes nothing. Read it again and redo the edit.
- Rules committed in `.codepanel/rules.md` are edited in the repository, not here.

### GET /learnings

The repository's learnings, highest ref first.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/learnings?repo=acme/api"
```

```json
[{
  "ref": "L3", "number": 3, "text": "In convex/reviews/, renew() extends the lease before any write",
  "scope": "convex/reviews/", "prNumber": 87, "source": "api", "createdAt": 1760000000000,
  "state": { "status": "candidate", "needs": "..." }
}]
```

| Field | Meaning |
| --- | --- |
| `scope` | A path prefix; empty for the whole repository |
| `source` | `comment`, `api`, `dashboard`, or `drafted` (written by the orchestrator from repeated false positives) |
| `state.status` | `active` (with `activatedAt` and `by`: `person`, `agents`, `evidence` or `disputes`), `candidate` (`needs` says what would confirm it), `off` (with `by`: `person` or `agent`, and `reason`, `prNumber` when given) or `expired` (no up for 180 days; `lastConfirmedAt`) |
| `drafted` | On a drafted learning: `at`, `model` and `evidence` (each `label`, `prNumber`, `ref`, `file`, `note`, `by`) |
| `conceded` | Evidence rows, shaped like `drafted.evidence`, for the false-positive disputes the orchestrator conceded that cite this learning's ref. With the repository's `disputeLearnings` convergence switch on, three pull requests of them activate a candidate (`state.by` `disputes`) |

See [Repo context](/docs/repo-context) for how learnings activate.

### POST /learnings

Records a learning: one short fact that would stop reviewers repeating a wrong finding. Same as a `/remember` comment.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `text` | string | yes | One paragraph, at most 500 characters |
| `scope` | string | no | A path prefix it holds under, such as `convex/reviews/`, at most 200 characters |
| `pr` | integer | no | The pull request it came from. An agent's learning without one never counts toward activation |
| `agent` | string | no | Your agent's name, such as `claude-code`. Defaults to `api` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/learnings" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","text":"In convex/reviews/, renew() extends the lease before any write","scope":"convex/reviews/","pr":87,"agent":"claude-code"}'
```

```json
{ "ref": "L3", "number": 3 }
```

A token call always counts as an agent's. Its learning is a candidate until a person confirms it, or another identity does on another pull request, and it never applies to the pull request it came from.

### POST /learnings/feedback

Confirms (`up`) or turns off (`down`) a learning. Any `down` turns it off at once. Same as `/feedback L3 up|down`.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `ref` | string | yes | The learning, such as `L3` |
| `rating` | string | yes | `up` or `down`. Never implied by `reason`: one `down` turns a learning off |
| `reason` | string | no | As for [`POST /feedback`](#post-feedback) |
| `note` | string | no | What in the code supports or contradicts it |
| `pr` | integer | no | The pull request you are working on. An agent's up without one never counts toward activation |
| `agent` | string | no | Your agent's name. Defaults to `api` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/learnings/feedback" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","ref":"L3","rating":"down","reason":"false_positive","note":"renew() is called after the write in lease.ts"}'
```

```json
{ "target": "L3", "outcome": "created" }
```

`outcome` is `updated` when you rated it before. An unknown ref is a `404` `not_found`: "Learning L9 not found; refs look like L3".

## Agent presence

Agents working in the same repository from one account can see each other before their pull requests collide. Each agent session sends a heartbeat with its branch and the files it changes; every heartbeat answers with the other sessions live in that repository and the files both change. A session is live for 10 minutes after its last heartbeat. The local MCP server sends one from git every minute on its own (see [MCP server](/docs/mcp-server#work-beside-other-agents)); any other client can call `POST /presence` itself.

Both routes answer with the same view:

- `peers`: the other live sessions, newest first, each with `id`, `agent`, `branch`, `headSha`, `worktree` (the folder name only), `intent`, `fileCount`, `startedAt`, `lastSeenAt` and `secondsSinceSeen`.
- `overlaps`: one per peer that changes a file you change, with `with` (the peer's `id`), `agent`, `branch`, `kind` (`both_editing`), `fileCount` and up to 20 `files`.
- `you`: your own session (with its `sessionKey`), when the request names it. A session is one key in one repository.
- `nextAction`: `coordinate` when there is an overlap (read the other branch or pull request before editing those files further, or split the work), else `continue`; `note` says why.

Old sessions are deleted a day after their last heartbeat, and a repository's sessions when it is disconnected. Only file paths are stored, never file contents. Paths over 300 characters are dropped and set `filesTruncated`.

### POST /presence

Records a heartbeat for one session. Fields left out keep their last value, so a heartbeat can carry only `files` and an intent stays set. Over 200 files, the first 200 are kept and the session is flagged `filesTruncated`.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `sessionKey` | string | yes | Your session, 1 to 80 characters, chosen by you and kept for the session |
| `agent` | string | no | Your name; defaults to the client's name |
| `branch`, `headSha`, `worktree` | string | no | Where you work. Send the worktree's folder name, not its path |
| `files` | string[] | no | Repository-relative paths you change against the default branch |
| `intent` | string | no | One line on what you are doing, at most 300 characters |

```bash
curl -sS -X POST -H "Authorization: Bearer $CODEPANEL_TOKEN" -H "Content-Type: application/json" \
  -d '{"repo":"acme/app","sessionKey":"s-41f2","branch":"fix-billing","files":["convex/billing/gate.ts"]}' \
  "$CODEPANEL_URL/api/v1/presence"
```

### GET /presence

The repository's live sessions. With `sessionKey`, `overlaps` are computed for that session.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `sessionKey` | string | no | Your session, to get `you` and `overlaps` |
| `filesPerPeer` | number | no | List up to this many (at most 50) of each peer's files |

## Tracked plans

A tracked plan is a plan an agent saves and works through over many sessions: numbered steps (`S1`, `S2`, ... for the plan's life), sub-plans that expand a step, and a history of every change. Every write returns the whole plan, so the agent reads its `nextAction` without another call. Plan tracking is on only where the deployment sets `PLAN_TRACKING=on`; elsewhere every route answers `400`.

The rules keep a plan honest without blocking work. Each departure needs a reason, and the reason is kept in `history`:

- Marking a step `blocked` or `skipped` needs a `reason`.
- Starting a step while another is in progress, or starting or finishing one before an earlier step that is still open, is a deviation. It needs a `reason`, and it is recorded as a `deviation` event whose `detail` says which step it went ahead of.
- Reopening a `done` or `skipped` step needs a `reason`.
- `done` needs `evidence` (a pull request, commit or test run) when the step has `acceptance` criteria. A step with an active sub-plan keeps its status until the sub-plan completes or is abandoned (block a step inside the sub-plan instead). A `done` or `skipped` step cannot get a new sub-plan, or have one made active again.
- A plan becomes `completed` by itself once every step is `done` or `skipped`. It becomes `active` again when a step is reopened or added.

`nextAction` always has `action`, `planId`, `step`, `steps` and `reason`. `action` is `start` or `continue` (with `step`), `unblock` (with `steps`, when the first open step is blocked), `add_steps` or `done`. When the step in progress has an active sub-plan, `nextAction` leads into that sub-plan.

The dashboard's **Plans** page shows the same plans, steps, `nextAction` and history to a person, and appears once you have a plan. Its one override is to abandon a plan (with its active sub-plans) or make an abandoned one active again; the history records that change with the agent `owner (dashboard)`, and the agent reads it in its next `nextAction`.

### GET /plans

Your plans, most recently changed first: `planId`, `title`, `status`, `repo`, `parentPlanId`, `parentStep` and `progress` (`total`, `done`, `skipped`, `inProgress`, `blocked`, `pending`).

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | no | `owner/name`: only plans for that repository |
| `status` | string | no | `active`, `completed` or `abandoned` |
| `includeSubplans` | boolean | no | Include sub-plans; top-level plans only by default |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/plans?status=active"
```

### GET /plans/get

One plan: its summary plus `goal`, `steps` (each with `ref`, `title`, `detail`, `acceptance`, `status`, `reason`, `evidence` and the `subplans` that expand it), `history` (the latest 50 changes, newest first, each with a stable `id`) and `nextAction`. Someone else's plan is `404`.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `planId` | string | yes | From `GET /plans` or `POST /plans` |

```json
{
  "planId": "k57...", "title": "Plan tracking", "status": "active",
  "nextAction": { "action": "start", "step": "S2", "planId": "k57...", "reason": "it is the next pending step" },
  "steps": [{ "ref": "S1", "title": "Schema", "status": "done", "evidence": "PR #412", "subplans": [] }]
}
```

### POST /plans

Saves a plan. With `parentPlanId` and `parentStep` it is a sub-plan that expands that step of the parent; one is refused without the other. Plans nest at most 5 deep; a plan holds at most 200 steps and 50 sub-plans. A request body is at most 1 MiB: send a long plan in parts with `POST /plans/steps`.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string | yes | At most 200 characters |
| `goal` | string | no | What the plan achieves and why |
| `repo` | string | no | `owner/name`. A sub-plan inherits its parent's |
| `parentPlanId` | string | no | The plan this one belongs to; it must be active |
| `parentStep` | string | with `parentPlanId` | The parent's step this plan expands, like `S2` |
| `steps` | array | no | `{ "title", "detail", "acceptance" }` in order |
| `agent` | string | no | Your agent's name, kept in the history |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/plans" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"title":"Plan tracking","repo":"acme/api","steps":[{"title":"Schema"},{"title":"API","acceptance":"routes tested"}],"agent":"claude-code"}'
```

### POST /plans/steps

Adds steps after a named step, or at the end. New steps get new numbers; existing refs never change.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `planId` | string | yes | |
| `steps` | array | yes | `{ "title", "detail", "acceptance" }` |
| `after` | string | no | Insert after this step, like `S1` |
| `reason` | string | no | Why the plan changed |
| `agent` | string | no | |

### POST /plans/step

Moves a step to a new status, records evidence, or edits its text. An abandoned plan refuses changes until it is active again.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `planId` | string | yes | |
| `step` | string | yes | Like `S3` |
| `status` | string | no | `pending`, `in_progress`, `done`, `blocked` or `skipped` |
| `reason` | string | no | Required by the rules above |
| `evidence` | string | no | What shows the step is done |
| `title`, `detail`, `acceptance` | string | no | Edit the step |
| `agent` | string | no | |

A change the rules refuse gets `400` with what to pass, and changes nothing.

### POST /plans/update

Edits a plan's `title` or `goal`, or sets `status`: `abandoned` (needs a `reason`; its active sub-plans are abandoned with it) or `active` again. An abandoned plan takes edits only in the call that makes it active. A sub-plan comes back only under an active parent, and a parent comes back without its sub-plans: make each active again that you still want. `completed` is never set by hand.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `planId` | string | yes | |
| `title`, `goal` | string | no | |
| `status` | string | no | `active` or `abandoned` |
| `reason` | string | no | |
| `agent` | string | no | |

## Reviews, sessions and findings

### POST /reviews/trigger

Starts a review of a pull request now, with the same pre-flight as the dashboard's **Start** button.

Scope: `reviews:write`. Limited to 20 per hour per token.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `pr` | integer | yes | Pull request number |
| `panelId` | string | no | Defaults to the repository's pinned panel, else your default |
| `traceparent` | string | no | Your [W3C traceparent](https://www.w3.org/TR/trace-context/#traceparent-header), if you trace your own work. A `traceparent` request header works too; the field wins. A malformed field is a `400`; a malformed header is ignored |

```bash tab="curl"
curl -sS -X POST "$CODEPANEL_URL/api/v1/reviews/trigger" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"repo":"acme/api","pr":123}'
```

```bash tab="CLI"
codepanel review acme/api#123 --trigger
```

```text tab="MCP"
trigger_review { "repo": "acme/api", "pr": 123 }
```

```json
{ "scheduled": true, "queued": false, "queuedBehind": null, "knownHeadSha": "abc123...", "lastReviewedSha": "9f8e..." }
```

| Field | Meaning |
| --- | --- |
| `scheduled` | The review runs in the background. Wait with `GET /reviews/status`, then read `GET /review` |
| `queued` | `true` when another run holds the pull request: this one starts when that ends, at the head as it is then |
| `queuedBehind` | What it waits for: `review` (a round, usually minutes) or `dispute` (the orchestrator answering disputes, usually under a minute). `null` when not queued |
| `knownHeadSha` | The head CodePanel last saw from GitHub (`null` before it has seen the pull request). A push it has not heard of yet may have moved it; the round reads the real head when it starts |
| `lastReviewedSha` | The commit the last completed review read |

The session id is not known yet; `GET /reviews/status` has it once the round starts. The review runs on your provider keys, or on CodePanel credits for providers you have no key for. With no panel, one is built from your keys, or on CodePanel's with credits ([Billing](/docs/billing)).

Errors: `400` "GitHub token not configured. Reconnect GitHub and try again." when GitHub is not connected; `400` `precondition` with `reason: "provider_key_missing"` (or `credits_required` when credits would cover the provider) when no panel can run.

A `traceparent` is stored on the round this call starts and returned by `GET /review` while that round is the latest, so you can join the review to your own trace. Rounds started by a push, or a trigger queued behind a running round, carry none. CodePanel sends it nowhere else. The CLI sends `$TRACEPARENT` when set; the local MCP server reads it once at startup, so in a long session pass `traceparent` to `trigger_review`.

### GET /review-brief

The brief your agent runs on its own model to review its change before it pushes. CodePanel calls no model to build it, so it is free: it needs no plan, counts toward none, and starts no review. The pull request still gets the full panel review.

| Parameter | Type | Required | Meaning |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name`, a repository you connected |
| `paths` | string | no | The files the change touches, comma-separated, repository-relative. At most 200 are used; `./` and leading slashes are stripped and paths with `..` are refused. Without it, every active learning is included |

```bash
curl -sS "$CODEPANEL_URL/api/v1/review-brief?repo=acme/api&paths=src/auth.ts,src/db.ts" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN"
```

| Field | Meaning |
| --- | --- |
| `text` | The brief as Markdown, to hand a fresh-context subagent |
| `seats` | Each panel seat: `name`, `prompt` (its full reviewer prompt, or `null` for none of its own), `uiOnly` |
| `gateLevel` | `off`, `critical`, `warning_high`, `warning` or `all`: what blocks the merge |
| `learnings` | Active learnings for the paths (`ref`, `scope`, `text`), narrower scope first, then newest |
| `droppedLearnings` | Learnings left out for length, lowest ranked first |
| `paths` | `used`, `dropped` (past 200), `refused`, `max` |
| `chars` | The length of `text` |

The brief aims at about 8,000 tokens. Every seat's prompt is served whole, so a large panel of long prompts can pass that; only learnings are dropped to fit. Rules, learnings and prompts are data for the agent to apply, and the brief says so. `.codepanel/rules.md` is read from the base branch when the panel reviews and is not stored, so the brief names it for the agent to read in its checkout; `codepanel review --local` adds it.

### POST /reviews/local

Optional. After your agent ran the brief and pushed, send what it found. It is stored against the commit you name, and shown as your claim, not checked by CodePanel: `payload.localReview` on [`GET /review`](#get-review) and one line on the review comment of that commit. The gate and the panel's reviewers never read it. Free: it starts no review and counts toward no plan.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name`, a repository you connected |
| `headSha` | string | yes | The full sha (40 hex characters) of the commit you reviewed |
| `findings` | array | yes | Each `file`, `severity` (`critical`, `warning`, `suggestion`), `message`, `fixed` (true or false) and optional `line`. At most 200 are accepted; the 50 most severe are kept |
| `pr` | integer | no | The pull request, when it is open; `atHead` then says whether the commit is its head as CodePanel last saw it |
| `verdict` | string | no | Your own call: `ready` or `not-ready` |
| `agent` | string | no | Your agent's name, such as `claude-code` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/reviews/local" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","pr":123,"headSha":"<40 hex>","verdict":"ready","findings":[{"file":"src/auth.ts","line":12,"severity":"warning","message":"Retry never gives up","fixed":true}]}'
```

```json
{ "ok": true, "headSha": "4be1c0d...", "atHead": false, "counts": { "critical": 0, "warning": 1, "suggestion": 0 }, "total": 1, "fixed": 1, "dropped": 0, "edited": 0, "shownOn": "..." }
```

Messages are cleaned like model text: put on one line, hidden text taken out, and cut to 500 characters with a ` [cut]` mark; `edited` counts the findings changed that way, and `dropped` the ones past 50. `atHead` is often `false`, since you review before you push; the payload and the comment pick the local review of the commit they show. Submitting again for the same commit replaces it. A repository keeps the local reviews of its 200 most recently submitted commits.

### POST /reviews/handoff

Leaves the author agent's note for the next review round: what it changed, tested, is unsure of and left out on purpose. Reviewers read it as a claim to check against the code, never as evidence or instructions. Format and use: [Agent setup](/docs/agent-setup).

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name`, a repository you connected |
| `pr` | integer | yes | Pull request number |
| `text` | string | yes | The handoff, up to 12,000 characters. Reviews use the first 6,000 |
| `sha` | string | no | The commit it describes; defaults to the head CodePanel last saw. When the pull request has moved past it, reviewers are told the note may describe an earlier version |
| `agent` | string | no | Your agent's name, such as `claude-code` |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/reviews/handoff" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","pr":123,"text":"Changed: ... Tested: ... Unsure: ... Left out: ...","agent":"claude-code"}'
```

```json
{ "ok": true, "chars": 412, "truncated": false, "headSha": "abc123...", "usedBy": "the next review round of this pull request, unless its description has a codepanel-handoff block" }
```

A new handoff replaces the last one. A `codepanel-handoff` block in the pull request's description takes precedence. `usedBy` says which round will read it, or that none will because CodePanel has handoffs off.

### POST /reviews/rounds

Sets how many automatic rounds a pull request gets, as a `/rounds` comment does (see [Triggering reviews](/docs/triggering-reviews)).

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `pr` | integer | yes | Pull request number |
| `rounds` | string or number | yes | `3` (3 automatic rounds in all, 1 to 50), `+N` (at least N more after the current one, such as `+1`), `stop` (none after the current one) or `reset` (back to the repository's setting) |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/reviews/rounds" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"repo":"acme/api","pr":123,"rounds":"+1"}'
```

```json
{ "limit": 4, "completed": 3, "running": false, "reviewQueued": true }
```

`limit` is the limit that now applies (`null` for none), `completed` the rounds done, `running` whether one is running, and `reviewQueued` whether raising the limit queued a review of a head the old limit skipped (it runs only if that head has not been reviewed). The token acts as the repository's owner, so it may raise the limit past the bot ceiling. A bad value: "rounds must be a number from 1 to 50, +N, stop or reset".

### GET /review

The review of a pull request: where it stands, the gate, the open findings, and `payload`, the same review as versioned data with a verdict and the next action. Same shape as the CI endpoint `GET /api/review` ([Merge gate](/docs/merge-gate)).

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `pr` | integer | yes | Pull request number |

```bash tab="curl"
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/review?repo=acme/api&pr=123"
```

```bash tab="CLI"
codepanel review acme/api#123 --json
```

```text tab="MCP"
get_review { "repo": "acme/api", "pr": 123 }
```

```json
{
  "found": true, "status": "complete", "round": 2,
  "headSha": "4be1c0d...", "lastReviewedSha": "4be1c0d...", "reviewCommentId": 2214567890,
  "rounds": { "completed": 2, "limit": 5, "perPr": false, "running": false, "limitReached": false },
  "open": { "critical": 0, "warning": 1, "suggestion": 2 },
  "gate": { "level": "warning", "blocking": true, "unanswered": ["F3"], "status": "posted" },
  "findings": ["..."],
  "payload": {
    "schemaVersion": 1, "round": 2, "reviewedSha": "4be1c0d...", "prHeadSha": "4be1c0d...", "inProgress": false,
    "nextAction": { "action": "fix", "refs": ["F3"], "reason": "..." },
    "verdict": "blocked", "blockedBy": ["F3"], "verdictReason": null, "nextRound": "will-run-on-push",
    "counts": { "open": 3, "critical": 0, "warning": 1, "suggestion": 2 },
    "findings": ["..."], "disputes": [], "suppressed": [],
    "pullRequest": { "state": "open", "closedAt": null, "mergedAt": null, "mergeCommitSha": null, "mergedBy": null, "openAtClose": null },
    "authorModel": null, "handoff": null, "authorProof": null, "linkedIssues": [], "ci": null, "headSha": "4be1c0d..."
  }
}
```

Read `payload.nextAction` first: it weighs the gate, the verdict, any running round and which commit was reviewed. When `gate.level` is not `off`, the pull request is done when `gate.blocking` is false; with the gate off, follow `payload.verdict`. Every field is in [Review payload](#review-payload).

### GET /reviews/status

The pull request's latest review session. Cheap to poll. `wait_for_review` and `codepanel review --wait` poll it for you.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `pr` | integer | yes | Pull request number |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/reviews/status?repo=acme/api&pr=123"
```

```json
{
  "found": true, "sessionId": "k97...", "status": "reviewing", "finished": false, "outcome": null,
  "headSha": "4be1c0d...", "lastReviewedSha": "9f8e...", "sessionHeadSha": "4be1c0d...",
  "activity": "...", "error": null, "errorCode": null, "nextAction": null,
  "publishError": null, "prState": "open"
}
```

| Field | Meaning |
| --- | --- |
| `found` | False until a round has started |
| `sessionId`, `status` | The latest session: `initializing`, `reviewing`, `synthesizing`, `ready`, `chatting`, `archived` or `failed` |
| `finished`, `outcome` | Whether the round is over, and `completed` or `failed` (`null` while running) |
| `headSha` | The pull request's current head |
| `lastReviewedSha` | The commit the last completed review read. Compare it with the commit you pushed |
| `sessionHeadSha` | The head this session fetched to review; `null` until it has |
| `activity` | What the round is doing now |
| `error`, `publishError` | Why it failed, or why posting failed; redacted |
| `errorCode`, `nextAction` | For a refused round, a stable reason (`plan_required`, `plan_limit`, `credits_required`, `credits_exhausted`, `provider_key_missing`, `provider_key_invalid`) and the one thing to do about it ([Billing](/docs/billing)). `null` otherwise. Not the same as `payload.nextAction` |
| `prState` | `open`, `merged` or `closed`; `null` when CodePanel has no record of the pull request |
| `refused` | The head CodePanel refused to review for a budget, cap, credits, plan or key reason: `sha`, `reason` (a refusal code, or `refused` for a budget or cap) and `nextAction` (review it locally and carry on). Set even before the first round, when `found` is false. `null` otherwise; absent from older servers |

A new push starts a new session, which becomes the latest.

### GET /sessions

Recent review sessions you created, newest first.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | no | `owner/name` |
| `status` | string | no | `active` (`initializing`, `reviewing`, `synthesizing` or `chatting`), `completed` (any other status) or `all` (default) |
| `limit` | integer | no | Default 20; over 100 is treated as 100 |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/sessions?repo=acme/api&status=active"
```

```json
[{
  "id": "k97...", "status": "ready", "repo": "acme/api", "prNumber": 123, "prTitle": "Add rate limiting",
  "activity": null, "error": null, "errorCode": null, "nextAction": null, "publishError": null,
  "createdAt": 1760000000000, "completedAt": 1760000240000
}]
```

Sessions come from your 500 most recent. `error` and `publishError` are redacted.

### GET /sessions/get

One session you created or took part in, with each panel member's status.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | A session id |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/sessions/get?id=k97..."
```

```json
{
  "id": "k97...", "status": "ready", "repo": "acme/api", "prNumber": 123, "prTitle": "Add rate limiting",
  "activity": null, "error": null, "errorCode": null, "nextAction": null, "publishError": null,
  "createdAt": 1760000000000, "completedAt": 1760000240000,
  "agents": [{ "name": "Bugs & Security", "status": "complete", "error": null }]
}
```

Each `agents[].status` is `pending`, `thinking`, `typing`, `complete`, `error` or `skipped` (a Design & UX reviewer on a round that changed no UI).

### GET /findings

Findings on a pull request, in the [shared projection](#finding-fields).

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `pr` | integer | yes | Pull request number |
| `includeResolved` | boolean | no | `true` to include resolved and dismissed findings. Default `false` |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/findings?repo=acme/api&pr=123"
```

```json
{ "found": true, "findings": [{
  "id": "k17...", "ref": "F3", "severity": "critical", "file": "src/auth.ts", "line": 42,
  "message": "...", "suggestion": null, "reviewers": ["Bugs & Security"], "source": "reviewers",
  "firstSeenRound": 1, "lastSeenRound": 2, "state": "open", "answered": false, "rated": false,
  "dispute": null, "dismissReason": null,
  "status": "persisting", "dismissed": false, "agentNames": ["Bugs & Security"]
}] }
```

Adds `dismissReason`, and `heldBackAtRound` on a suggestion a later round [held back](/docs/triggering-reviews#suggestions-after-round-1). `status` (`new`, `persisting` or `resolved`), `dismissed` and `agentNames` are deprecated: `state` and `reviewers` say the same.

### POST /findings/dismiss

Says a finding is wrong. From the owner it closes the finding; with `agent` set it disputes it instead.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `findingId` | string | one of | From `GET /review` or `GET /findings` |
| `repo`, `pr`, `ref` | string, integer, string | one of | Instead of `findingId`: the finding as the review names it, such as `F3`. `review` is a `400` |
| `reason` | string | no | `false_positive`, `wrong_location`, `not_worth_fixing`, `duplicate`, `deferred` or `other`. Hyphens and `/feedback` synonyms work (`false-positive`, `fp`). `deferred` means real, but handled outside this pull request |
| `agent` | string | no | The agent dismissing, such as `claude-code` |
| `note` | string | no | With `agent`: why the finding is wrong, for the orchestrator to check |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/findings/dismiss" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","pr":123,"ref":"F3","reason":"false_positive","agent":"claude-code","note":"The caller checks ownership in middleware.ts"}'
```

```json
{ "ok": true, "dispute": { "status": "pending" } }
```

- Without `agent`: the repository owner's dismissal. It closes the finding, keeps it closed if a later round reports it again, and returns `{"ok": true}`.
- With `agent`: it [disputes](/docs/feedback) the finding, as an agent's down rating does (`reason` defaults to `false_positive`). With `deferred` it closes the finding instead.
- Do not dismiss findings you fixed: the next review closes them.

### POST /findings/reopen

Reopens a dismissed finding, including one in the payload's `suppressed`. It comes back open with its dispute cleared; the next round that re-examines it closes it if it was fixed.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `findingId` | string | one of | From `GET /review` or `GET /findings` |
| `repo`, `pr`, `ref` | string, integer, string | one of | Instead of `findingId`, such as `F3`. Ignored when `findingId` is given |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/findings/reopen" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" -d '{"repo":"acme/api","pr":123,"ref":"F3"}'
```

```json
{ "id": "k17...", "ref": "F3", "reopened": true, "status": "persisting" }
```

`reopened` is `false`, and nothing changes, when the finding was not dismissed. An unknown finding is `404`; `ref: "review"` is `400`.

### POST /agent-feedback

Tells the CodePanel team what got in the way of an agent using CodePanel's tools, API or docs: an error that did not say how to fix the call, a parameter it had to guess, several tries for one thing. Send one report after the task, not one per error. It is not for rating a review; that is `POST /feedback`. The MCP tool is [`send_feedback_to_codepanel`](/docs/mcp-server/send_feedback_to_codepanel).

Scope: any token, `read` included. At most 10 reports an hour per account.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string | yes | What you tried, what you called and what got in the way; at most 4,000 characters |
| `tool` | string | no | The tool or route most involved, such as `trigger_review` |
| `outcome` | string | no | `gave_up`, `worked_around` or `succeeded` |
| `agent` | string | no | Your name; the client's own name, when it sends one, wins |

```json
{ "id": "wd7...", "received": true, "note": "Thanks. The CodePanel team reads every report. Carry on with your task; there is no reply to wait for." }
```

### POST /feedback

Rates a finding or the whole review, one or many. A rating never closes a finding; an agent's verdict that it is wrong disputes it. Rating semantics: [Feedback](/docs/feedback).

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `findingId` | string | one of | A finding id |
| `repo`, `pr`, `ref` | string, integer, string | one of | `ref` is `F3`, `3`, or `review` for the whole review; `finding` is read as `ref` |
| `rating` | string | unless `reason` implies it | `up` or `down` (also `+1`, `-1` and similar). Left out, `fixed`, `useful` and `deferred` mean `up`, and `false_positive`, `wrong_location`, `not_worth_fixing`, `duplicate` and `unclear` mean `down` |
| `reason` | string | no | `fixed`, `useful`, `false_positive`, `wrong_location`, `not_worth_fixing`, `duplicate`, `deferred`, `unclear` or `other`. Hyphens, spaces and `/feedback` synonyms work (`false-positive`, `false positive`, `fp`, `nit`, `later`). An explanation goes in `note`, not here. `fixed` and the verdict reasons answer the finding for the [merge gate](/docs/merge-gate) |
| `note` | string | no | A sentence on why. Cut to 1,000 characters; over 4,000 is a `400` |
| `agent` | string | no | The harness rating, such as `claude-code`. Lowercased, dots to dashes, cut to 64 characters. A Claude model id (`claude-opus-5-5`) or `claude` is stored as `claude-code`, with the model id kept as `agentModel` |
| `ratings` | array | no | Up to 50 items instead of `ref` and `rating`; see below |

```bash tab="curl"
curl -sS -X POST "$CODEPANEL_URL/api/v1/feedback" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","pr":123,"ref":"F3","rating":"up","reason":"fixed","note":"Added the ownership check","agent":"claude-code"}'
```

```bash tab="CLI"
codepanel feedback acme/api#123 F3 up --reason fixed --note "Added the ownership check" --agent claude-code
```

```text tab="MCP"
rate_finding { "repo": "acme/api", "pr": 123, "ref": "F3", "rating": "up", "reason": "fixed", "note": "Added the ownership check" }
```

```json
{ "target": "F3", "rating": "up", "outcome": "created" }
```

- `outcome` is `updated` when you rated the same target before; the new rating replaces the old.
- `rating` is the one recorded, implied by `reason` when the call gave none.
- Without `findingId` or all of `repo`, `pr` and `ref`: `invalid_input`, "give findingId, or repo, pr and ref (a finding like F3)". Without `rating` or a `reason` that implies one: `invalid_input`, "rating is missing: …".
- With `agent` set, a `down` with `false_positive`, `wrong_location`, `not_worth_fixing` or `duplicate` disputes the finding, and the response adds `"dispute": {"status": "pending"}`. When the finding was already decided at its current commit, `status` is that outcome and `reason` the orchestrator's; for a closed finding it is `closed`. Without `agent`, a rating never closes or disputes anything.
- The rating appears in the review comment's **Ratings** section within about a minute (or with the next round). The note is posted too, with anything that looks like a credential masked, so on a public repository it is public. Withdrawing a rating removes its line. A `/feedback` reply is recorded apart from an API rating, so repeating one as a reply keeps both.

**Many at once.** Send `ratings`, an array of up to 50 items, each with `ref` (or `finding`, or `findingId`), `rating` (left out when `reason` implies it), `reason` and `note`. `repo`, `pr` and `agent` at the top apply to every item that leaves them out. Each item is recorded on its own:

```json
{"failed": 1, "results": [
  {"ref": "F1", "ok": true, "target": "F1", "rating": "up", "outcome": "created"},
  {"ref": "F9", "ok": false, "error": "Finding F9 not found on this pull request", "code": "not_found"}
]}
```

### POST /reviews/ask

Asks the orchestrator about the review or a finding and waits up to 25 seconds for the answer. Same as a `/ask` reply, without the posted comment. Never starts a review.

Scope: `reviews:write`. 10 questions per hour per pull request.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `pr` | integer | yes | Pull request number |
| `question` | string | yes | At most 2,000 characters |
| `ref` | string | no | The finding asked about, such as `F3` |
| `agent` | string | no | The agent asking |
| `wait` | boolean | no | `false` returns at once instead of waiting |

```bash
curl -sS -X POST "$CODEPANEL_URL/api/v1/reviews/ask" \
  -H "Authorization: Bearer $CODEPANEL_TOKEN" \
  -d '{"repo":"acme/api","pr":123,"ref":"F3","question":"Which caller can pass an unowned id here?","agent":"claude-code"}'
```

```json
{ "id": "kq3...", "status": "answered", "question": "...", "ref": "F3", "answer": "...", "concedes": false, "error": null, "model": "anthropic/claude-sonnet-5-5", "createdAt": 1760000000000, "answeredAt": 1760000012000 }
```

| Field | Meaning |
| --- | --- |
| `status` | `pending` (read it later with `GET /reviews/ask`), `answered` or `failed` |
| `concedes` | True when the answer conceded the finding was wrong, and it was withdrawn |
| `error` | Why it was not answered, such as a budget limit, no key for the orchestrator's provider, or not enough credits |

Each question counts toward the monthly budget (and the repository's cap) like chat. Past 10 an hour: `429`. A pull request with no review yet, or an unknown `ref`: `400`.

### GET /reviews/ask

Reads a question and its answer. Use it to keep waiting on a `pending` one; it asks nothing new.

Scope: `read`.

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

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/reviews/ask?id=kq3..."
```

Returns the question, as above. An unknown id: `404` "Question not found".

## Review payload

What [`GET /review`](#get-review), the MCP tool `get_review` and the CI endpoint `GET /api/review` return.

### Snapshot fields

| Field | Meaning |
| --- | --- |
| `found` | False when CodePanel has no record of the pull request; then `payload` is absent |
| `status` | `pending`, `reviewing`, `complete` or `failed` |
| `failure` | When `status` is `failed`: `error`, and for a refusal `code` (`plan_required`, `plan_limit`, `credits_required`, ...) and `nextAction` |
| `round` | The latest round number |
| `headSha` | The pull request's current head. For the commit the review is about, read `payload.reviewedSha` |
| `lastReviewedSha` | The commit the last completed review read |
| `reviewCommentId` | The GitHub id of the posted review comment |
| `rounds` | Where the pull request stands against its automatic round limit: `completed`, `limit` (absent for none), `perPr` (set with `/rounds`), `running`, `limitReached`, and `capped`: the head is a commit no round reviewed, the limit kept it from review and no round is running, so no review is coming and its `CodePanel` status passes on the answers already given |
| `open` | Open findings by severity: `critical`, `warning`, `suggestion` |
| `gate` | `level` (`off`, `critical`, `warning_high`, `warning` or `all`), `blocking`, `unanswered` (the refs still blocking, most severe first) and `status` (`posted`, `missing_permission` or `refused`; absent until a status was posted). Anything but `posted` means the pull request carries no `CodePanel` status, so `blocking` is the only gate. A passing status does not imply coverage: when `verdict` is `needs-review` because no file was read, the status still follows the findings alone |
| `findings` | Deprecated copy of `payload.findings` with fewer fields: `id`, `ref`, `severity`, `file`, `line`, `message`, `suggestion`, `status`, `answered`, `state`, `agentNames`, `source`. Empty `ref`, `line` and `suggestion` are left out |
| `traceparent` | The one the latest round was triggered with, when there was one |
| `startedBy` | `reconciler` when the latest round was started by CodePanel's own check because the webhook that should have started it never arrived ([Merge gate](/docs/merge-gate#status-behaviour)); absent otherwise |
| `payload` | The review as versioned data, below |

### Payload fields

The verdict and the gate can differ: the verdict counts every open critical and warning, while the gate lets through a finding answered with a verdict and counts the severities its level names. A finding whose dispute was upheld is never let through until it is fixed or deferred. When `gate.level` is not `off`, the pull request is done when `gate.blocking` is false; with the gate off, follow `verdict`.

| Field | Meaning |
| --- | --- |
| `schemaVersion` | `1`. Fields are only ever added; a change in meaning bumps it |
| `nextAction` | What to do now: `action`, `refs` (the findings it is about, by ref, or id for one not yet numbered) and `reason`. See [Next action](#next-action). Absent from older servers |
| `round`, `reviewedSha` | The last round that finished, and the commit it reviewed. Act on `verdict` only when `reviewedSha` is the commit you pushed: for a minute or more after a push the payload still describes the previous one |
| `prHeadSha` | The pull request's head as GitHub last reported it. When it differs from `reviewedSha`, the verdict is about an older commit |
| `headSha` | Deprecated: the reviewed commit, the same as `reviewedSha` despite its name |
| `inProgress` | A newer round is running; everything else describes the last finished one |
| `counts` | `open`, `critical`, `warning`, `suggestion` |
| `verdict` | `ready` (no critical or warning open), `blocked` (some are) or `needs-review` (see `verdictReason`) |
| `blockedBy` | Refs (or ids) of the open critical and warning findings. Empty when `ready` |
| `verdictReason` | Why the verdict is `needs-review`: no round has finished, the last round failed, the orchestrator could not run and the findings are unfiltered, or the head is a commit no round reviewed (as when a round stood down for a newer push and none is running), or a full round skipped every changed file so no model read the change. `null` otherwise. For no finished round or an unreviewed head, trigger a review. For a failed or unfiltered round, or one that read no file, report it and stop: do not trigger again in a loop |
| `nextRound` | `will-run-on-push`, `cap-reached` (the automatic round limit is used up, the repository's or one set with `/rounds`; a `/review` or trigger is refused until the limit is raised) or `disabled` (automatic review or the push trigger is off). Draft, bot-author and base-branch trigger filters are not taken into account |
| `findings` | Each open finding, most severe first. See [Finding fields](#finding-fields) |
| `disputes` | Every disputed finding, oldest dispute first, withdrawn and closed ones included: `id`, `ref` and the fields of `dispute` |
| `suppressed` | Dismissed findings a later round reported again and kept closed, latest re-report first. See below. Absent from older servers |
| `heldBack` | New suggestions a round after the pull request's first held back instead of posting ([suggestions after round 1](/docs/triggering-reviews#suggestions-after-round-1)): `count`, `reason` (`later_round_suggestion`), `switch` (`REVIEW_HOLD_LATER_SUGGESTIONS`), `why` (one sentence) and `findings`, each with `id`, `ref`, `severity`, `confidence`, `file`, `line`, `message`, `suggestion`, `heldBackAtRound`, `lastSeenRound` and `postedIn` (`payload`). Not counted in `findings`, `counts`, `blockedBy`, the gate or `nextAction`. `null` when none is held; absent from older servers |
| `pullRequest` | How the pull request ended: `state` (`open`, `merged` or `closed`), `closedAt` and `mergedAt` (epoch ms), `mergeCommitSha`, `mergedBy` (a GitHub login), and `openAtClose` (`count` and `refs` of findings still open when it closed; `null` while open). Empty values are `null`. Reopening the pull request clears them. Absent from older servers |
| `authorModel` | Which coding agent and model family wrote the pull request, as far as the last round could tell: `family` (`anthropic`, `openai`, `google`, `xai`, `deepseek`, `moonshot`, `mistral`, `human` or `unknown`), `tool` and `model` when named, and `evidence` (commit trailers, the description, the branch name or the author account). `null` before any round read it |
| `handoff` | The handoff that round read: `source` (`pr-body` or `api`), `headSha` and `agent` when given. `null` when it had none or CodePanel has handoffs off. The text is not repeated |
| `authorProof` | What the author says it ran to prove the change, as the last round found it: `source` (`description`, or `handoff` for the description's handoff block; a handoff submitted through the API is never used), `rung` when it names one, and `text`, the section on one line, up to 500 characters. The author's claim, not checked by CodePanel. `null` when it stated none ([Proof](/docs/agent-setup#proof)) |
| `linkedIssues` | Issues the pull request closes that the round read, as `owner/name#12`. Empty when none, unreadable, or CodePanel has linked issues off. On a public repository, issues in other repositories are withheld and not listed |
| `stepBack` | From the repository's `stepBackAfterRounds` round (3 by default) while the pull request is open: `rounds` (rounds that reviewed something, counted as the round limit counts them), `threshold`, `totalFindings` (every finding on the pull request, resolved ones included), `findingsAfterRound1` (those first reported after round 1, which usually means on code written during the review; `basis` is `first-reported-after-round-1`), `action` (`reconsider-approach`), `reason`, and how to turn it off (`setting` `stepBackAfterRounds`, `offValue` `0`). Advice only: it changes neither `nextAction`, the verdict nor the gate, unless the repository escalates on it (`escalation`). `null` otherwise; absent from older servers |
| `escalation` | Findings handed to a person ([Merge gate](/docs/merge-gate#escalate-to-a-person)): `trigger` (`upheld_critical`, `round_limit`, `step_back` or `novel`), `refs`, `contacts` (GitHub logins), `reason` (one sentence with the evidence), `needsPerson` (for `novel` only: each finding's `ref`, `category` and the orchestrator's `reason`) and `notifiedAt` (epoch ms of the comment that asked them, `null` until posted). `null` unless the repository sets `escalation` and a trigger applies; absent from older servers |
| `convergence` | How the pull request's rounds went, from the same functions as [`GET /quality`](/docs/api#get-quality) `convergence`: `rounds` so far; `firstGreen`, the round after which the gate was first green (`null` if not yet); `roundsByTrigger`, every round by what started it (`push`, `manual` for `/review`, the dashboard, the API or MCP, `base_merge` for a push of only base-branch changes, `unknown` for a round that predates the record); and `afterGreen`: `rounds` that began when the gate was green, how many `reBlocked` (reported a new warning-or-worse finding), and `byTrigger` with the same two counts per trigger. Read-only: it changes neither `nextAction`, the verdict nor the gate. Rounds beyond the repository's `maxAutoRounds` show up here as `manual`. The review comment's footer carries the same split as "Rounds: 3 automatic, 2 requested (`/review`), 1 base merge". `null` when the history is too large to read; absent from older servers |
| `localReview` | Your agent's own review, sent with [`POST /reviews/local`](#post-reviewslocal), of the pull request's head (else of the reviewed commit): `headSha`, `agent`, `verdict`, `counts` by severity, `total`, `fixed`, `dropped` (past 50, not kept), `submittedAt` and `claim` (always `author`). The author's claim, not checked by CodePanel: it changes neither the verdict nor the gate, and `nextAction` only by ending a `review_locally` for the commit it names. `null` when none was sent; absent from older servers |
| `failingReviewers` | The repository's panel members that failed two or more rounds in a row, while the open pull request is still reviewed without them: `memberId`, `name`, `role` (`reviewer` or `orchestrator`), `provider`, `modelId`, `consecutiveFailures`, `failingSince` and `lastFailureAt` (epoch ms, `failingSince` `null` on a streak older than the field), `reason` (the provider's latest error, redacted), `keyFailure` (out of credit or revoked, which only a person can fix), `keyTurnedOffAt` (when the streak turned your own key off, so rounds skip the member; `null` while it is on, see [`GET /keys`](#get-keys)), `consoleUrl` and `fix` (one sentence). While any is listed, `nextAction.reason` ends with a `Panel:` sentence asking you to tell your user; the action itself is unchanged. Empty when none is failing or the pull request is closed; absent from older servers |
| `panel` | The latest finished round's reviewers (the round `verdict` reads): `asked` (those it called; a skipped UI-only reviewer is not counted), `answered`, `complete` (every reviewer asked answered) and `failed`, one entry each with `slug` (as in `keys`), `modelId`, `cause` (`output_limit`: the model ran out of output tokens before finishing; `timed_out`: the round went on without it, or it was still unanswered when the round ended; `error`: anything else, or unanswered in a round that failed) and `detail` (the error on one line, redacted and cut to 300 characters). A round with `complete` false posted only the other reviewers' findings, so its verdict covers less than the whole panel. `null` before a round finishes, or when the latest called no reviewer; absent from older servers |
| `keys` | Which key paid for each panel member in the latest round that recorded it: `reviewers` and `orchestrator`, each with `slug`, `modelId`, `paidBy` (`credits`, `own_key` or `plan`) and `creditsSkipped` (`balance` when the balance did not cover a [credits-first](#credits-first) member, `no_price` for a model without a known price, `not_offered` for one CodePanel's key does not offer, `platform_key` when CodePanel's own key for the provider is refused or expired, else `null`) and `ownKeyRejected` (`true` when the member ran on credits because the account's own key for its provider is rejected). `null` before any round recorded it; absent from older servers |
| `crossFamily` | Who carried the latest round's verdict when the repository sets `crossFamilyReview` ([Cross-family verdicts](/docs/reviewers#cross-family-verdicts)): `outcome` (`swapped`, the verdict moved to another family; `kept`, the orchestrator already qualified; `unavailable`, no other family has a working key, so the round ran as configured; `skipped`, the author's family is not known), `authorFamily`, `fullLane` and `fullLaneReason`, `verdictBy` (`provider`, `modelId`, `family`), `from` (the configured orchestrator, when the round moved off it), `frontier` (whether the verdict model is its provider's frontier model; a full-lane round can be cross-family without it) and a `reason`. `null` when the setting is off or no round recorded it; absent from older servers |
| `ci` | The head commit's CI when the last finished round started: `passed`, `failed`, `pending` (check names) and `annotations` (how many the failed checks carried). Most checks are usually still `pending` then, so read your CI for the current result. `null` when unreadable or CodePanel has CI signals off (the default) |

`suppressed` entries have `id`, `ref`, `severity`, `file`, `line`, `message`, `round` and `headSha` (the latest re-report), and `dismissal`: `reason` (or `null`), `by` (the agent, GitHub login or `owner`), `via` (`agent`, `github` or `owner`), `at`, and `withdrawnReason` (the orchestrator's reason when a withdrawn dispute closed it, else `null`). An entry leaves the list once a later round re-reads the finding's code and does not report it; compare its `round` with the payload's to judge how recent it is. Suppressed findings are not counted in `counts`, `blockedBy` or the verdict. Reopen one with [`POST /findings/reopen`](#post-findingsreopen).

### Next action

`payload.nextAction.action` is decided on the server from the gate, the verdict, `inProgress`, `reviewedSha` against `prHeadSha`, and `nextRound`. Rows are checked top to bottom.

| `action` | When | What to do |
| --- | --- | --- |
| `done` | The pull request is merged or closed (`pullRequest.state`) | Stop: it takes no more pushes |
| `review_locally` | CodePanel refused to review the head for a budget, cap, credits, plan or key reason, and no local review of that commit was sent yet. `refs` names any open findings the gate still counts | Do not wait or trigger: no round is coming. Run the [review brief](#get-review-brief) in a fresh-context subagent on your own model, fix what it shows, send it with [`POST /reviews/local`](#post-reviewslocal), answer the findings in `refs`, and carry on. Once the local review is in, `nextAction` follows the open findings as if a round had run |
| `fix` | A finding the gate counts has no fix or answer (with the gate off: an open critical or warning) | Fix each finding in `refs`, or answer it with a verdict ([`POST /feedback`](#post-feedback)). `reason` says whether the next push is reviewed |
| `wait` | A round is running, or the only blocking findings are your own disputes the orchestrator has not answered (`refs` names them), including one waiting on a budget or key; each counts as an answer 4 minutes after you made it | Wait for the round (`GET /reviews/status`, `wait_for_review`), or read the review again in a few minutes |
| `trigger` | No round has reviewed the head and nothing is running | Start one ([`POST /reviews/trigger`](#post-reviewstrigger), which spends credits), then wait |
| `escalate` | Every blocking finding left was handed to a person (`payload.escalation`); only with the repository's `escalation` setting | Do not push or dispute for the findings in `refs`. Report it, wait for their `/feedback`, then read the review again |
| `rate` | Nothing blocks, but open findings in `refs` have no rating | Rate each one (`fixed`, `deferred`, `false_positive`, ...). When only suggestions are open, `reason` says not to push a commit for suggestions alone, since every push starts another round |
| `done` | Nothing blocks and every open finding is rated, including on a capped head (`rounds.capped`), where `reason` says no review is coming | Stop. On a capped head, do not `/review` or trigger: both are refused, and raising the limit buys a paid round, worth it only when your user asks or the push changed code no round has read. A local review ([review brief](#get-review-brief), [`POST /reviews/local`](#post-reviewslocal)) is the free check |
| `stop` | The last round failed, was unfiltered, or read no file (every changed file skipped for size), or no round ever ran and the round limit allows none. A capped head (`rounds.capped`) follows its findings instead: `fix`, `escalate`, `rate`, `done`, or `trigger` for one confirming round when only your own `fixed` or `deferred` on a critical is left | Report `reason`; do not trigger again in a loop |

### Finding fields

`payload.findings` and [`GET /findings`](#get-findings) share one projection. Empty values are `null`, never left out.

| Field | Meaning |
| --- | --- |
| `id`, `ref` | The finding's id, and its ref on the pull request (`F3`). Follow a finding across rounds by these; `fingerprint` can change when a round rewords it |
| `severity`, `confidence` | `critical`, `warning` or `suggestion`; `high`, `medium` or `low` |
| `file`, `line`, `lineSha` | Where it is; `lineSha` is the commit `line` refers to |
| `message`, `suggestion` | What is wrong, and the suggested fix |
| `instances` | Other places with the same defect, each `{file, line}` (`line` may be `null`), lines at `lineSha`. Fix every one: the finding stays open until each place is changed. A rating answers all of them. Empty unless CodePanel reports [one finding per class of bug](/docs/findings#one-finding-several-places) |
| `failureScenario`, `verify` | What triggers it and how to confirm it. Always `null` unless CodePanel is set to ask for failure scenarios |
| `patch` | A unified diff that applied cleanly to `file` at `lineSha` when stored. `null` unless the repository has [inline suggestions](/docs/findings#inline-suggestions) on or CodePanel is set to ask for patches; never for files with Windows line endings. Check it like any fix before applying it |
| `preExisting` | Why the finding was marked pre-existing and demoted to a suggestion, or `null` |
| `proofGraded` | Why a warning was lowered to a suggestion: the description's proof names a test of this file that the change adds to, and every check on the head commit passed. Names the test, the checks and the commit. `null` unless the repository turns on `REVIEW_PROOF_GRADING` ([Review switches](/docs/review-switches)) |
| `notBlocking` | One sentence saying why a finding at the gate level does not hold the merge (low confidence at `warning_high`, a finding written by the orchestrator alone, or outside the lines changed since green). `null` when it blocks or is not gated. The review comment prints it as `Not blocking: <reason>` |
| `fixCheck` | The [fix check](/docs/merge-gate#fix-check-past-the-round-limit)'s verdict on an agent's `fixed` past the round limit: `sha` (the head it read), `outcome` (`confirmed` or `not_confirmed`), `reason` (the model's one sentence), `model` and `at`. A `not_confirmed` whose `sha` is the head means the agent's `fixed` does not count until a new push. `null` unless the repository turns on `REVIEW_CONFIRM_FIXES` and a check decided something |
| `reviewers`, `models`, `source` | Reviewer names (empty for a finding the orchestrator wrote); distinct `provider/modelId` values, not paired with `reviewers`; `reviewers` or `orchestrator` |
| `state` | `new` (first reported by the last round), `open` (reported earlier, still open; the comment says "open since round N"), `resolved` (a round confirmed it fixed) or `dismissed`. Only `GET /findings` with `includeResolved` returns the last two |
| `answered` | It has a verdict since the last round reported it, so the gate no longer counts it |
| `rated` | Anyone rated it at all |
| `firstSeenRound`, `lastSeenRound` | The rounds that first and last reported it |
| `dispute` | When an agent disputed it: `status` (`pending`, `withdrawn`, `upheld`, `revised`, or `closed` when closed another way), `claim` (the reason given), `by`, `at`, `reason` (the orchestrator's, once decided), `headSha` (the commit disputed) and `waiting` (why a pending dispute is not answered yet, such as a budget limit, no key for any panel model, or not enough credits) and `lapsedAt` (when a pending dispute passed its 4-minute deadline undecided, so the gate counts it as an answer; otherwise `null`). Otherwise `null` |
| `status` | Deprecated: `new` or `open`, as `state` |

`failureScenario`, `verify` and `patch` are CodePanel settings, not repository settings.

**Deprecated, kept for existing readers:** the top-level `findings` list (read `payload.findings`), `payload.headSha` (read `reviewedSha`), each finding's `status` (read `state`) and `agentNames` (read `reviewers`). They stay while any reader depends on them; a removal will come with a `schemaVersion` bump and a changelog note.

## Review quality

### GET /quality

How precise the reviews on one repository have been, counting only verdicts the pull request's author agent cannot give itself. An agent that fixes every finding, false positives included, would make an "addressed" or "rated up" rate look perfect, so those are reported apart and never counted as precision.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `days` | integer | no | The window, by when findings were reported. Default 30, at most 90 |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/quality?repo=acme/api" \
  | jq '.byModel[] | {key, precision: .verified.precision, sample: .verified.sample, insufficientData: .verified.insufficientData}'
```

The response has `overall` and rows `byModel`, `byRole`, `bySeverity`, `byConfidence` and `bySeverityConfidence` (keys like `warning/low`), each `{ key, reported, verified, unverified }`, plus `days`, `since`, `findings`, `unattributed` (findings recorded before models were), `truncated` (only the newest 2,000 findings were read) and `minSample`.

`verified` holds what counts:

| Field | Meaning |
| --- | --- |
| `truePositives` | `disputesUpheld` and `disputesRevised` (the orchestrator read the code and kept the finding, maybe milder), and `upByPerson` (an up from you or a trusted collaborator, on the review page or as a `/feedback` reply) |
| `falsePositives` | `disputesWithdrawn` (the orchestrator agreed it was wrong), `downByPerson` and `dismissedByPerson` (a trusted person said `false_positive` or `not_worth_fixing`); `notWorthFixing` counts the second |
| `sample`, `coverage` | Findings with a verdict, and their share of `reported` |
| `precision`, `interval` | TP / (TP + FP), with a 95% interval. `null` until `sample` reaches `minSample` (20) |
| `insufficientData` | `true` below `minSample`: too few verdicts to compare this row with another |

`unverified` is what an agent can produce on its own, for context: `addressedByCommit` (resolved after a commit edited the finding's lines), `resolution` (how each finding a later round closed was closed: `touched`, `moved`, `fileRemoved`, `fileLeft`, `untouched`, `unclassified`, or `unrecorded` for findings closed before this was recorded), `upByAgents`, `downByAgents` and `unverifiableDismissals` (older dismissals that do not say whether a person or a token made them).

- A token's ratings and dismissals are an agent's, and so is a `/feedback` reply with `--agent` or from a bot.
- A dispute counts only when the disputer could have closed the finding.
- When one finding has several verdicts, the newest decides.
- Reopening a finding on the review page voids every earlier verdict on it, a collaborator's included; reopening it with a token does not.
- Roles are matched from reviewer names: `orchestrator` is a finding no reviewer reported, `custom` a reviewer whose name matches no role.

### GET /precision-audit

Precision measured on a random sample of what CodePanel posted, rather than on the findings an agent chose to dispute. Every day a job draws, for each completed week (UTC, ISO weeks such as `2026-W43`), 30 of that week's posted findings, uniformly at random within each severity in proportion to what was posted. A bucket (severity and confidence, such as `suggestion/low`) whose [verified precision](#get-quality) over 90 days is below 25% on at least 50 verdicts also gets one targeted draw of 30 of its findings. The draw is ordered by a hash of the repository, the week and the finding, and stored once drawn, so nobody picks the sample and later edits cannot move it. Verdicts are read live, so a person who corrects a rating corrects the audit.

A person audits the sample: rate each listed finding up, or down with `false_positive` or `not_worth_fixing`, on its review page or as a `/feedback` reply without `--agent`. Nothing a token does counts, so this route only reads. The orchestrator's dispute decisions are left out too.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `week` | string | no | The week to list, such as `2026-W43`. Default the newest week drawn |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/precision-audit?repo=acme/api" \
  | jq '{judged, awaiting: [.items[] | select(.verdict == null) | .reviewUrl]}'
```

| Field | Meaning |
| --- | --- |
| `target` | `{ precision: 0.7, sample: 150 }`: the target is met when the 95% interval's lower bound over the latest 150 audited findings of the weekly draw reaches 70% |
| `judged` | That reading: `audited`, `truePositives`, `precision`, `interval`; `drawn` and `awaitingAudit` count the weekly draw; `met` is `null` until 150 are audited |
| `targeted` | One row per bucket that had a targeted draw: `bucket`, `drawn` and the same reading. Never part of `judged` |
| `weeks` | Each week drawn: `proportional`, `targeted` and `audited` counts |
| `week`, `items` | The listed week's draw: `ref` (`F3`), `prNumber`, `kind`, `bucket` (when drawn), `severity` (now, which a later round may have revised), `file`, `line`, the start of the `message`, `verdict` (`true_positive`, `false_positive` or `null`), `verdictSource` and `reviewUrl`, the page to rate it on |
| `missing`, `ratingsCapped`, `truncated` | Drawn findings since deleted; findings with more than 20 raters, left without a verdict; whether only the newest 1,000 draws were read |

### GET /escapes

What a repository's reviews missed. Every other quality number is about findings that were posted; this counts what was not. An escape is a range of lines that a CodePanel-reviewed pull request added and that a later commit on the default branch fixed or reverted, where no finding of that pull request sat within 3 lines.

A daily job finds them. For each repository with a reviewed pull request merged in the last 16 days, it lists the default branch's commits since its last run. A commit counts when its message says it fixes or reverts something: a revert, a word that says something broke (`regression`, `hotfix`, `broke`, `crash`), or a subject that leads with a fix. "Fix lint" and "fix review findings" do not count, and neither does a merge commit. Each line such a commit changed is placed by blame at the commit's parent, never by its text, and kept when:

- GitHub ties the blamed commit to a pull request CodePanel reviewed (squash, merge-commit and rebase merges all resolve);
- the fixing commit came within 14 days after that pull request merged and is not part of it;
- the line was already there at the commit the pull request's last round read;
- no finding of that pull request sat within 3 lines.

Docs, tests, fixtures and generated files are left out. One run lists at most 200 commits for a repository and reads the files of at most 20 matching ones; the rest wait for the next run, oldest first. It is measurement only: no review reads these rows.

Scope: `read`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `days` | integer | no | The window, by when each escape first showed. Default 30, at most 90 |

```bash
curl -sS -H "Authorization: Bearer $CODEPANEL_TOKEN" "$CODEPANEL_URL/api/v1/escapes?repo=acme/api" \
  | jq '{rate, refs: [.escapes[] | select(.notEscape == null) | "\(.ref) \(.path):\(.startLine)"]}'
```

| Field | Meaning |
| --- | --- |
| `rate` | Over the reviewed pull requests merged in the window: `escapes`, `escapedPullRequests`, `reviewedMerged`, `per100` (escapes per 100 of them, counted over every row and not only the 200 listed; `null` when none merged, or when either count passed 2,000 and was cut), `notEscapes` (rows marked, not counted) and `stillInWindow` (merged under 14 days ago, so they can still gain one and the rate can still rise) |
| `escapes` | Newest first, at most 200. Each is one range of one pull request's lines: `ref` (`E3`, never reused), `prNumber`, `round` and `reviewedSha` (the review that let it through), `path`, `startLine` and `endLine` at `reviewedSha`, `mergedAt`, `firstFixedAt`, `insertionOnly` (every fix only inserted beside the lines: weaker evidence) and `notEscape` (`null`, or `{ at, agent, note }` once marked) |
| `escapes[].fixes` | The commits that changed the lines, oldest first: `sha`, `at`, `rule` (`revert`, `break` or `fix`) and `subject` (at most 120 characters). A second fix of the same lines is added here, not as a second escape |
| `scan` | The daily job's last run, `null` before the first: the cursor (`sha`, `commitAt`), `ranAt`, `listed`, `fetched`, `filesSkipped` (files whose blame or reviewed version could not be read), `recorded`, `stoppedShort` and, when it ended early, `failure` |
| `windowDays`, `truncated` | 14; whether only the newest rows or merges were read |

The scan lists commits by commit date. A commit that reaches the default branch long after it was committed (a stale branch merged with a merge commit, a direct push of old commits) is behind the cursor and is not read.

### POST /escapes/mark

Marks an escape as not an escape, when the fixing commit did not fix a defect in those lines. The row is kept with who marked it and is no longer counted; later fixes of the same lines still land on it. `notEscape: false` takes the mark back. Nothing waits for this call: escapes count as soon as the scan records them.

Scope: `reviews:write`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | `owner/name` |
| `ref` | string | yes | The escape, such as `E3` |
| `notEscape` | boolean | no | `true` (default) marks it; `false` takes the mark back |
| `note` | string | no | Why, in a sentence. Cut to 500 characters |
| `agent` | string | no | Who is marking it, such as `claude-code`. A call that names none is recorded as `api` |

```bash
curl -sS -X POST -H "Authorization: Bearer $CODEPANEL_TOKEN" -H "Content-Type: application/json" \
  -d '{"repo":"acme/api","ref":"E3","note":"A rename, not a defect","agent":"claude-code"}' \
  "$CODEPANEL_URL/api/v1/escapes/mark"
```

Returns `{ ref, notEscape, outcome }`, where `outcome` is `marked`, `unmarked`, or `unchanged` when the row was already in that state. An unknown ref is a 400: `Escape E9 not found; refs look like E3`.

### Convergence

The same response carries `convergence`: how the review loop settles on this repository, for the pull requests merged in the window. Fewer rounds is better only while the verified precision above holds, so they are read together. Rounds per pull request and the first-seen split say how much loop there is; the rounds after a green gate say what it was spent on.

`convergence` is `{ repo, days, since, pullRequests, truncated, minPullRequests, overall, byPipeline }`. The cohort is the pull requests merged in the window that had a round in it, with their whole history, up to 60 of the newest (`truncated` says a cap was hit). `overall` is every pull request; `byPipeline` has one segment per pipeline, keyed by the prompt hashes and the switches that were on, counting a pull request under the pipeline that ran its first round (`unstamped` before pipelines were recorded). Each segment is `{ key, pullRequests, insufficientData, rounds, firstGreen, afterGreen, findingsByRound }`:

| Field | Meaning |
| --- | --- |
| `rounds` | `mean`, `p90` and `fiveOrMore` (the share of pull requests that took five rounds or more) over completed rounds, and `empty`, the rounds that had nothing of the pull request's own to review |
| `firstGreen` | `afterRound1`, the share of pull requests whose gate was green after the first round; `meanRounds`, the mean round at which it first went green; `never`, pull requests that merged without it ever being green after a round |
| `afterGreen` | `rounds` that began when the previous round had left the gate green, as a `shareOfRounds`; `reBlocked`, how many of them reported a new warning or worse, and `reBlockedShare`; `byTrigger`, the same by what started the round |
| `findingsByRound` | Findings by the round that first reported them (`1`, `2`, `3`, `4+`) with their severity mix |

A trigger is `manual` (`/review`, the dashboard, the API or MCP), `push` (a pull request event: an author's push), `base_merge` (every commit since the last review merged the base branch, or the push carried base-branch changes and nothing of the pull request's own), or `unknown` for a round that predates the record. Rates are `null` when there is nothing to divide, and `insufficientData` is `true` below `minPullRequests` (20).

The gate after each round is not stored, so it is rebuilt from the findings and ratings with the gate's own rule (a finding is answered when a round resolved it, someone dismissed it, or a verdict was given since the last round that reported it), always at warning or worse. It is a lower bound on how often the gate was red, since a verdict or dispute that changed later is seen only in its last state.

`convergence.loop` is the author agent's side of the same loop, for the same pull requests: `{ pullRequests, excluded, truncated, overall, byGuidance }`, where `excluded` counts pull requests left out for having more recorded events than one query reads (the busiest loops). `byGuidance` has one segment per version of the guidance agents read (the `nextAction` reasons, the review comment's instructions and the MCP server's tool descriptions), keyed by the first 8 characters of the `guidanceHash` the pull request's first round ran with, or `unknown` before it was recorded. Each segment is `{ key, pullRequests, insufficientData, rounds, pushes, pushesPerRound, served, bytesServed, bytesServedPerRound, toolCalls, toolCallsPerRound, afterServed, pushAfterDone, clients }`:

| Field | Meaning |
| --- | --- |
| `pushes`, `pushesPerRound` | Pushes to the pull requests, reviewed or not |
| `served`, `bytesServed`, `bytesServedPerRound` | Reads of the review (`GET /review`, `get_review`, `codepanel review`, the end of `wait_for_review`) and the bytes they returned |
| `toolCalls`, `toolCallsPerRound` | Those reads plus ratings and disputes made through the API, one per finding rated; waiting's polls are not counted |
| `afterServed` | For each `nextAction` served, what came next: a `push`, `rating`, `dispute`, `trigger`, or `none` yet |
| `pushAfterDone` | `{ served, pushed, share }`: how often `done` was followed by a push, each of which starts a full round |
| `clients` | Who read the reviews: the MCP client's name, the connected app's, or the `X-CodePanel-Client` header, with the `X-CodePanel-Plugin-Version` header when sent |

These are what CodePanel can count of an agent's work; they are not its token usage. They inform only: nothing here changes a review, the gate or `nextAction`.

## Example

Trigger a review, wait for it, and read what to do next.

```bash
AUTH="Authorization: Bearer $CODEPANEL_TOKEN"
curl -sS -X POST -H "$AUTH" -d '{"repo":"acme/api","pr":123}' "$CODEPANEL_URL/api/v1/reviews/trigger"

# poll until "finished" is true and "lastReviewedSha" is the commit you pushed
curl -sS -H "$AUTH" "$CODEPANEL_URL/api/v1/reviews/status?repo=acme/api&pr=123"

curl -sS -H "$AUTH" "$CODEPANEL_URL/api/v1/review?repo=acme/api&pr=123" \
  | jq '{next: .payload.nextAction, gate, findings: [.payload.findings[] | {ref, severity, file, line, message}]}'
```

### Panel filters and reviewer tools

`GET /panels?repo=owner/name` returns only the repository's effective panel, including the default fallback. `GET /panels?panelId=...` returns only that owned panel. The filters are mutually exclusive; foreign panels and repositories return 404. Without a filter, the existing all-panels response is preserved.

`GET /reviewer-tools?repo=owner/name` needs `read` and returns effective tool enablement, available tool descriptions, revision and limits, plus `gitHistory: false` and `shell: false`. Omit `repo` for CodePanel's default. See [reviewer tools and path scopes](/docs/reviewers#reviewer-tools-and-path-scopes).

Recommendations preserve existing seats by default. Pass `roles` explicitly to change the lineup. Responses include `changes` explaining additions/removals. Apply edits matching seats in place; undo includes `reviewerModels` so their former models, effort and names can be restored without replacing seats.
