---
title: "REST API"
description: "Call the Baz REST API with an API key: authentication, the endpoints that accept a key, request and response shapes, and errors."
canonical: "https://baz.ai/docs/reference/api"
---

# REST API

Call the Baz REST API with an API key: authentication, the endpoints that accept a key, request and response shapes, and errors.

The Baz REST API gives scripts, CI jobs, and agents the same data the app uses: reviewer configuration, review discussions, memories, plans, evaluations, and indexed code search. An API key acts as the user who created it and carries that user's permissions. Only the endpoints on this page accept a key; every other endpoint rejects it.

## Authentication

Create a key in **Account Settings → API Keys** with **Generate API key**. The key is shown once ("Copy this key now. You will not see it again."). See [API keys](/docs/admin/api-keys).

Send the key in the `x-api-key` header. Do not put it in `Authorization`, which carries only browser session tokens.

```bash title="Terminal"
curl https://baz.ai/api/v2/reviewer/reviewers \
  -H "x-api-key: $BAZ_API_KEY"
```

API requests go to `https://baz.ai`. On a self-hosted or private deployment, use your own Baz host. The interactive API reference is served at `/api-docs` on the same host.

## Endpoints that accept an API key

All paths start with `/api/v2`.

| Method | Path | Description |
| --- | --- | --- |
| GET | `/reviewer/config` | The organization's review configuration: feature switches (`orgConfig`) and excluded paths per repository (`excludedConfig`). |
| GET | `/reviewer/reviewers` | List agents. Query: `enabled` (`true` or `false`), `repoName` (`owner/repo`, only agents that apply to it). |
| GET | `/reviewer/reviewers/:reviewerId` | One agent with its configurations. `404` if it is not in your organization. |
| PATCH | `/reviewer/reviewers/:reviewerId` | Update an agent: `title`, `description`, `enabled`, `scopesToAdd`, `scopesToRemove`, `configurations`. `403` if you cannot edit it. |
| GET | `/memories` | List memories visible to you, with filters, sorting, and pagination. |
| GET | `/memories/filter-options` | Repositories, contributors, agents, and categories that appear on visible memories. |
| GET | `/memories/:id` | One memory with its source PR comments. Query: `sourceLimit`. |
| PATCH | `/memories/:id` | Update `text` (1 to 10000 characters), `status` (`active` or `disabled`), or `scope`. Admin only. |
| PATCH | `/memories` | Activate or disable every visible pending memory that matches a filter. Body: `status`, `filter`. Returns `{ "updated": number }`. Admin only. |
| GET | `/memories/:id/events` | The memory's timeline, oldest first: `learned`, `merged`, `reinforced`, `agent_used`, `edited`, `status_changed`, `scope_changed`. |
| GET | `/memories/:id/usages` | Where the memory was applied, newest first, with posted, prevented, and accepted counts. |
| POST | `/plans` | Create a plan, or add a version when the `seriesKey` already exists. `201` for a new plan, `200` for a new version. |
| GET | `/plans/:seriesId` | Read a plan by UUID or display id (`PLAN-123`). Query: `version` (defaults to latest). |
| POST | `/plans/:seriesId/pull-requests` | Link a PR to the plan and mark the plan implemented. Body: `prNumber`, plus `repoName` or `repoId`. |
| GET | `/plans/:seriesId/comments` | List comments. Query: `includeOutdated` (default `true`). Returns `comments` and `mutedThreadIds`. |
| POST | `/plans/:seriesId/comments` | Add a comment or reply. Body: `body`, `versionId`, optional `parentId`, `anchor`. |
| PATCH | `/plans/:seriesId/comments/:commentId` | Edit a comment's `body` or set `triageState` (`open`, `dismissed`, or `null`). |
| GET | `/discussions/by-branch` | Review discussions on the newest PR for a branch. Query: `repository`, `branch`, `status` (`open` or `all`, default `open`). |
| GET | `/remote-fs/file-search` | Find files by glob in an indexed repository. Query: `repository`, `pattern` (up to 1000 characters), optional `ref`. |
| POST | `/remote-fs/grep` | Search file contents. Body: `repository`, `pattern` (up to 2000 characters), `path`, optional `ref`. Returns `{ "text": string }`. |
| POST | `/cross-repo/search` | Search architecture summaries across the organization. Body: `keywords` (1 to 32), optional `domains` (up to 50). |
| POST | `/review-questions/rank` | Rank the top review questions for a diff. Body: `repoId`, `diff`, optional `k` (default 3), `topCategories` (1 to 5, default 2). |
| GET | `/evaluations` | Everything on the [Evaluation](/docs/insights/evaluation) page in one call. Query: `timeWindow`, `from`, `to`, `repoIds`, `reviewerIds`, `logins`, `groupBy`, `page`, `pageSize`. |
| POST | `/mcp-sessions/events` | Record a planner event for an agent session. Body: `sessionId`, `eventType`, optional `repository`, `agentVendor`, `payload`. |
| POST | `/integrations/azure-devops/projects/:project/repositories` | Add one Azure DevOps repository to Baz. Body: `repository` (name or GUID), optional `automaticReview` (default `true`). The project must already be selected. Admin only. |

`/remote-fs` endpoints return a list of candidate repositories instead of results when the `repository` name is ambiguous. Pass the full `owner/repo` to choose one.

## Examples

### List memories

```bash title="Terminal"
curl "https://baz.ai/api/v2/memories?status=active&pageSize=50" \
  -H "x-api-key: $BAZ_API_KEY"
```

Narrow the list with query parameters. The ones you reach for most are `status` (`pending`, `active`, or `disabled`), `repoIds` or `agentName` to focus on one repository or agent, and `updatedFrom` and `updatedTo` (`YYYY-MM-DD`) for a date range. Results come back in pages of 20 by default; use `page` and `pageSize` (up to 100) to walk through them, and `sort` with `order` to change the order.

```json title="Response"
{
  "memories": [
    {
      "id": "uuid",
      "title": "string",
      "text": "string",
      "status": "active",
      "agents": [{ "id": "uuid", "name": "string", "version": 3 }],
      "contributors": [{ "login": "string", "avatarUrl": "string" }],
      "scope": [{ "repository": { "id": "uuid", "fullName": "org/repo" }, "paths": ["src/api"] }],
      "categories": ["string"],
      "pendingUntil": null,
      "appliedCount": 12,
      "acceptanceRate": 75,
      "preventedCount": 4,
      "createdAt": "string",
      "updatedAt": "string"
    }
  ],
  "pagination": { "page": 1, "pageSize": 50, "total": 1, "totalPages": 1 }
}
```

An empty `scope` means the memory applies to every repository. The `agent` field is deprecated; use `agents`.

### List reviewers for a repository

```bash title="Terminal"
curl "https://baz.ai/api/v2/reviewer/reviewers?repoName=acme/api&enabled=true" \
  -H "x-api-key: $BAZ_API_KEY"
```

The response is `{ "reviewers": [...] }`. Each reviewer includes `id`, `title`, `description`, `enabled`, `type`, `activeVersion`, `scopes`, `createdAt`, `updatedAt`, and `canEdit`.

### Upload a plan

```bash title="Terminal"
curl -X POST https://baz.ai/api/v2/plans \
  -H "x-api-key: $BAZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "seriesKey": "7f1c2a9e-1111-4b6a-9c1e-2d3f4a5b6c7d",
    "content": "# Plan\n\n1. Add the endpoint\n2. Add tests",
    "agentVendor": "claude-code",
    "repoNames": ["acme/api"]
  }'
```

You must send `seriesKey`, `content`, and `agentVendor`. The `seriesKey` is a UUID that ties versions together: post again with the same key and Baz adds a new version instead of a new plan. `agentVendor` names the tool that wrote the plan, such as `claude-code`, `cursor`, or `codex`. Add `repoNames` (up to 20) so reviewers know which code the plan touches.

The response includes the plan `id`, `displayId` (`PLAN-<number>`), `status` (`pending`, `approved`, `implemented`, `closed`, or `deleted`), `versions`, `pullRequests`, and the current `version` with its `content`.

## Errors

Errors return JSON with an `error` string. A `401` means the key is missing, revoked, or sent to an endpoint that does not accept keys. A `403` means the key works but its user is not allowed, for example a non-admin updating a memory, and a `404` means the item does not exist or the user cannot see it. A `409` means a conflict, such as an ambiguous `agentName`; retry or be more specific.

## Related

<CardGroup cols={2}>
  <Card title="API keys" href="/docs/admin/api-keys" icon="key-round">
    Generate and revoke keys.
  </Card>
  <Card title="MCP tools" href="/docs/reference/mcp-tools" icon="network">
    The same data, exposed as tools for coding agents.
  </Card>
  <Card title="How memory works" href="/docs/brain/how-memory-works" icon="brain">
    What memories are and how Baz learns them.
  </Card>
  <Card title="Plans" href="/docs/work/plans" icon="layers">
    Plan review in the Baz app.
  </Card>
</CardGroup>
