# CodeRabbit Agent overview Source: https://docs.coderabbit.ai/agent/index CodeRabbit Agent brings AI-powered code investigation, planning, and action into the tools where your team already works. Slack (This feature is available with CodeRabbit Agent for Slack.) Discord (This feature is available with CodeRabbit Agent for Discord.) CodeRabbit Agent is an AI agent that works where your team already communicates. From a Slack message or a Discord channel, you can ask CodeRabbit to investigate your codebase, generate an implementation plan, and open a pull request — without switching to another tool. The Agent understands your repositories, connected tools, and conversation history. It carries context across messages, retains knowledge over time, and lets multiple people steer the same task from the same thread. ## What the Agent can do * **Investigate** — Browse repository context, trace features across merged PRs and issues, and cross-reference data from connected tools like Sentry, Datadog, or Linear. * **Plan** — Generate a structured Coding Plan from a conversation thread and hand it off to a coding agent like Claude Code, Codex, or Cursor. * **Act** — After the team agrees on a direction, ask CodeRabbit to prepare and open a pull request that incorporates the full conversation context. * **Automate** — Schedule recurring tasks or trigger work from matching messages, so investigations and summaries run without manual prompting. The Agent can also write [Skills](/agent/skills): reusable procedures that persist across sessions and guide future runs through established workflows. ## Available platforms CodeRabbit Agent is available on two messaging platforms, targeting different audiences: | | Agent for Slack | Agent for Discord | | - | - | - | | **Audience** | Engineering teams and organizations | Open-source communities and enabled GitLab Self-Hosted organizations | | **Repositories** | Any repositories connected to the workspace | Eligible public GitHub Cloud repositories or repositories in enabled GitLab Self-Hosted organizations | | **Availability** | Early Access | Limited Availability | | **Billing** | Billed separately by agent minutes | Unpaid during launch, with usage caps | | **Pull request authorship** | Workspace-connected Git platform identity by default, with an optional per-request user identity for live Slack requests | Personal GitHub account or configured GitLab Self-Hosted credentials | ## What's next > [card] [Durable skills](/agent/skills) > > Learn how the Agent writes, stores, and reuses procedures across sessions. > [card] [Agent for Slack](/slack-agent) > > Set up CodeRabbit Agent in your Slack workspace and start investigating, planning, and opening pull requests from Slack threads. > [card] [Agent for Discord](/discord-agent) > > Bring CodeRabbit into your community or organization's Discord server to investigate and contribute from public channels. # Agent skills Source: https://docs.coderabbit.ai/agent/skills Learn how CodeRabbit Agent writes reusable procedures, stores them across sessions, and applies them to future work. Early Access (Agent-authored skills are available as part of CodeRabbit Agent Early Access.) An agent skill is a reusable procedure that CodeRabbit Agent writes for itself. A skill captures how to complete a repeatable task, including the steps, tools, checks, and output requirements that made the workflow successful. Durable skills let the Agent reuse working procedures instead of reconstructing the same workflow in every conversation. They are useful for recurring operational tasks, team-specific processes, and multi-step work that benefits from a consistent sequence. A skill is the best tool when a job has multiple steps that must run in a particular order, or when it is a repetitive task that gets executed often and involves similar actions each time, such as triaging a class of incoming issues or running a standard release checklist. ## How to create a skill You typically create a skill by asking the Agent to author one directly, for example after it works through a task you expect to repeat. The skill records the reusable process rather than the one-time result of the run. Skills persist across sessions, so a procedure remains available after the conversation or run that created it has ended. ![CodeRabbit Agent authoring a durable skill](https://mintcdn.com/coderabbit/7vHtiR4kZfH2Gv1T/assets/images/agent-add-skill.png?fit=max\&auto=format\&n=7vHtiR4kZfH2Gv1T\&q=85\&s=ea94813c5b2e1766bfb329e58c268f8c) CodeRabbit Agent authoring a durable skill ## Using a skill In later runs, the Agent can invoke a stored skill automatically when a request matches its purpose, or you can explicitly ask the Agent to use a specific skill by name. The skill guides the Agent through the established procedure while the current conversation, repository, connected tools, and permissions provide the context for that specific run. Later runs include [automations](/slack-agent/automations), so scheduled or trigger-based recurring operational tasks can invoke the same stored skill as conversational runs. ### Skill availability in Slack In Slack, durable skills follow the same privacy boundaries as durable facts. | Slack surface | Skill availability | | - | - | | Public channels and shared surfaces | Shared workspace skills are available across public-channel workflows | | Private channels | Skills are isolated to that private conversation | | DMs and group DMs | Skills are isolated to that DM or group DM | > [!NOTE] > > Create the skill from the Slack surface where you intend to use it. Skills created in private channels, DMs, or group DMs are not available in public-channel workflows. ## Viewing saved skills Review saved skills in the web app under [**Slack** > **Knowledge base** > **Skills**](https://app.coderabbit.ai/slack/knowledge-base/skills), alongside the [durable facts](/slack-agent/knowledge-base) captured in the same workspace or private conversation. Skills can be edited by asking CodeRabbit Agent in chat to update, correct, or remove the procedure. ## What's next > [card] [Automations](/slack-agent/automations) > > Run saved skills on a schedule or in response to matching events. > [card] [Knowledge Base](/slack-agent/knowledge-base) > > Learn how durable facts give the Agent reusable knowledge alongside durable procedures. > [card] [CLI Skills](/cli/skills) > > Install static SKILL.md packages for compatible coding agents. # Authenticate API requests Source: https://docs.coderabbit.ai/api/authentication Choose a CodeRabbit API key type, create the key, send it with each request, and understand which permissions it carries. Every REST request, and every `coderabbit api` command, authenticates with an API key that you send in the `x-coderabbitai-api-key` header. A key belongs to a person: it acts with that person's current role and access, and never with more. The [hosted MCP server](/api/mcp) doesn't use API keys; it signs you in with OAuth instead. ## Key types | Key type | What it is | Create it in | | - | - | - | | User key | A key for reading and exporting data and for automation that doesn't run reviews. It doesn't need a seat. | **API keys**, type **User** | | Agentic key | A key for agents and CI jobs that run CodeRabbit reviews, such as the [CLI in headless mode](/cli/headless-cli-integration). Its owner must hold a seat, and the key stops working when they lose it. | **API keys**, type **Agentic** | | Workspace API token | A token for an [Enterprise SSO](/management/sso) workspace admin that works across every organization in the workspace. | **Workspace management** > **API tokens**. See [Workspace API tokens](/api/workspace-api-tokens). | | Self-hosted instance key | A user or agentic key created in an organization on self-hosted CodeRabbit or on a self-managed Git provider, such as GitHub Enterprise Server or GitLab Self-Managed. It acts on that whole instance rather than one organization. | **API keys** in that organization | The **API keys** list shows each key's type in the **Type** column. Keys marked **Legacy** aren't tied to a person. Product operations reject them, and the user, audit log, Deep Scan findings, and Bug Scan findings operations return `410 LEGACY_API_KEY`. Replace them with a user or agentic key. ## Which key for which job | Job | Use | Why | | - | - | - | | A script that reads data, such as pull requests and their review status | User key | Reads don't need a seat, and the built-in Member role can create user keys. | | An unattended service that also requests reviews, such as a bot that runs coding tasks and then asks for a review | Agentic key | Requesting a review needs an agentic key, and the same key works for most other product operations. Its owner needs a seat. | | A scheduled export of metrics, credits, audit logs, or Deep Scan and Bug Scan findings | User key, owned by an account that stays with the organization, such as one kept for automation | Metrics, audit logs, and the scan findings exports refuse agentic keys. The owner's role must allow each export, and credit balances also need permission to read the subscription, which the Admin role has and the Member role doesn't. | | User and seat management across the organizations of an Enterprise SSO workspace | [Workspace API token](/api/workspace-api-tokens) | One token covers every organization in the workspace, and in an SSO workspace only a workspace API token can list users and manage seats. | | An AI agent, such as Claude or Codex | The [hosted MCP server](/api/mcp), with OAuth | The agent never holds a key, and you approve the scopes it asks for. | Organizations on self-hosted CodeRabbit or on a self-managed Git provider use a self-hosted instance key of type **User** for exports and user management. ## Create a user or agentic key **1. Open API keys** In the CodeRabbit app, open **API keys** for the [US region](https://app.coderabbit.ai/settings/api-keys) or the [EU region](https://app.eu.coderabbit.ai/settings/api-keys). Organizations on a self-managed Git provider or on self-hosted CodeRabbit find the page at `/settings/account/api-keys`. **2. Create the key** Choose **Create API key**. Select the **Type**, enter a name that says what the key is for, and choose an **Expiration**: 7, 30, or 90 days, 1 year, a custom date up to a year away, or **No expiration**. **3. Copy the key** Choose **Save API key** and copy the key. CodeRabbit shows it only once. Keys start with `cr-`. **Type** offers only the types you can create: * **User** needs a role that can manage API keys. The built-in Admin and Member roles can. For a custom role, see [custom roles](/management/custom-roles). * **Agentic** needs an assigned seat in the organization. If **Create API key** is unavailable, ask an organization admin to check your role and seat. Billing administrators can't create API keys. ## Which keys each operation accepts The API has two families of operations, and they accept different keys: * **Product operations** are the GitHub Cloud operations: identity, repositories, pull requests and reviews, Coding Agent, coding environments, Verify, Triage, security scans and findings, Knowledge Base, automations, reports, configuration, connections, custom roles, and usage. They accept user and agentic keys, workspace API tokens with a [selected organization](#select-an-organization), and connections through the hosted MCP server, which offers most of them as tools. * **Export and user-management operations** are the operations under `/v1/users`, `/v1/audit-logs`, `/v1/metrics`, `/v1/learnings`, `/v1/organizations`, and `/v1/linked-repositories`, plus [Deep Scan code findings](/api/reference/security-scans-code-list) at `/v1/security/scans/code` and [Bug Scan findings](/api/reference/bug-scan-findings-list) at `/v1/bug-scan/findings`. They work on every Git platform CodeRabbit supports. | Operations | User key | Agentic key | Workspace API token | Self-hosted instance key (user type) | | - | - | - | - | - | | Product operations | Yes | Yes, except changes to configuration and connections, including custom roles: `403 forbidden` | Yes, with a [selected organization](#select-an-organization) | No: `404 not_found` | | Users, seats, and role changes under `/v1/users` | Yes | Yes | Yes | Yes | | Other export and user-management operations | Yes | No: `403 KEY_TYPE_FORBIDDEN` | Yes | Yes | A few operations add their own rule: * With a workspace API token, product operations act on one GitHub Cloud organization of the workspace, so every request needs an [organization selector](#select-an-organization). For operations that act on repositories, the token's owner also needs their GitHub account connected in the workspace; without it, the request fails with the message "Connect the API key owner's GitHub account in this workspace." * [Requesting a pull request review](/api/reference/request-pull-request-review) needs an agentic key, because the review uses its owner's seat. * In an Enterprise SSO workspace, [listing users](/api/reference/list-users) and [managing seats](/api/reference/manage-seats) need a workspace API token. User and agentic keys get `403 SSO_WORKSPACE_ORG_KEY_FORBIDDEN`. * [Adding users](/api/reference/add-users) and [changing the seat assignment mode](/api/reference/update-seat-assignment-mode) work only for organizations on self-hosted CodeRabbit or a self-managed Git provider. * A self-hosted instance key of type **Agentic** is refused wherever the table refuses an agentic key. See [Availability](/api#availability) for plans and Git platforms. ## Send the key Send the key in the `x-coderabbitai-api-key` header over HTTPS: ```bash theme={null} curl -sS https://api.coderabbit.ai/v1/me \ -H "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` Use the base URL for your organization's region; see [Base URLs and regions](/api/conventions#base-urls-and-regions). CodeRabbit returns `401` when the header is missing, the key is unknown, deleted, or expired, or an agentic key's owner no longer holds a seat. In the CLI, pass the key with `--api-key-file`, or sign in once with an agentic key. See [CLI](/api/cli). ## Select an organization A user or agentic key belongs to the organization it was created in, and every request acts on that organization. A self-hosted instance key acts on its instance. A workspace API token isn't bound to one organization. Select one with one of two selectors, never both: * **`org_name`** is the GitHub login of a GitHub Cloud organization in the workspace, such as `coderabbitai`. Matching ignores letter case. Use the organization's current login: display names and earlier logins don't match. Name selection is turned on per organization; where it isn't on, or where a name matches more than one organization, use `org_id`. * **`org_id`** is the Git provider's ID for an organization in the workspace, such as the numeric ID of a GitHub organization. It works on every Git platform. Send the selector here: * **Reads** take it as a query parameter. Export and user-management reads cover the whole workspace when you omit it, and one organization when you pass it. Product operations always need it. * **Changes** that act on one organization need it: in the JSON body for `POST`, `PUT`, and `PATCH`, and in the query string for `DELETE`. Seat management works across the workspace by email address and takes no selector. A missing selector where one is needed, or both selectors at once, returns `400`. An organization that isn't active in the workspace returns `404`, and a token whose owner is no longer a workspace admin returns `403`. CodeRabbit also refuses a key or token whose owner was archived from the subscription. [Workspace API tokens](/api/workspace-api-tokens#supported-operations) lists what each export and user-management operation does with and without a selector. Don't send `org_name` or `org_id` with other keys: product operations reject either one with `400 invalid_request`. A self-hosted instance key can pass `org_id` to [change roles](/api/reference/change-roles) in one organization on the instance, or `"ALL"` for every organization on it. `org_id` differs from the CodeRabbit organization ID that [Get the authenticated principal](/api/reference/get-me) returns in `scope.id`. See [Identifiers](/api/conventions#identifiers). ## Permissions A key carries its owner's permissions, checked again on every request: * **User and agentic keys** act with the owner's current role in the organization, such as Admin, Member, or a [custom role](/management/custom-roles). An agentic key identifies its owner; it doesn't grant extra permissions. * **Workspace API tokens** act as an admin of the selected organization, and only while the token's owner is a workspace admin. * **Plans and product settings** still apply. A key can't use a product that the organization's plan or settings don't include. When the owner's role changes, their keys change with it. A `403 forbidden` usually means the owner's role lacks the permission, the key type isn't accepted, or the owner can't access the repository. ## Store and rotate keys * Store keys in a secrets manager or your CI system's secret store, and expose them to jobs as environment variables. Never commit a key or put it in a URL. * For the CLI, keep the key in a file that only you can read and pass it with `--api-key-file`. The file must contain only the key. * Give each script or integration its own key and an expiration date, so you can revoke one without breaking the others. * To rotate a key, create the new key, switch your integration to it, then delete the old key from the **API keys** list. A deleted key stops working immediately. * Keys start with `cr-`, which helps secret scanners find leaked keys. Delete a leaked key right away. People whose role can manage users can turn on **Show member keys** on the **API keys** page to review and delete keys that others created. ## AI agents and the MCP server The [hosted MCP server](/api/mcp) authenticates with OAuth instead of a key. You sign in to CodeRabbit in the browser, choose an organization, and approve the scopes the agent asks for. The agent never receives a key, and you can grant read access without granting changes. ## What's next > [card] [Handle responses](/api/conventions) > > Learn the base URLs, identifiers, pagination, errors, and rate limits shared by every operation. > [card] [Use workspace API tokens](/api/workspace-api-tokens) > > Create one token that works across every organization of an Enterprise SSO workspace. > [card] [Connect an MCP client](/api/mcp) > > Set up the hosted MCP server with OAuth in Claude, Codex, or another client. # Call the API from the CLI Source: https://docs.coderabbit.ai/api/cli Call CodeRabbit API operations from a terminal, a script, or a CI job with the CodeRabbit CLI and an API key, and get JSON back. `coderabbit api` sends authenticated requests to the CodeRabbit API and prints each response as one line of JSON. It has commands for your identity, repositories, and pull requests, and a `request` command for any other API operation. ## Before you start * Install CodeRabbit CLI 0.9.4 or later. Check your version with `coderabbit --version`. To install the CLI, see [CLI Tool](/cli); to upgrade, see [Update the CLI](/cli#update-the-cli). * Create an API key that can call the operations you need. See [Authentication](/api/authentication). ## Authenticate `coderabbit api` uses an API key from a key file or from a saved agentic key login. A browser sign-in with `coderabbit auth login` doesn't work for API calls: without a key, commands fail with `unauthenticated`. ### Use a key file Save the key alone in a file that only you can read, then pass the file with `--api-key-file`. The option goes right after `api`, before the subcommand: ```bash theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key me ``` The CLI uses the key for this command only and doesn't change your saved login. If the file is missing, unreadable, or empty, the command fails with `invalid_request` and doesn't fall back to the saved login. ### Use a saved agentic key login Sign in once with an agentic key, and later `api` commands use it when you don't pass `--api-key-file`. The CLI saves only agentic keys, so use a key file for a user key. ```bash theme={null} coderabbit auth login --api-key "$CODERABBIT_API_KEY" coderabbit api me ``` ### Use a workspace API token A [workspace API token](/api/workspace-api-tokens) needs an organization selector wherever the operation expects one, as [Select an organization](/api/authentication#select-an-organization) describes. With CLI 0.9.5 or later, the `me`, `repositories`, and `pull-requests` commands take `--org-name`, the organization's GitHub login, or `--org-id`. Pass one of them, not both: ```bash theme={null} coderabbit api --api-key-file ~/.config/coderabbit/workspace-token me --org-name coderabbitai ``` With `request`, put `org_name` or `org_id` in the query string, or in the JSON input where the operation expects it in the body: ```bash theme={null} coderabbit api --api-key-file ~/.config/coderabbit/workspace-token request '/users?org_id=12345678' ``` ## Choose the region The CLI calls the US region unless you select the EU region: * **Saved login:** the CLI uses the region you signed in with. For the EU region, sign in with `coderabbit auth login --region eu --api-key "$CODERABBIT_API_KEY"`. * **Key file:** the CLI doesn't read the saved login, so it calls the US region. For the EU region, set `CODERABBIT_HOST_URL` to the EU app address, or pass `--host-url` with the same value. ```bash theme={null} CODERABBIT_HOST_URL=https://app.eu.coderabbit.ai \ coderabbit api --api-key-file ~/.config/coderabbit/api-key me ``` Set the app address, `https://app.eu.coderabbit.ai`, not the API address: the CLI derives the API address from the app address and rejects other hosts. The host setting also takes precedence over the region of a saved login. ## Commands | Command | Returns | Operation | | - | - | - | | `me` | The key owner and the organization the key selects | [Get the authenticated principal](/api/reference/get-me) | | `repositories list` | Repositories you can access, one page at a time | [List repositories](/api/reference/list-repositories) | | `repositories get ` | One repository | [Get a repository](/api/reference/get-repository) | | `pull-requests list ` | A repository's pull requests | [List pull requests](/api/reference/list-repository-pull-requests) | | `pull-requests get ` | One pull request with checks and, optionally, review threads | [Get a pull request](/api/reference/get-repository-pull-request) | | `pull-requests review-status ` | CodeRabbit's review state for a pull request | [Get the review state](/api/reference/get-pull-request-review) | | `request ` | The response of any operation | Any operation | `` is the Git provider's repository ID, which `repositories list` returns as `id`. For every option of each command, see the [CLI command reference](/cli/reference) or run the command with `--help`. ### `me` Check which key and organization the CLI uses: ```bash theme={null} coderabbit api me ``` `principal` describes the key and its owner's role, and `scope` describes the organization. `scope.id` isn't the value that `org_id` takes; see [Select an organization](/api/authentication#select-an-organization). ### `repositories` ```bash theme={null} coderabbit api repositories list --page-size 100 coderabbit api repositories get 123456789 ``` A list returns `data` and `next_page_token`. Pass the token with `--page-token` and the same page size to read the next page. See [Pagination](/api/conventions#pagination). ### `pull-requests` ```bash theme={null} coderabbit api pull-requests list 123456789 --author all --state open coderabbit api pull-requests get 123456789 42 --include checks,threads coderabbit api pull-requests review-status 123456789 42 ``` * `list` returns your open pull requests unless you set `--author` or `--state`. Filter by source branch with `--head-branch` and `--head-owner`. * `get` includes checks by default. Use `--include threads` or `--include checks,threads` for review threads, and filter them with `--thread-author` and `--thread-state`. Threads have their own page token, `threads.next_page_token`, which you pass with `--thread-page-token`. With `--expected-head-sha`, the command fails with `head_changed` if the pull request's head commit differs. * `review-status` returns the pull request's `head_sha` and CodeRabbit's `review`. See [what the review status means](/api/guides/pull-request-reviews#4-follow-the-review-status). ### `request` `request` calls any operation. Give the path relative to `/v1`, and quote it when it has a query string: ```bash theme={null} coderabbit api request /me coderabbit api request '/code/tasks?page_size=20' ``` Choose the method with `-X` (`--method`): `GET`, `POST`, `PUT`, `PATCH`, or `DELETE`. This call [requests a review](/api/reference/request-pull-request-review) of a pull request's current head: ```bash theme={null} coderabbit api request -X POST /repositories/123456789/pull-requests/42/review ``` Send a JSON body from a file with `--input`. The method is then `POST` unless you set `-X`. For example, create `task.json`: ```json theme={null} { "repository_id": "123456789", "branch": "main", "instructions": "Add a regression test for the pagination bug.", "mode": "plan", "client_request_id": "pagination-plan-001" } ``` Then create the coding task: ```bash theme={null} coderabbit api request /code/tasks --input task.json ``` Keep these rules in mind: * Write the path relative to `/v1`: `/code/tasks`, not `/v1/code/tasks`. The CLI rejects full URLs and paths outside the API. * The input file must contain valid JSON, and a `GET` request can't have one. Put filters in the path's query string instead. * The CLI doesn't follow redirects. * There is no time limit by default. Set one with `--timeout `. Each operation's reference page, such as [Create a coding task](/api/reference/create-code-task), shows its path, method, and body. The [pull request reviews](/api/guides/pull-request-reviews) and [coding tasks](/api/guides/coding-tasks) guides show complete flows. ## Output Each command prints the response body as one line of JSON on standard output. An empty response prints `{}`. Pipe the output to `jq` to format or filter it: ```bash theme={null} coderabbit api repositories list --page-size 100 | jq -r '.data[] | "\(.id)\t\(.full_name)"' ``` Errors are also printed as one line of JSON on standard output, so check the exit code before you use the output. ## Exit codes and errors | Exit code | Meaning | | - | - | | `0` | The API returned a success response. | | `1` | The API returned an error status, or the CLI couldn't make the call. The JSON on standard output describes the error. | Invalid options, such as an unknown method or a page size outside 1–100, print a usage error to standard error and exit with `1` before the CLI calls the API. The `me`, `repositories`, and `pull-requests` commands print errors in one shape: ```json theme={null} {"error":{"code":"rate_limit_exceeded","message":"Too many requests.","retry_after":30}} ``` `code` is one of the error codes that the API returns, and `retry_after` gives the seconds to wait after a rate limit. See [Errors](/api/conventions#errors). `request` prints the error response as the API returns it, so its shape depends on the operation. When the CLI can't make the call, every command prints the same shape with one of these codes: | Code | Cause | | - | - | | `unauthenticated` | No key: you didn't pass `--api-key-file`, and the saved login isn't an agentic key login. | | `invalid_request` | The key file is missing or empty, the path leaves the API, or the input file isn't valid JSON or is used with `GET`. | | `unavailable` | The network request failed or timed out, the response wasn't JSON, or the API returned an error that the `me`, `repositories`, or `pull-requests` command doesn't recognize. | ## Use in CI In a CI job, keep the key in a secret, write it to a temporary file, and pass the file with `--api-key-file`. The CLI then doesn't need a saved login. For the EU region, also set `CODERABBIT_HOST_URL=https://app.eu.coderabbit.ai`. ```bash theme={null} set -euo pipefail key_file="$(mktemp)" trap 'rm -f "$key_file"' EXIT printf '%s' "$CODERABBIT_API_KEY" > "$key_file" coderabbit api --api-key-file "$key_file" \ pull-requests review-status "$REPOSITORY_ID" "$PR_NUMBER" | jq -r '.review.status // "none"' ``` `set -o pipefail` makes the step fail when `coderabbit api` exits with `1`, even though `jq` runs after it. When a call fails with `rate_limit_exceeded`, wait `retry_after` seconds before you retry. CI jobs share your organization's request quota; see [Rate limits](/api/conventions#rate-limits). To install the CLI in CI, see [Headless CLI integration](/cli/headless-cli-integration). ## What's next > [card] [Request and read reviews](/api/guides/pull-request-reviews) > > Read pull requests, request a review, and follow its status through the API. > [card] [Handle responses](/api/conventions) > > Learn how the API handles pagination, errors, and rate limits. > [card] [Connect an MCP client](/api/mcp) > > Give your AI agent the same operations as tools, with OAuth instead of an API key. # API conventions Source: https://docs.coderabbit.ai/api/conventions Base URLs and regions, identifiers, pagination, errors, rate limits, asynchronous operations, and versioning that every CodeRabbit API operation shares. This page covers the rules that apply across the CodeRabbit API. Each operation's page in the API reference adds its own parameters, response fields, and error codes. ## Base URLs and regions Send requests to the region where your CodeRabbit organization lives, the same region as the app you sign in to and create keys in: | Region | App | API host | | - | - | - | | US | `https://app.coderabbit.ai` | `https://api.coderabbit.ai` | | EU | `https://app.eu.coderabbit.ai` | `https://api.eu.coderabbit.ai` | Every path in the API reference starts with `/v1`, so `GET /v1/me` in the EU region is `https://api.eu.coderabbit.ai/v1/me`. If your HTTP client takes a base URL, set it to the API host and keep `/v1` at the start of each path. Use HTTPS. Request and response bodies are JSON; send `Content-Type: application/json` with a body. A few export operations can also return CSV or SARIF when you ask for it with their `format` parameter. The [hosted MCP server](/api/mcp) has its own address and region support. ## Identifiers | Identifier | What it is | Where to find it | | - | - | - | | `repository_id` | GitHub's numeric repository ID, sent as a string of digits. It isn't the repository name or GitHub's GraphQL node ID. | `id` in [List repositories](/api/reference/list-repositories) | | `pull_request_number` | The pull request's number on GitHub, such as `42`. | The pull request URL, or [List pull requests](/api/reference/list-repository-pull-requests) | | `org_id` | The Git provider's ID for an organization, such as the numeric ID of a GitHub organization. Workspace API tokens use it to select an organization; see [Select an organization](/api/authentication#select-an-organization). | `provider_organization_id` in [List organizations](/api/reference/organizations-list). For GitHub, also `id` in the response of `https://api.github.com/orgs/` | | `org_name` | The GitHub login of a GitHub Cloud organization, such as `coderabbitai`. Workspace API tokens can use it instead of `org_id` where name selection is on; see [Select an organization](/api/authentication#select-an-organization). | The organization's GitHub URL, `https://github.com/` | | CodeRabbit organization ID | CodeRabbit's own ID for an organization. It isn't interchangeable with `org_id`. | `scope.id` in [Get the authenticated principal](/api/reference/get-me), or `id` in [List organizations](/api/reference/organizations-list), where it's the `organization_id` of the next request | Other IDs, such as task, scan, and job IDs, are opaque strings that the API returns. Pass them back unchanged. ## Pagination A list operation returns one page and a field that tells you how to get the next. Look at the response, find the continuation field, and send its value back: | The response has | Send it back as | Used by | | - | - | - | | `next_page_token` | `page_token`, with the same `page_size` | Repositories, pull requests, coding tasks, and Change Stack layer diffs. A pull request's review threads use `threads.next_page_token` and `thread_page_token`. | | `next_cursor` or `nextCursor` | `cursor`, with the same `limit` | Most export and user-management operations, Triage, Verify, connection requests, and runtime validations | | `next_before_turn_start_seq` | `before_turn_start_seq` | A coding task's turns and questions | | `next_offset` | `offset` | Automation runs | | `pagination`, `page`, or `total` | The next `page` number | Audit logs, security findings, dependencies, SBOMs, security scans, secret findings, usage budget members, Knowledge Base Learnings, architecture knowledge repositories, and a Verify bug's history | Stop when the continuation field is `null` or missing, or when you reach the last page. Knowledge Base Learnings take their page size as `pageSize`, not `page_size`. * **Keep the request the same.** Send the same filters, page size, key, and organization selector with every page. Only the continuation value changes. * **Continue past empty pages.** A page can be empty while more results follow, for example when it holds only items you can't access. Stop on the continuation field, not on an empty page. * **Don't store tokens.** Page tokens and cursors are opaque and short-lived: repository and pull request listings expire theirs after ten minutes. An expired or mismatched token returns `400`; start again from the first page. * **Expect a live listing.** Items can change between pages. Deduplicate by ID when you collect a full list. Page sizes have a maximum that differs by operation, from 25 to 1,000. Each operation's reference shows its limits and defaults. ## Errors Check the HTTP status first, then the error code in the body. Branch on the code, never on the message text, which can change. When the body has no code, as for a missing or expired key, act on the HTTP status. ### Product operations [Product operations](/api/authentication#which-keys-each-operation-accepts), every operation outside the export and user-management paths listed in the next section, return one error shape: ```json Error response theme={null} { "error": { "code": "rate_limit_exceeded", "message": "Too many requests.", "retry_after": 30 } } ``` | Code | HTTP status | What to do | | - | - | - | | `invalid_request` | 400 | Fix the request: check parameter names, types, and values, and the organization selector: where it goes, and that you sent only one. For an expired page token, restart the listing. | | `unauthenticated` | 401 | Send a valid key. Replace a key that was deleted or expired, or an agentic key whose owner no longer holds a seat. | | `forbidden` | 403 | Check that the key's owner has the permission, that the operation [accepts the key type](/api/authentication#which-keys-each-operation-accepts), and that the owner can access the repository. Retrying unchanged doesn't help. | | `not_found` | 404 | The resource doesn't exist, you can't access it, or the operation isn't available for the organization, for example because it isn't on GitHub Cloud or the key is a self-hosted instance key. | | `head_changed` | 409 | The pull request's head commit changed while you paged through it. Start again without a page token. | | `conflict` | 409 | The resource changed since you read it. Read its current state, then decide whether to repeat the change. | | `precondition_failed` | 412 | A condition the operation needs isn't met. Check the operation's description in the reference before retrying. | | `payload_too_large` | 413 | Send a smaller request body. | | `rate_limit_exceeded` | 429 | Wait `retry_after` seconds, then retry. See [Rate limits](#rate-limits). | | `internal_error` | 500 | Retry a read after a short wait. Before you retry a change, read the resource to check whether the change happened. | | `unavailable` | 503 | A service CodeRabbit depends on is temporarily unavailable. Retry with an increasing wait. | ### Export and user-management operations The operations under `/v1/users`, `/v1/audit-logs`, `/v1/metrics`, `/v1/learnings`, `/v1/organizations`, and `/v1/linked-repositories`, and the Deep Scan and Bug Scan findings exports, return error codes in upper case, in one of three shapes: * `{"error": {"code": "LEGACY_API_KEY", "message": "…"}}` for most errors * `{"errors": [{"code": "RATE_LIMIT_EXCEEDED", "message": "…"}]}` for rate limits and some metrics errors * `{"success": false, "errors": [{"message": "…"}]}` when the key is missing, unknown, or expired Read `error.code` first, then `errors[0].code`. The codes you're most likely to meet: | Code | HTTP status | What to do | | - | - | - | | `LEGACY_API_KEY` | 410 | Replace the legacy key with a [user key](/api/authentication#create-a-user-or-agentic-key). | | `KEY_TYPE_FORBIDDEN` | 403 | The operation doesn't accept agentic keys. Use a user key. | | `SSO_WORKSPACE_ORG_KEY_FORBIDDEN` | 403 | Use a [workspace API token](/api/workspace-api-tokens) in an Enterprise SSO workspace. | | `ENTERPRISE_PLAN_REQUIRED` | 403 | The operation needs the Enterprise plan. See [Plans](/api#plans). | | `RATE_LIMIT_EXCEEDED` | 429 | Wait for the `Retry-After` interval, then retry. | | `METRICS_BUSY`, `METRICS_QUERY_IN_PROGRESS` | 429 | The metrics service is busy, or the same query is still running. Wait for `Retry-After`, then repeat the same request with the same cursor. | | `METRICS_PREPARING` | 503 | The metrics are being prepared. Retry after `Retry-After`. | Each operation's reference lists the rest of its error codes. ## Rate limits Each operation has its own budget: a burst of 10 requests, refilled at 10 requests per minute. These groups of operations share one budget: | Shared budget | Operations | | - | - | | Repositories | [List repositories](/api/reference/list-repositories) and [get a repository](/api/reference/get-repository) | | Pull requests and reviews | [List pull requests](/api/reference/list-repository-pull-requests), [get a pull request](/api/reference/get-repository-pull-request), [read the review status](/api/reference/get-pull-request-review), and [request a review](/api/reference/request-pull-request-review) | | Organization Learnings changes | [Update](/api/reference/learnings-update) and [delete](/api/reference/learnings-delete) an organization Learning | | Metrics exports | [Review metrics](/api/reference/review-metrics), [review comment metrics](/api/reference/review-comment-metrics), and [MCP server usage](/api/reference/mcp-metrics). The size of this budget is set separately from the others. | The budget belongs to the organization, not to the key. Every key, the CLI, and the hosted MCP server draw from the same budget for the same organization. When you go over, the API returns `429` with these headers: | Header | Meaning | | - | - | | `Retry-After` | Seconds to wait before the next request. Product operations also return it as `error.retry_after`. | | `X-RateLimit-Limit` | The size of the budget. | | `X-RateLimit-Remaining` | Requests left in the budget. | | `X-RateLimit-Reset` | When the budget is full again, as a Unix timestamp in seconds. | ### Pace scheduled jobs A job that stays under the budget doesn't have to recover from `429` responses: * Send at most 10 requests a minute to one budget, about one every 6 seconds. For the metrics exports, use the size that `X-RateLimit-Limit` reports on a `429`. * Count every job, script, and agent that works on the same organization, because they draw from the same budget. Start scheduled jobs at different times. * On a `429`, wait the `Retry-After` interval plus a few random seconds, then send the same request again. At this pace, reading the review status of 40 pull requests takes about four minutes. ## Asynchronous operations and retries Some operations start work that finishes later, such as requesting a review, starting a Verify job or a security scan, sending a follow-up to a coding task, or delivering a patch. A successful response, often `202 Accepted`, means CodeRabbit accepted the request, not that the work finished. Read the resource the operation names, such as the review status, the coding task, the Verify job, or the scan, to follow its progress. Most changes don't accept an idempotency key. If a change times out or the connection drops, read the resource before you retry, so you don't start the same work twice. ## Versioning The major version of the API is part of the path: every operation is under `/v1`. Operations and response fields are added to `v1` over time, so write clients that ignore response fields they don't recognize. The API reference is generated from the OpenAPI description that the API serves. ## What's next > [card] [Authenticate requests](/api/authentication) > > See which operations accept which key, and how a key's permissions work. > [card] [Request and read reviews](/api/guides/pull-request-reviews) > > Put pagination, polling, and error handling to work in a complete review workflow. > [card] [API reference](/api/reference/get-me) > > Look up an operation's parameters, response fields, limits, and error codes. # Run coding tasks with the API Source: https://docs.coderabbit.ai/api/guides/coding-tasks Create a Coding Agent task, follow its turns, answer its questions, review and approve its plan, work with plan feedback threads, and deliver the patch. Use this recipe to drive [Coding Agent](/code) from a script or an agent: create a task, follow it, review its plan, and deliver its patch. The task page in the app shows the same task, so people can follow and steer it there too. ## Before you start * You need a user or agentic API key for a [GitHub Cloud organization](/api#availability) that can use Coding Agent; if the same job also [requests CodeRabbit reviews](/api/guides/pull-request-reviews#3-request-a-review), use an agentic key for the whole flow. See [Authentication](/api/authentication#which-keys-each-operation-accepts) for keys and [Conventions](/api/conventions) for base URLs, pagination, errors, and rate limits. * Tasks act as the key's owner: that person's repository access, Coding Agent permissions, and billing apply. See [Access and billing](/code/access-and-billing). * The curl examples read the key from `CODERABBIT_API_KEY` and the API host from `CODERABBIT_API_HOST`; [Set up your shell](/api/quickstart#set-up-your-shell) sets both. The CLI has no dedicated commands for these operations; the CLI examples call them through [`coderabbit api request`](/api/cli). To work with tasks interactively in a terminal, use [`cr code`](/cli/cloud-tasks) instead. * On the [hosted MCP server](/api/mcp), every operation on this page is a tool with the same name as its operation ID, such as `create_code_task`. Reads need the `code:read` scope and changes need `code:write`. ## 1. Create a task [Create a task](/api/reference/create-code-task) with a JSON body. Save it as `task.json`: ```json task.json theme={null} { "repository_id": "123456789", "branch": "main", "instructions": "Add a regression test for the pagination bug in src/list.ts.", "mode": "plan", "client_request_id": "pagination-test-2026-11-10" } ``` Set `mode` to `plan` to get a plan to review first; without it, the agent changes code directly. See [Code mode and Plan mode](/code#code-mode-and-plan-mode). `client_request_id` is required: give each new task its own, and a retry with the same ID returns the task already created, as [Retry safely](#retry-safely) explains. [Create a task](/api/reference/create-code-task) lists every field and its limits. ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/code/tasks" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data @task.json ``` ```bash CLI theme={null} coderabbit api request /code/tasks --input task.json ``` The response holds the `task` and `created`, which is `false` when the `client_request_id` matched a task you already created. Save `task.task_id`; the examples below read it from `TASK_ID`. Creating a task never pushes code: the work ends as a proposed patch that you deliver in [step 6](#6-deliver-the-patch). ## 2. Follow the task Poll [Get a task](/api/reference/get-code-task) to see where the task is. ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID" ``` `status` tells you what the task needs next. These values need your attention: | `status` | What to do | | - | - | | `plan_ready` | A plan is ready. Read it in [step 3](#3-read-the-plan). | | `patch_ready` | A proposed patch is ready. Review and deliver it in [step 6](#6-deliver-the-patch). | | `conflicts_detected` | Delivery hit a conflict. See [Resolve delivery conflicts](/code/deliver-changes#resolve-delivery-conflicts). | | `completed`, `no_file_changes` | The work finished. `pull_request_url` links to the pull request when the task delivered one. | | `failed`, `canceled`, `rejected` | The latest turn failed, was stopped, or had its patch rejected. Read the turn to see why. | | `stale` | The task is out of date with the branch it was created against. | While work is in progress, `status` is `queued`, `running`, `revising`, `applying`, or `resolving_conflicts`. A polling loop stops at `plan_ready`, `patch_ready`, and `conflicts_detected`, which wait for you, and at the final states `completed`, `no_file_changes`, `failed`, `canceled`, `rejected`, and `stale`. A question from the agent doesn't change the task's `status`: while it is `running`, also read the latest turn, and when its `waiting_for_interaction_id` is set, [answer the question](#answer-a-question) before you poll again. Poll every 10 seconds or less often; [Get a task](/api/reference/get-code-task) has its own budget under [rate limits](/api/conventions#rate-limits). `plan_version` is `null` until the task has a plan. [Follow the work](/code/work-with-a-task#follow-the-work) explains the states as the app shows them. Each instruction the agent works on is a turn. [List turns](/api/reference/list-code-task-turns) returns the newest 20 turns, oldest first. For older turns, pass `next_before_turn_start_seq` as `before_turn_start_seq`. To read what the agent said at the end of a turn, call [Get a turn](/api/reference/get-code-task-turn) with its `start_seq`: ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/turns/$TURN_START_SEQ" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID/turns/$TURN_START_SEQ" ``` A turn's `status` is `running`, `patch_ready`, `completed`, `canceled`, or `failed`. For a `completed` or `patch_ready` turn, `result.text` holds the agent's final reply. `result` is `null` while the turn runs or when no final reply was kept. A `failed` turn has a general `error.message`; open the task in the app for details. Old turns eventually return `404 not_found`. ### Answer a question When the agent needs your input, the turn's `waiting_for_interaction_id` is set. [List questions](/api/reference/list-code-task-questions) and find the entry whose `question.interactionId` matches it. Each item in `question.questions` has an `id`, the `question` text, and sometimes `options` to choose from. Answer with [Answer a question](/api/reference/answer-code-task-question). `client_operation_id` must be a UUID, and `answers` maps each question `id` to your answers: ```json answer.json theme={null} { "client_operation_id": "6f1c2d4e-8a9b-4c3d-9e2f-1a2b3c4d5e6f", "answers": { "QUESTION_ID": { "answers": ["Keep the current retry behavior"] } } } ``` ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/questions/$INTERACTION_ID/answers" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data @answer.json ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID/questions/$INTERACTION_ID/answers" --input answer.json ``` The response's `result` is `accepted`, `duplicate`, `deferred`, or `rejected`, with a `reason` when it has one. Prompts that ask for permission to use the owner's personal connections, or ask how to deliver the work, return `412 precondition_failed`; answer those on the task page in the app. ### Send a follow-up or stop a turn * To give the agent another instruction, [send a follow-up](/api/reference/create-code-task-turn) with `message` and a `client_operation_id`. CodeRabbit queues it and runs it as a new turn; [Get the queue](/api/reference/get-code-task-queue) shows messages still waiting. * To stop the running turn, [stop the task](/api/reference/cancel-code-task-turn), optionally with a `reason`. It works like **Stop** on the task page, including what happens to queued messages; see [Stop a task](/code/work-with-a-task#stop-a-task). It doesn't stop CodeRabbit reviews. Both calls return `202` when CodeRabbit accepts them. Keep polling the task for the result. ## 3. Read the plan In plan mode, the task stops at `plan_ready` with a `plan_version`. [Get the plan](/api/reference/get-code-task-plan) for that version: ```bash curl theme={null} curl --get "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/plan" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "version=$PLAN_VERSION" \ --output plan.json ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID/plan?version=$PLAN_VERSION" > plan.json ``` `PLAN_VERSION` is the task's `plan_version`. The response has the plan's `markdown`, its `approvals`, and the `version` and `sha256` that identify this exact plan. Every revision creates a new version. Feedback and approval calls take both `version` and `sha256`, and return `409 conflict` when they don't match the current plan; read the task and the plan again, then decide how to continue. The examples below read the hash from `PLAN_SHA256`: ```bash theme={null} PLAN_SHA256=$(jq -r '.sha256' plan.json) ``` ## 4. Work with plan feedback People start feedback threads by selecting plan text on the task page; the API can't start a thread, but it can reply to, resolve, and reopen the threads that exist. A script that wants to send feedback shouldn't wait for a thread: [revise the plan](#5-approve-revise-or-implement-the-plan) with a `message`, which needs no thread. [List plan feedback](/api/reference/list-code-task-plan-comments) returns the open and resolved threads for one plan version, without deleted comments: ```bash curl theme={null} curl --get "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/plan/comments" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "version=$PLAN_VERSION" \ --data-urlencode "sha256=$PLAN_SHA256" ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID/plan/comments?version=$PLAN_VERSION&sha256=$PLAN_SHA256" ``` Each thread has an `id`, a `status` of `open` or `resolved`, a `location.quote` with the plan text it's about, and its `comments`, each with its own `id`, `text`, and `author`. Thread actions use the thread `id`; editing and deleting use the comment `id`: | Action | Operation | Path ID | Body | | - | - | - | - | | Reply | [Reply to a thread](/api/reference/reply-code-task-plan-comment-thread) | Thread | `version`, `sha256`, `text` | | Resolve | [Resolve a thread](/api/reference/resolve-code-task-plan-comment-thread) | Thread | `version`, `sha256` | | Reopen | [Reopen a thread](/api/reference/reopen-code-task-plan-comment-thread) | Thread | `version`, `sha256` | | Replace your comment | [Replace a comment](/api/reference/replace-code-task-plan-comment) | Comment | `version`, `sha256`, the complete new `text` | | Delete your comment | [Delete a comment](/api/reference/delete-code-task-plan-comment) | Comment | None; send `version` and `sha256` as query parameters | For example, to reply to a thread and then resolve it, build both request bodies from `plan.json`, which you saved when you read the plan, then send them: ```bash theme={null} jq --arg text 'Covered in step 3.' '{version, sha256, text: $text}' plan.json > reply.json jq '{version, sha256}' plan.json > plan-version.json ``` ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/plan/comments/threads/$THREAD_ID/replies" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data @reply.json curl "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/plan/comments/threads/$THREAD_ID/resolve" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data @plan-version.json ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID/plan/comments/threads/$THREAD_ID/replies" --input reply.json coderabbit api request "/code/tasks/$TASK_ID/plan/comments/threads/$THREAD_ID/resolve" --input plan-version.json ``` A reply returns `201` with the new `comment_id` and the updated feedback. Keep these rules in mind: * Replying doesn't reopen a resolved thread, and resolving a thread doesn't approve the plan or start implementation. * The API doesn't limit resolving to a thread's author, so a key can resolve threads that other people started. That closes their feedback without their agreement, so a script should resolve only threads it replied to and use Revise for the rest. * Only a comment's author can replace or delete it. A replacement keeps the mentions whose tokens are still in the new text. * Replies have no retry key. If a reply times out, list the feedback before you send it again, so you don't post it twice. > [!CAUTION] > > Deleting the first comment of a thread deletes the whole thread, including other people's replies. Deleting a reply removes only that reply. ## 5. Approve, revise, or implement the plan These calls finish the plan review. They're separate calls: approving a plan doesn't start implementation, and implementing doesn't require an approval. * **Approve.** [Set the plan approval](/api/reference/set-code-task-plan-approval) (`PUT`) with `version`, `sha256`, and `approved: true`. Send `approved: false` to withdraw your approval. The plan's author is the person who created the task: they can't approve their own plan and get `403 forbidden`, so send the approval with another person's key. See [Review a plan](/code/work-with-a-task#review-a-plan). * **Revise.** [Request a revision](/api/reference/revise-code-task-plan) with your feedback as `message` and a `client_operation_id`. When the revision finishes, the task's `plan_version` increases; read the new plan from [step 3](#3-read-the-plan). * **Implement.** [Implement the plan](/api/reference/implement-code-task-plan) with the `version` and a `client_operation_id`. While any feedback thread on that version is open, including a thread a person started, the call returns `409 conflict`; resolve the threads or revise the plan first. CodeRabbit implements each plan version once, so repeating the call for the same version doesn't queue the work twice. Build the bodies from `plan.json`: ```bash theme={null} jq '{version, sha256, approved: true}' plan.json > approval.json jq --arg op "implement-$TASK_ID-$PLAN_VERSION" '{version, client_operation_id: $op}' plan.json > implement.json ``` To approve the plan: ```bash curl theme={null} curl --request PUT "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/plan/approval" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data @approval.json ``` ```bash CLI theme={null} coderabbit api request -X PUT "/code/tasks/$TASK_ID/plan/approval" --input approval.json ``` The response is the plan with its updated `approvals`. To implement it: ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/plan/implementation" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data @implement.json ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID/plan/implementation" --input implement.json ``` Revision and implementation return `202` when CodeRabbit accepts them. Follow the task from [step 2](#2-follow-the-task) until it reaches `plan_ready` again or `patch_ready`. ## 6. Deliver the patch When the task reaches `patch_ready`, read the proposed patch with [Get the patch](/api/reference/get-code-task-patch). `patch.patch` holds the unified diff. `patch` is `null` when the task has no patch, and `preview_status` is `too_large` when the diff is too large to return; review it on the task page instead. Then [deliver the patch](/api/reference/deliver-code-task). `delivery_mode` chooses how it lands: | `delivery_mode` | What happens | | - | - | | `commit_to_pr_branch` | Commits the patch to the branch of the task's pull request. | | `stacked_pr` | Pushes the patch to a new branch and opens a pull request. | Without `delivery_mode`, CodeRabbit commits to the task's pull request when it has one, and opens a new pull request otherwise. A new pull request opens against the task's working branch, as [Deliver a task's changes](/code/deliver-changes#choose-how-changes-land) explains, and the API has no field for its title or body. That page also covers both modes and who the commits are attributed to. ```bash theme={null} echo '{"delivery_mode": "stacked_pr"}' > delivery.json ``` ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID/delivery" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data @delivery.json ``` ```bash CLI theme={null} coderabbit api request "/code/tasks/$TASK_ID/delivery" --input delivery.json ``` A `202` response means CodeRabbit accepted the delivery. Poll the task until `pull_request_url` is set or `status` reports a problem. Delivery pushes with the key owner's own GitHub authorization, which they connect in the CodeRabbit app. If it's missing or expired, delivery returns `401 unauthenticated` even though the API key is valid; reconnect GitHub in the app and deliver again. Branch protections still apply; see [When delivery is blocked](/code/deliver-changes#when-delivery-is-blocked). Delivery has no retry key. If a request times out, read the task and the pull request before you send it again. ## 7. Turn on Autofix [Autofix](/code/deliver-changes#autofix) publishes a task's work and keeps fixing review findings, failing checks, and merge conflicts on its pull request. [Get Autofix status](/api/reference/get-code-autofix) takes a `target`, either a task or a pull request: ```bash curl theme={null} curl --get "$CODERABBIT_API_HOST/v1/code/autofix" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "target[type]=task" \ --data-urlencode "target[taskId]=$TASK_ID" ``` ```bash CLI theme={null} coderabbit api request "/code/autofix?target[type]=task&target[taskId]=$TASK_ID" ``` For a pull request, use `target[type]=pull_request` with `target[repoId]` and `target[prNumber]`. The response says whether Autofix is `available` for the target. `watch` is `null` when Autofix isn't set up for the target; otherwise it reports `enabled`, `state`, `prUrl`, and a `reason` when there is one. To change it, [send an Autofix command](/api/reference/set-code-autofix) with the same `target` and an `action`: `enable`, `disable`, `resume`, or `recover`. `recover` also takes the `deliveryConflict` object from the status response. ```json autofix.json theme={null} { "target": { "type": "task", "taskId": "TASK_ID" }, "action": "enable" } ``` > [!WARNING] > > Enabling Autofix authorizes CodeRabbit to publish changes and follow-up fixes without approving each patch. Repository permissions and branch protections still apply. ## 8. Request a review of the delivered pull request When delivery sets `pull_request_url` (for example `https://github.com/acme/api/pull/42`), the pull request number is its last path segment, and the repository ID is the task's `repository_id`. Read both from [Get a task](/api/reference/get-code-task): ```bash theme={null} TASK=$(curl -sS "$CODERABBIT_API_HOST/v1/code/tasks/$TASK_ID" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY") REPOSITORY_ID=$(jq -r '.repository_id' <<<"$TASK") PR_NUMBER=$(jq -r '.pull_request_url | split("/") | last' <<<"$TASK") ``` Read the [review status](/api/guides/pull-request-reviews#4-follow-the-review-status) of that pull request first, and request a review only when the current head has none running or completed. A review request needs an agentic key; see [Authentication](/api/authentication#which-keys-each-operation-accepts). ```bash theme={null} curl "$CODERABBIT_API_HOST/v1/repositories/$REPOSITORY_ID/pull-requests/$PR_NUMBER/review" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data '{}' ``` The [pull request reviews guide](/api/guides/pull-request-reviews#3-request-a-review) covers the request, the status values, and what to do when `review` is `null`. ## Run it unattended One agentic key can run every step of this flow. Approving a plan is the exception for tasks the key's own owner created, and a few steps need a person or the app: | Step | Key | | - | - | | Create, follow, read the plan, send plan feedback, revise, implement, read the patch, deliver, Autofix | User or agentic key, acting as its owner | | Approve the plan | User or agentic key owned by an account other than the task's creator, with access to the task | | Request a review of the pull request | Agentic key | Give the bot its own account as the key owner. An agentic key's owner needs a seat, and delivery uses that account's GitHub authorization, so the pull requests and commits are attributed to it; see [Who pushes, and who wrote it](/code/deliver-changes#who-pushes-and-who-wrote-it). Leave `is_private` unset on tasks that another account must approve, because a private task is visible only to its author. * **Feedback threads on a plan start in the app.** The API can reply to, resolve, and reopen threads, but can't start one. To send feedback from a script, revise the plan with a `message`. List the feedback before you act on it. * **Approval needs a second account.** The plan's author is the account that created the task, so a bot can't approve the plans of tasks it created; a key owned by another account, such as a second bot, can. Implementation doesn't check for an approval; if your process requires one, read the plan's `approvals` before you implement. * **Delivery needs the key owner's GitHub authorization.** The key's owner connects GitHub in the CodeRabbit app, and CodeRabbit renews that authorization on its own. The API can't connect it: when it's missing or GitHub no longer accepts it, delivery returns `401 unauthenticated` until the owner reconnects GitHub in the app, so alert a person instead of retrying. * **Some questions need the app.** Questions about the owner's personal connections or how to deliver the work return `412 precondition_failed`; a person answers them on the task page. See [Answer a question](#answer-a-question). * **No webhooks.** The API doesn't notify you when a task changes. Poll [Get a task](/api/reference/get-code-task), and stay within your [rate limit](/api/conventions#rate-limits). * **No lookup by `client_request_id`.** Tasks don't return it, and [List tasks](/api/reference/list-code-tasks) can't filter by it. To find a task after a crash, send the same create request again. * **No GitHub issue link, and no pull request title or body.** A task has no field for a GitHub issue, and delivery takes only `delivery_mode`, so the pull request can't say `Fixes #123`. Put everything the agent needs from the issue in `instructions`, and edit the pull request on GitHub afterward. ## Retry safely Some calls take a key that makes a retry safe; others need a read first. | Call | How to retry | | - | - | | Create a task | Send the same `client_request_id`. You get the task already created, with `created: false`. | | Follow-up, plan revision, implementation, answer | Send the same `client_operation_id`. CodeRabbit accepts the operation once. | | Approve or withdraw approval | Send it again. A repeat leaves your approval as it is. | | Resolve or reopen a thread | Send it again. The thread ends in the state you asked for. | | Reply to plan feedback, deliver | No retry key. Read the feedback, or the task and its pull request, before you send the call again. | | Request a review of the task's pull request | No retry key, and each request starts a review like a new push. Read the [review status](/api/guides/pull-request-reviews#4-follow-the-review-status) first, and request again only when no review of the current head is running or completed. | CodeRabbit remembers a `client_request_id` for as long as the task exists, archived or not, and matches it per key owner and repository. It doesn't compare the rest of the body, so the same ID with new instructions returns the first task. Use a new ID for each new task, for example by adding an attempt number. ## Handle errors All errors use the error format described in [Errors](/api/conventions#errors). Error messages are generic, so use the status and the step you were on to find the cause: | Response | Likely cause in this flow | | - | - | | `400 invalid_request` | The request body doesn't match the schema, or the task was started by an Automation, which these operations don't manage. | | `401 unauthenticated` on delivery | The key owner's GitHub authorization for delivery is missing or expired. | | `403 forbidden` | Coding Agent isn't enabled for the organization, the key owner can't change this task, or the task's creator tried to approve its plan. | | `insufficient_scope` (MCP) | The MCP connection lacks the scope that the error names, such as `code:write`. Add it; see [MCP troubleshooting](/api/mcp#troubleshooting). | | `404 not_found` | The task doesn't exist or isn't visible to the key owner, or a turn is too old to read. | | `409 conflict` | `version` and `sha256` don't match the current plan, or a feedback thread is still open when you implement. | | `412 precondition_failed` | The prompt has to be answered in the app, or billing doesn't allow new Coding Agent work. | ## What's next > [card] [Request and read reviews](/api/guides/pull-request-reviews) > > Request a CodeRabbit review of the pull request your task opened and read the results. > [card] [Work with a running task](/code/work-with-a-task) > > See how the same task looks on its task page, where people can steer it and review its plan. > [card] [Connect an MCP client](/api/mcp) > > Connect an AI agent to CodeRabbit and call these operations as MCP tools. # Manage Learnings with the API Source: https://docs.coderabbit.ai/api/guides/learnings Choose between the organization Learnings operations and the Knowledge Base Learnings operations, then list, export, create, update, and delete Learnings with the CodeRabbit API. [Learnings](/knowledge-base/learnings) are the review preferences CodeRabbit saves from your team's feedback. The API has two sets of operations for them. Both work on your organization's Learnings; they differ in what they can do and which keys they accept. ## Before you start * See [Authentication](/api/authentication#which-keys-each-operation-accepts) for the keys each operation family accepts and [Conventions](/api/conventions) for base URLs, pagination, errors, and rate limits. * The curl examples read the key from `CODERABBIT_API_KEY`. The CLI examples use the [`coderabbit api` command](/api/cli) with a key file. ## Choose an operation set | | Organization Learnings | Knowledge Base Learnings | | - | - | - | | Path | `/v1/learnings` | `/v1/knowledge/learnings` | | Operations | List (JSON or CSV), update, delete | List, read, create, update, delete, statistics, filter values, full download | | Formats | JSON pages or a CSV file | JSON | | Organizations | Enterprise organizations on every Git provider, including self-hosted CodeRabbit | GitHub Cloud organizations | | Operation family | [Export and user-management operations](/api/authentication#which-keys-each-operation-accepts) | [Product operations](/api/authentication#which-keys-each-operation-accepts) | | Hosted MCP | Not available | Each operation is an MCP tool with the same name | Use the organization Learnings operations to: * Export Learnings to CSV. * Read the Learnings of every organization in an SSO workspace at once with a workspace API token. * Work with GitLab, Bitbucket, Azure DevOps, or self-hosted CodeRabbit. Use the Knowledge Base Learnings operations to: * Create Learnings. * Read usage statistics or the values you can filter by. * Work through the [MCP server](/api/mcp). ## List and export organization Learnings 1. Call [List learnings for an organization](/api/reference/learnings-list). Its reference lists the filters: text search, file paths, repositories, authors, and recent use. ```bash curl theme={null} curl --get "https://api.coderabbit.ai/v1/learnings" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "stat_filter=never_used" \ --data-urlencode "limit=500" ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key request '/learnings?stat_filter=never_used&limit=500' ``` 2. While `next_cursor` isn't `null`, request the next page with `cursor` set to that value and the same filters. Results come newest first, up to 1,000 per page. 3. To download a file instead, add `format=csv`. The CSV columns match the JSON fields. A CSV response holds a single page of up to `limit` rows and has no cursor, so use JSON when you expect more rows than `limit`. The CLI prints JSON only; download CSV with curl. A response larger than 16 MiB returns `413`; add filters or lower `limit`. With a workspace token, `org_id` selects one organization; without it, the response covers every organization in the workspace. > [!WARNING] > > Filter by repository with `repository_ids` only. The operation ignores query parameters it doesn't know, so a misspelled filter, or `repository_id` in the singular, returns a broader set of Learnings instead of an error. ## Update or delete organization Learnings 1. Take the Learning's `id` from the list. 2. Call [Update a learning](/api/reference/learnings-update) (`PATCH /v1/learnings/{learning_id}`) with the new text in `learning`. With a workspace token, also send `org_id`. CodeRabbit trims the text and redacts recognized credentials before saving it. A `204` response means the update is saved. The CLI example reads the same body from `learning.json`. ```bash curl theme={null} curl "https://api.coderabbit.ai/v1/learnings/$LEARNING_ID" \ --request PATCH \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data '{"learning": "Prefer early returns over nested conditionals in request handlers."}' ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key request -X PATCH "/learnings/$LEARNING_ID" --input learning.json ``` 3. To remove a Learning, call [Delete a learning](/api/reference/learnings-delete) (`DELETE /v1/learnings/{learning_id}`), with `org_id` in the query for a workspace token. Deletion is idempotent: it returns `204` even when the Learning is already gone, so a retry is safe. The key owner needs the `learning:write` permission, which the **Read and Write** level of the Learnings permission grants. If an update returns `500`, send the same request again. ## Create Learnings in the Knowledge Base 1. Call [Save Learnings](/api/reference/create-learnings) with a `learnings` array. Each item needs `repoOwner`, `repoName`, `learning`, and `user`. Add `file`, `startLine`, `endLine`, `pullRequest`, or `url` to tie the Learning to code. The CLI example reads the same body from `learnings.json`. ```bash curl theme={null} curl "https://api.coderabbit.ai/v1/knowledge/learnings" \ --request POST \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data '{ "learnings": [ { "repoOwner": "acme", "repoName": "backend", "learning": "Use the shared retry helper for outbound HTTP calls.", "user": "jane", "file": "src/http/client.ts" } ] }' ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key request /knowledge/learnings --input learnings.json ``` 2. Read `learning_ids` in the response. Saving can create new Learnings or update matching ones, so an ID can belong to a Learning you saved before. If `learning_ids` is `null`, don't send the request again to find the IDs; [list the Learnings](#find-and-analyze-knowledge-base-learnings) instead. 3. Read a Learning with [Read a saved Learning](/api/reference/get-learning), change its text with [Update a Learning](/api/reference/update-learning) (`PATCH /v1/knowledge/learnings/{learning_id}`), or remove it with [Delete a Learning](/api/reference/delete-learning) (`DELETE /v1/knowledge/learnings/{learning_id}`). ## Find and analyze Knowledge Base Learnings * [List saved Learnings](/api/reference/list-learnings) returns numbered pages of up to 100 Learnings, sorted and filtered the way the **Learnings** page in the app does. * [Read available Learning filters](/api/reference/get-learning-filters) returns the repository names, files, and users you can filter by. * [Read recorded Learning usage statistics](/api/reference/get-learning-statistics) returns four counts for the filters you pass: all Learnings, active Learnings, Learnings never used, and Learnings created this week. * [Export saved Learnings](/api/reference/export-learnings) returns every matching Learning in one JSON response, without paging. `usage_count` and `last_used` reflect the usage CodeRabbit recorded. Treat them as best effort, not as proof that a Learning was or wasn't applied. The key owner's Learnings permissions apply to every operation. For errors and paging details, see [Errors](/api/conventions#errors) and [Pagination](/api/conventions#pagination). ## What's next > [card] [Learnings](/knowledge-base/learnings) > > Learn how CodeRabbit records Learnings, applies them in reviews, and scopes them to repositories. > [card] [Connect an MCP client](/api/mcp) > > Connect an MCP client to manage Learnings with the same operations as tools. > [card] [Review instructions](/configuration/path-instructions) > > Write lasting path-based review rules when a Learning isn't the right fit. # Export metrics, read usage, and schedule reports Source: https://docs.coderabbit.ai/api/guides/metrics-and-usage Export review metrics as JSON or CSV, read review comment and MCP server usage metrics, check usage, credits, and usage budgets, and schedule reports with the CodeRabbit API. Feed CodeRabbit review data into your analytics tools, watch spend, and schedule reports from code. ## Before you start * See [Authentication](/api/authentication#which-keys-each-operation-accepts) for the keys each operation accepts and [Conventions](/api/conventions) for base URLs, pagination, errors, and rate limits. The metrics exports are export and user-management operations, and they need the Enterprise plan. The usage, credit, budget, and report operations are product operations, which follow each feature's access rules: reports, for example, follow your plan's reporting access. See [Plans](/api#plans). * The curl examples read the key from `CODERABBIT_API_KEY`. The CLI examples use the [`coderabbit api` command](/api/cli) with a key file. ## Retry busy metrics requests When a metrics request returns `429` or `503`, wait at least the `Retry-After` interval. Then send the same request again with the same cursor. Don't move to the next cursor after an error. Every page you request counts against the [rate limit](/api/conventions#rate-limits). ## Export review metrics 1. Call [Get PR metrics for organization](/api/reference/review-metrics) with `start_date` and `end_date`. `status` decides whether the dates match merge dates, close dates, or both; merged pull requests are the default. ```bash curl theme={null} curl --get "https://api.coderabbit.ai/v1/metrics/reviews" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "start_date=2026-10-01" \ --data-urlencode "end_date=2026-10-31" ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key request '/metrics/reviews?start_date=2026-10-01&end_date=2026-10-31' ``` 2. To narrow the results, filter by repository or user. With a workspace token, add `org_id` to read one organization; without it, the response covers every organization in the workspace. 3. While `next_cursor` isn't `null`, request the next page with `cursor` set to that value and the same dates and filters. A page holds up to 1,000 pull requests (`limit`). Pages follow the order in which CodeRabbit recorded the data, not merge dates, so a pull request recorded late can appear on a later page. Read every page before you treat the data as complete. ### Download review metrics as CSV Add `format=csv` to download a file with one row per pull request. The nested `coderabbit_comments` object becomes flat columns, such as `total_coderabbit_comments_posted` and `critical_comments_accepted`, and the `status` and `review_iterations` columns follow `merged_at`. [Data Export](/guides/data-export#exported-fields) describes the other columns. ```bash theme={null} curl --get "https://api.coderabbit.ai/v1/metrics/reviews" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "start_date=2026-10-01" \ --data-urlencode "end_date=2026-10-31" \ --data-urlencode "format=csv" \ --output review-metrics.csv ``` A CSV response holds a single page of up to `limit` rows and has no cursor. If the file has as many rows as `limit`, split the date range into smaller windows, or use JSON. A file larger than 16 MiB returns `400 RESPONSE_TOO_LARGE`; shorten the date range or add filters. The CLI prints JSON only, so download CSV with curl. ## Read review comment metrics Call [Get review comment metrics for merged pull requests](/api/reference/review-comment-metrics) for finding-level data, such as trends by severity or category. Use review metrics for per-pull-request totals. * The dates select pull requests by merge date in UTC, whenever their comments were posted. * Each nested comment entry is one finding. A comment URL can appear more than once when a comment holds several findings. Comment text isn't returned. * The response is JSON only. Sending `format` or `status` returns `400`. * `limit` counts pull requests, not comments. A page larger than 16 MiB returns `413`. One pull request's comments can't span pages, so lower `limit` or shorten the date range. Self-hosted CodeRabbit can use this operation when it's configured to send metrics to CodeRabbit Cloud. ## Read MCP server usage [Get MCP server usage by pull request](/api/reference/mcp-metrics) measures how CodeRabbit used the MCP servers you [connected to CodeRabbit](/connections/mcp-servers) for review context. It has nothing to do with the CodeRabbit [MCP server](/api/mcp) that your own clients connect to. Each row is a merged, reviewed pull request that used MCP, with its servers and their tools nested. Join rows to review metrics on `pr_url`. The counts are best-effort usage telemetry. ## Check usage and credits 1. Call [Read current usage and permitted credit balances](/api/reference/get-usage). It returns usage billing settings for the billing period, the review spending cap, the key owner's own usage in `callerUsage`, and the credit balances the key owner can see. ```bash theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key request /usage ``` 2. Check the `state` of each section. An `available` section holds values. An `unavailable` section has a `reason`, such as `forbidden` or `not_supported`; treat its values as unknown, not zero. `callerUsage` counts only the reviews, spend, and waived amounts of the person who owns the key. For everyone's spend in the period, read `spent_cents` from the [usage budget](#read-usage-budgets). [Read permitted credit balances](/api/reference/get-credits) returns only the credit balances. Credit balances and usage budgets need the key owner's role to include read access to **Subscription and Billing**, which Admins have; see [Role-based access](/management/roles). Without it, the credit sections come back `unavailable` with the reason `forbidden`. These reads don't give the caller permission to spend. ## Read usage budgets [Read current usage budget policy and consumption](/api/reference/get-usage-budget) returns the budget's `status`, the default limit per member, when enforcement starts, the current period, and `spent_cents`, the workspace's total spend for the period. `spent_cents` is `null` unless the budget is active. `member_usage_complete` is `false` when part of the spend can't be attributed to a member. [Read paginated member usage budgets](/api/reference/list-usage-budget-members) returns each member's spend, effective limit, and whether the member has an override, paged with `page` and `page_size`. The API reads budgets only; change them in the CodeRabbit app. Amounts in the usage, credit, and budget responses are in US cents. ## Schedule reports The Reports operations manage the same reports as the CodeRabbit app. 1. Call [Create an on-demand or scheduled report](/api/reference/create-report). Set `type` to `WEEKLY` (days of the week and a frequency in weeks), `MONTHLY` (days of the month), or `ONDEMAND` (a `from` and `to` range, generated once). Choose where CodeRabbit delivers it with `platform` (`SLACK`, `DISCORD`, `EMAIL`, or `TEAMS`), and set filters, grouping, and a `promptTemplate` or your own `prompt`. 2. Keep the returned `report_id`. It identifies the report configuration; CodeRabbit delivers the generated report to the destination you chose. 3. Manage the report with [Replace a recurring report configuration](/api/reference/update-report) (weekly and monthly reports only), [Enable or disable a report schedule](/api/reference/set-report-status), and [Delete a report configuration](/api/reference/delete-report). [Read a report configuration](/api/reference/get-report) returns the configuration, not report content or delivery status. For filters, grouping, templates, and delivery channels, see [Schedule reports](/guides/scheduled-reports) and [Customize reports](/guides/custom-reports). ## What's next > [card] [Data Export](/guides/data-export) > > Look up what each exported review metrics column means. > [card] [Reports overview](/management/reports) > > Learn what CodeRabbit reports contain and how teams use them. > [card] [Handle responses](/api/conventions) > > Review pagination, error formats, and rate limits shared by every operation. # Review pull requests with the API Source: https://docs.coderabbit.ai/api/guides/pull-request-reviews Find a repository and pull request, request a CodeRabbit review of the current head, follow its status, and read the summary and Change Stack it produced. Use this recipe to start a CodeRabbit review from a script or an agent, wait for it, and read what it produced. ## Before you start * You need an API key for a [GitHub Cloud organization](/api#availability); requesting a review needs an agentic key. See [Authentication](/api/authentication#which-keys-each-operation-accepts) for keys and [Conventions](/api/conventions) for base URLs, pagination, errors, and rate limits. * The curl examples and the Python script read the key from `CODERABBIT_API_KEY` and the API host from `CODERABBIT_API_HOST`, the variables that [Set up your shell](/api/quickstart#set-up-your-shell) sets for your region. The CLI examples use the [`coderabbit api` command](/api/cli). Each step also names its tool on the [hosted MCP server](/api/mcp). * The examples use repository ID `123456789` and pull request `42`. ## 1. Find the repository ID Pull request operations take the repository's numeric GitHub ID, not its name. [List repositories](/api/reference/list-repositories) returns the repositories where CodeRabbit is installed and you have read access on GitHub. ```bash curl theme={null} curl --get "$CODERABBIT_API_HOST/v1/repositories" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "page_size=100" ``` ```bash CLI theme={null} coderabbit api repositories list --page-size 100 ``` Take the `id` of the repository you want. It's GitHub's numeric repository ID, not the `node_id`. The list has no name filter, so to look up a repository by name, filter the response on `full_name`: ```bash theme={null} curl --get "$CODERABBIT_API_HOST/v1/repositories" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "page_size=100" | jq -r '.data[] | select(.full_name == "acme/api") | .id' ``` Trimmed response: ```json Response (trimmed) theme={null} { "data": [ { "id": "123456789", "full_name": "acme/api", "private": true } ], "next_page_token": "eyJ2Ijox" } ``` If the filter prints nothing, the repository isn't on that page: keep following `next_page_token` as described in [Pagination](/api/conventions#pagination). To check a single ID, call [Get a repository](/api/reference/get-repository). MCP tools: `list_repositories`, `get_repository`. ## 2. Find the pull request [List pull requests](/api/reference/list-repository-pull-requests) returns open pull requests. Set `state` for closed or merged pull requests, and `head_branch` to find the pull request for a branch; add `head_owner` to tell forks apart. > [!WARNING] > > Without `author`, the list holds only the pull requests opened by the GitHub account linked to the key's owner (`author=me`). Set `author=all` for every author, or a GitHub login for one person. ```bash curl theme={null} curl --get "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "author=all" \ --data-urlencode "state=open" ``` ```bash CLI theme={null} coderabbit api pull-requests list 123456789 --author all --state open ``` The list comes from a live GitHub search, so it can change between pages. When `coverage.complete` is `false`, `coverage.limitations` says what the search couldn't cover; narrow the filters and search again. To read one pull request, call [Get a pull request](/api/reference/get-repository-pull-request) with the repository ID and the pull request's `number`. The `id` field in pull request responses is GitHub's internal ID and doesn't work in paths. `include` selects the sections to return: `checks` (the default), `threads`, both, or `none`. Review threads default to unresolved threads that CodeRabbit started. Set `thread_author=all`, `thread_state=all`, or `thread_include_outdated=true` to widen that. ```bash curl theme={null} curl --get "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests/42" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "include=threads" \ --data-urlencode "thread_state=all" ``` ```bash CLI theme={null} coderabbit api pull-requests get 123456789 42 --include threads --thread-state all ``` Threads page separately from the rest of the response: pass `threads.next_page_token` as `thread_page_token` with the same filters. If the pull request's head commit moves while you page, the API returns `409 head_changed`; start again without the token. A thread's `replies_complete` is `false` when the response holds only part of the replies. To read the whole discussion, call [List all comments in a pull-request review thread](/api/reference/list-pull-request-review-thread-comments) with the thread's `id`: it returns the root comment and every reply, and pages with its own `page_token`, separate from `thread_page_token`. The `reviews` section shows what GitHub reports. To find out whether CodeRabbit finished reviewing the current head, use the review status in [step 4](#4-follow-the-review-status). MCP tools: `list_pull_requests`, `get_pull_request`, and `list_pull_request_review_thread_comments`. `list_pull_requests` and `get_pull_request` take GitHub URLs instead of a repository ID and pull request number. `list_pull_request_review_thread_comments` takes the repository ID, the pull request number, and the thread's `id`, as the API does. ## 3. Request a review [Request a review](/api/reference/request-pull-request-review) asks CodeRabbit to review the pull request's current head. The pull request must be open. ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests/42/review" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data '{}' ``` ```bash CLI theme={null} coderabbit api request -X POST /repositories/123456789/pull-requests/42/review ``` A `202` response means CodeRabbit accepted the request, not that the review finished. `observed_head_sha` is the pull request's head when you sent the request. CodeRabbit handles the request like a new push to the pull request and reviews whatever the head is when the review starts. The API can't review an older commit or cancel a review. MCP tool: `request_pull_request_review`. The connection needs the `reviews:write` scope; the `review` scope for local reviews doesn't include it. ## 4. Follow the review status [Get review status](/api/reference/get-pull-request-review) returns the pull request's current head and CodeRabbit's latest review status for it. It's the status that [Triage](/triage) shows, but it doesn't depend on anyone using Triage: CodeRabbit records it as pull request events arrive. ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests/42/review" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api pull-requests review-status 123456789 42 ``` ```json Response (trimmed) theme={null} { "head_sha": "9a1d3c7e5b2f4a6c8d0e1f2a3b4c5d6e7f8a9b0c", "review": { "status": "reviewing", "reason": null, "target_commit_sha": "9a1d3c7e5b2f4a6c8d0e1f2a3b4c5d6e7f8a9b0c", "updated_at": "2026-11-10T14:03:12.000Z" } } ``` | `status` | What it means | | - | - | | `pending` | The review hasn't started. When `reason` is set, it says why CodeRabbit is waiting or skipped the review, for example `draft_pull_request` or `automatic_review_disabled`. | | `starting` | CodeRabbit is preparing the review. | | `reviewing` | The review is running. | | `completed` | The review of `target_commit_sha` finished. | | `failed` | The review didn't finish. `reason` can say why. | | `unconfirmed` | A `starting` or `reviewing` review hasn't reported progress recently. It can still be running. | Read the response with these rules: * The current head is reviewed when `status` is `completed` and `target_commit_sha` equals `head_sha`. * `completed` doesn't tell you what CodeRabbit posted. Read the summary in [step 5](#5-read-the-summary) and the review threads from [step 2](#2-find-the-pull-request). * `review: null` means CodeRabbit has no status for the pull request's current commit, for example because it hasn't recorded the pull request yet or because the last status belongs to an older commit. It doesn't prove that no review ran. * `updated_at` is when the status last changed, not when you read it. Poll about once a minute; each call counts toward your [rate limit](/api/conventions#rate-limits). This loop waits until the current head is reviewed or the review fails: ```bash theme={null} while :; do RESPONSE=$(coderabbit api pull-requests review-status 123456789 42) STATUS=$(jq -r '.review.status // "none"' <<<"$RESPONSE") CURRENT=$(jq -r '.review.target_commit_sha == .head_sha' <<<"$RESPONSE") echo "status: $STATUS" if [ "$STATUS" = completed ] && [ "$CURRENT" = true ]; then break; fi if [ "$STATUS" = failed ]; then exit 1; fi sleep 60 done ``` MCP tool: `get_pull_request_review`. ## 5. Read the summary [Get the review summary](/api/reference/get-pull-request-review-summary) returns CodeRabbit's latest summary comment on the pull request, the comment that carries the [walkthrough](/pr-reviews/walkthroughs). `summary.body_markdown` holds its Markdown without the hidden markers, and `summary.source_url` links to the comment on GitHub. ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests/42/review/summary" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api request /repositories/123456789/pull-requests/42/review/summary ``` `summary: null` means CodeRabbit hasn't posted a summary comment. `summary.reviewed_commit_sha` is `null` when the commit the summary describes is unknown, so use [step 4](#4-follow-the-review-status) to check that the review covers the current head. MCP tool: `get_pull_request_review_summary`. ## 6. Read the Change Stack [Get the Change Stack](/api/reference/get-pull-request-change-stack) returns the latest saved [Change Stack](/change-stack) for the pull request: its title and summary, `groups` of ordered `layers`, each layer's files, line ranges, dependencies (`depends_on`), and Mermaid diagrams. The call never builds a Change Stack; `artifact: null` means none is saved. ```bash curl theme={null} curl "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests/42/change-stack" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api request /repositories/123456789/pull-requests/42/change-stack ``` Check these fields of `artifact` before you use it: | Field | What it tells you | | - | - | | `snapshot_id` | The saved version you're reading. Pass it to the layer diff, or back to this call to read the same version again. | | `reviewed_head_sha` | The commit the Change Stack describes. | | `freshness` | `current` when `reviewed_head_sha` is the pull request's head, `outdated` when the head has moved since, and `unknown` when the reviewed commit isn't recorded. | | `coverage` | `unassigned_ranges` and `excluded_files` list changes that no layer covers. | An outdated Change Stack stays readable. See [Snapshots and freshness](/change-stack/snapshots) for how versions relate to the live pull request. MCP tool: `get_pull_request_change_stack`. ## 7. Read a layer's diff [Get a layer's diff](/api/reference/get-pull-request-change-stack-layer-diff) returns unified patches for the files in one layer. Use the `snapshot_id`, the group `id`, and the layer `id` from the same Change Stack response. Layer IDs are unique only within their group. For example, to pick the first layer of the first group: ```bash theme={null} coderabbit api request /repositories/123456789/pull-requests/42/change-stack > change-stack.json SNAPSHOT_ID=$(jq -r '.artifact.snapshot_id' change-stack.json) GROUP_ID=$(jq -r '.artifact.groups[0].id' change-stack.json) LAYER_ID=$(jq -r '.artifact.groups[0].layers[0].id' change-stack.json) ``` ```bash curl theme={null} curl --get "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests/42/change-stack/groups/$GROUP_ID/layers/$LAYER_ID/diff" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "snapshot_id=$SNAPSHOT_ID" ``` ```bash CLI theme={null} coderabbit api request "/repositories/123456789/pull-requests/42/change-stack/groups/$GROUP_ID/layers/$LAYER_ID/diff?snapshot_id=$SNAPSHOT_ID" ``` URL-encode the IDs if they contain reserved characters. Each file in `data` has an `availability`: `available` files carry a `patch`, and `unavailable` files are ones GitHub couldn't supply a patch for, not empty diffs. Add `path` to get one file of the layer. Results page by file, 50 files per page by default. If the snapshot is gone or doesn't record its commits, the call returns `404 not_found`; it doesn't fall back to a newer Change Stack. Read the Change Stack again for a current `snapshot_id`. MCP tool: `get_pull_request_change_stack_layer_diff`. ## Check every open pull request This Python script combines steps 2 and 4: it lists every open pull request in a repository and reports whether CodeRabbit finished reviewing each one's current head, and why not when it hasn't. It needs the [`requests`](https://pypi.org/project/requests/) package and reads the key and host from `CODERABBIT_API_KEY` and `CODERABBIT_API_HOST`. Set `CODERABBIT_API_HOST` to the host of your region, without `/v1`; see [Base URLs and regions](/api/conventions#base-urls-and-regions). ```python check_reviews.py theme={null} import os import time import requests API_HOST = os.environ["CODERABBIT_API_HOST"] REPOSITORY_ID = "123456789" session = requests.Session() session.headers["x-coderabbitai-api-key"] = os.environ["CODERABBIT_API_KEY"] def get(path, params=None): while True: response = session.get(f"{API_HOST}/v1{path}", params=params, timeout=60) if response.status_code == 403: raise SystemExit(f"403 forbidden: {response.text}") if response.status_code != 429: response.raise_for_status() return response.json() time.sleep(int(response.headers.get("Retry-After", "60"))) pulls = f"/repositories/{REPOSITORY_ID}/pull-requests" params = {"author": "all", "state": "open", "page_size": 100} open_pull_requests = {} while True: page = get(pulls, params) open_pull_requests.update((pr["number"], pr) for pr in page["data"]) if page["next_page_token"] is None: break params["page_token"] = page["next_page_token"] for number, pull_request in open_pull_requests.items(): status = get(f"{pulls}/{number}/review") review = status["review"] if review is None: verdict = "no status for the current head (not recorded yet, or the last status is for an older commit)" elif review["status"] == "completed": reviewed = review["target_commit_sha"] == status["head_sha"] verdict = "reviewed" if reviewed else "completed an older commit" elif review["status"] == "failed": verdict = f"failed ({review['reason']})" else: verdict = f"in progress or waiting ({review['status']}, reason: {review['reason']})" print(number, verdict, pull_request["title"], sep=" | ") ``` A `403` stops the script and prints the error, because retrying can't fix a key that the operation doesn't accept. The script collects every page before it reads any status, so page tokens don't expire while it works, and it keys pull requests by number because a live listing can repeat one. Each status read counts toward your [rate limit](/api/conventions#rate-limits): on a repository with many open pull requests, the script pauses at each `429` for the time in `Retry-After`, then sends the same request again. ## Handle errors All errors in this flow use the error format described in [Errors](/api/conventions#errors). The common ones: | Response | Likely cause | What to do | | - | - | - | | `403 forbidden` | The key's type isn't accepted for the operation (a review request needs an agentic key whose owner holds a seat), the key owner's role lacks the permission, or the owner can't access the repository. | Check the key type and its owner's role and access; see [Which keys each operation accepts](/api/authentication#which-keys-each-operation-accepts) and [Errors](/api/conventions#errors) for the codes. | | `insufficient_scope` (MCP) | The MCP connection lacks the scope that the error names, such as `reviews:write`. | Add the scope; see [MCP troubleshooting](/api/mcp#troubleshooting). | | `400 invalid_request` | The pull request isn't open, or a page token expired or doesn't match the request. | Request reviews only for open pull requests. Restart a listing without a page token. | | `404 not_found` | CodeRabbit isn't installed on the repository, you can't read it, the pull request number doesn't exist, or a Change Stack snapshot is gone. | Check the IDs from steps 1 and 2. Read the Change Stack again for a new snapshot. | | `409 head_changed` | The head commit moved while you paged review threads. | Read the pull request again without `thread_page_token`. | | `429 rate_limit_exceeded` | You sent too many requests. | Wait for the time in `Retry-After`, then poll less often. | ## What's next > [card] [Run coding tasks](/api/guides/coding-tasks) > > Create a Coding Agent task, review its plan, and deliver its patch through the API. > [card] [Connect an MCP client](/api/mcp) > > Connect an AI agent to CodeRabbit and call these operations as MCP tools. > [card] [Handle responses](/api/conventions) > > Look up base URLs, pagination, error formats, and rate limits for every operation. # Export and manage security findings Source: https://docs.coderabbit.ai/api/guides/security-findings Export Deep Scan code findings and Bug Scan findings as JSON, CSV, or SARIF, and list, scan, fix, dismiss, and reopen findings with the CodeRabbit Security operations. Send CodeRabbit security findings to your security tools, and triage them from scripts or agents. For what Deep Scan finds and how to read a finding, see [CodeRabbit Security](/security). ## Before you start * See [Authentication](/api/authentication#which-keys-each-operation-accepts) for the keys each operation accepts and [Conventions](/api/conventions) for base URLs, pagination, errors, and rate limits. The Deep Scan and Bug Scan findings exports are export and user-management operations. The other Security operations are product operations. * The curl examples read the key from `CODERABBIT_API_KEY`. The upload steps read SARIF files with `jq`. ## Choose an operation | Task | Operation | Availability | | - | - | - | | Download Deep Scan code findings as JSON, CSV, or SARIF | [Deep Scan code findings](/api/reference/security-scans-code-list) | Every plan and supported Git provider. Needs Security read access. | | Download one repository's Bug Scan findings as JSON, CSV, or SARIF | [Bug Scan findings](/api/reference/bug-scan-findings-list) | Organizations with Bug Scan enabled. Needs the `bug_scan:read` permission. | | List findings, secrets, dependencies, and SBOMs; start scans; request fixes; dismiss and reopen findings | The Security operations under `/v1/security` | GitHub Cloud organizations | ## Export Deep Scan code findings 1. Call [List or download Deep Scan code findings](/api/reference/security-scans-code-list). By default, it returns open findings from the latest completed scan of each repository in the key's scope. Its reference lists the filters for one repository, an earlier scan, and the finding state. With a workspace token, `org_id` selects one organization. ```bash theme={null} curl --get "https://api.coderabbit.ai/v1/security/scans/code" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "repo_id=123456789" \ --data-urlencode "state=all" ``` 2. While `next_cursor` isn't `null`, request the next page with `cursor` set to that value and the same filters. 3. To download the whole inventory instead, add `format=csv` or `format=sarif`. A download holds every finding that matches the filters, up to 50,000 findings and 16 MiB; larger results return `413`, so narrow them with `repo_id` or `scan_id`. The CLI prints JSON only, so download CSV and SARIF with curl. ```bash theme={null} curl --get "https://api.coderabbit.ai/v1/security/scans/code" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "repo_id=123456789" \ --data-urlencode "format=sarif" \ --fail --silent --show-error \ --output deep-scan.sarif ``` Each format carries the explanation and the reachability call stack in a different place: * **JSON:** `description` and the `reachability_call_stack` array. * **CSV:** the `description` column, and the call stack as a JSON-encoded array in the `reachability_call_stack` column. * **SARIF:** `runs[].results[].message.text` for the explanation and `runs[].results[].properties.reachabilityCallStack` for the call stack. An empty call stack means CodeRabbit captured none, not that the finding is unreachable. For a finding's full scan provenance, including evidence, use SARIF: CSV keeps a compact summary, and paged JSON doesn't load evidence. This operation doesn't start scans or change scan billing, and it doesn't need a Security add-on or trial. ### Upload Deep Scan findings to GitHub code scanning Code scanning keeps results per repository and commit, so upload one SARIF file per repository. 1. Get the repository IDs from [List repositories](/api/reference/list-repositories) on GitHub Cloud, or from [List organization repositories](/api/reference/organization-repositories-list) on the Enterprise plan. 2. Download a SARIF file for each repository with `repo_id`. Pause between requests; see [Rate limits](/api/conventions#rate-limits). ```bash theme={null} for repo_id in 123456789 987654321; do curl --get "https://api.coderabbit.ai/v1/security/scans/code" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "repo_id=$repo_id" \ --data-urlencode "format=sarif" \ --fail --silent --show-error --retry 5 \ --output "deep-scan-$repo_id.sarif" \ || echo "Download failed for repository $repo_id" >&2 sleep 6 done ``` `--fail` makes curl report an error response, such as `413` for an export that's too large, instead of saving it as a SARIF file, so only successful downloads leave a file. `--retry` retries a `429` after the `Retry-After` interval. Before you upload, delete the SARIF files of earlier runs, so a failed download can't leave an old file in place. 3. Read the scanned commit from the file. Without `scan_id`, a download holds the repository's latest completed scan, and each result names the scan in `properties.scanProvenance.scanId` and its commit in `properties.scanProvenance.scope.primary.revision`. ```bash theme={null} jq -r '.runs[0].results[0].properties.scanProvenance.scope.primary.revision // empty' deep-scan-123456789.sarif ``` If the command prints nothing, the file has no findings or the scan recorded no commit; skip it. Skipping the upload doesn't replace the previous GitHub analysis, so earlier results can remain visible. If you take the commit from a JSON call instead, pass that row's `scan_provenance.scanId` as `scan_id` when you download, so both describe the same scan even when a newer one completes in between. 4. Upload each file to its repository with the `github/codeql-action/upload-sarif` action. Set `sha` to the scanned commit and `ref` to the full reference of the scanned branch, such as `refs/heads/main`. Otherwise, GitHub attaches the results to the commit of the workflow that uploads them. Deep Scan results carry no `partialFingerprints`, which code scanning uses to recognize the same alert across uploads. The `upload-sarif` action computes them from the source files, so run it in a checkout of the scanned commit. The code scanning REST API doesn't compute them, so uploads through it can create duplicate alerts. GitHub rejects a SARIF file larger than 10 MB after gzip compression. It accepts up to 25,000 results per run and keeps the 5,000 most severe. See [SARIF support for code scanning](https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning) for the other limits. ## Export Bug Scan findings 1. Call [List or download Bug Scan findings](/api/reference/bug-scan-findings-list) with `repo_id`, the repository's Git provider ID. For a Bitbucket Cloud repository, use its UUID in braces. The operation reads the latest completed scan unless you pass `scan_id`, and you can filter by severity. ```bash theme={null} curl --get "https://api.coderabbit.ai/v1/bug-scan/findings" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "repo_id=123456789" \ --data-urlencode "severity=critical" ``` 2. Read `scan` for the scan's `id`, `head_commit`, `completed_at`, and `partial_coverage`. When the repository has no completed scan, `scan` is `null` and `data` is empty. Findings come in the scan's rank order, and each has a `state` of `open`, `fixed`, or `dismissed`. 3. While `next_cursor` isn't `null`, request the next page with `cursor` set to that value. A cursor stays on the scan it came from, even after a newer scan completes. Sending a different `scan_id` with it returns `400 INVALID_CURSOR`. 4. To download every finding of the scan, add `format=csv` or `format=sarif`. Downloads are limited to 50,000 findings and 16 MiB; larger results return `413`, so filter by `severity`. `state` isn't a filter, and sending it returns `400`. With a workspace token, a repository ID that more than one organization holds returns `400 AMBIGUOUS_REPOSITORY`; pass `org_id` to pick the organization. An organization without Bug Scan gets `403 BUG_SCAN_NOT_ENABLED`. `repo_id` is required, so to cover every repository, call the operation once per repository. Take the IDs from [List repositories](/api/reference/list-repositories) or [List organization repositories](/api/reference/organization-repositories-list), as for Deep Scan, and pause between calls. Skip a repository whose `scan` is `null`: it has no completed scan. ### Upload Bug Scan findings to GitHub code scanning A Bug Scan SARIF file names its scan in `runs[0].properties.scanId` and the scanned commit in `runs[0].properties.headCommit`. Read the commit from the file you upload, so it always matches the findings in it: ```bash theme={null} jq -r '.runs[0].properties.headCommit // empty' bug-scan-123456789.sarif ``` If `headCommit` is `null`, the scan recorded no commit; skip the file. If you read `scan.head_commit` from a JSON call instead, pass its `scan.id` as `scan_id` when you download. Upload the file with the `github/codeql-action/upload-sarif` action or the code scanning REST API. Set the commit SHA of the upload to the scanned commit and its `ref` to the full reference of the scanned branch, such as `refs/heads/main`. Otherwise, GitHub attaches the results to the commit of the workflow that uploads them. Each result carries a stable fingerprint in `partialFingerprints`, so code scanning tracks a finding across uploads. GitHub's size limits from the [Deep Scan upload](#upload-deep-scan-findings-to-github-code-scanning) apply too. ## Work with findings through the Security operations These operations work for GitHub Cloud organizations. They use the same access rules as the CodeRabbit app: reading needs Security read access, and starting scans, requesting fixes, and changing a finding's state follow the rules in [Access and billing](/security#access-and-billing). ### List and read findings * [List code and secret findings](/api/reference/list-security-findings) returns vulnerabilities and secrets together. Set `finding_kind` to get only one kind. * [List secret scanner findings](/api/reference/list-security-secret-findings) returns secrets only, with filters for confidence and verification status. * [List vulnerable dependencies](/api/reference/list-security-dependencies) lists dependencies with known advisories. * [Read a code security finding](/api/reference/get-security-finding), [Read a secret finding](/api/reference/get-security-secret-finding), and [Read a dependency and its advisories](/api/reference/get-security-dependency) return one item each. ### Export a software bill of materials [List software bill of materials components](/api/reference/list-security-sbom) pages through components. [Export a software bill of materials](/api/reference/export-security-sbom) downloads it as CycloneDX, SPDX, or CSV. Both can be limited to specific repositories. ### Start a scan 1. Estimate the cost with [Estimate an AI Deep Scan](/api/reference/get-security-scan-quote). Its `fresh` field tells you whether the estimate is current. An estimate doesn't start a scan. 2. Call [Request security scans for installed repositories](/api/reference/start-security-scans) with the repositories, the targets to scan, and the scan mode. A `scan_mode` of `deep` with the `code` target runs a Deep Scan. To cap the spend, set `spend_limit_cents`. 3. Check `results` for each repository. `triggered` means CodeRabbit accepted the scan, not that it finished. `blocked` comes with a `blockedReason` and can include `blockedRetryAfterSeconds`. 4. Follow progress with [List security scan activity](/api/reference/list-security-scans) or [Read a security scan](/api/reference/get-security-scan). When the available Deep Scan credits can't cover a scan, someone with Subscription write access confirms the charge: send `paid_usage_confirmation` with the estimate in `estimateCents` and the credit amount in `creditCents`. Only a Deep Scan can be confirmed this way. For how Deep Scan billing works, see [Deep Scan estimates and billing](/security#deep-scan-estimates-and-billing). ### Fix, dismiss, or reopen a finding * [Request an AI fix for a security finding](/api/reference/fix-security-finding) with the finding's kind in `finding_kind`. A `202` response means CodeRabbit accepted the request, not that the fix is done. To follow the fix and find the resulting task or pull request, read the finding with the reader for its kind: [Read a code security finding](/api/reference/get-security-finding) for a vulnerability, [Read a secret finding](/api/reference/get-security-secret-finding) for a secret, or [Read a dependency and its advisories](/api/reference/get-security-dependency) for a dependency. If you aren't sure whether a fix request went through, read the finding before you send it again. * [Dismiss a security finding](/api/reference/dismiss-security-finding) with the same `finding_kind` values. * [Reopen a code security finding](/api/reference/reopen-security-finding) returns a code finding to the open state. It doesn't apply to secrets or dependencies. For what each action does in the product, see [Triage and remediate findings](/security#triage-and-remediate-findings). ### Read runtime validation results 1. Call [Read runtime validation availability for a finding](/api/reference/get-security-runtime-validation-capability). This call doesn't start a validation. 2. If `available` is `true`, pass its `findingIdentityId` as `finding_identity_id` to [List runtime validation attempts for a finding](/api/reference/list-security-runtime-validations). 3. Read an attempt with [Read a runtime validation result](/api/reference/get-security-runtime-validation). For how CodeRabbit verifies findings at runtime, see [Runtime verification](/security/runtime-verification). ## Handle errors | Response | What to do | | - | - | | `403 KEY_TYPE_FORBIDDEN` | Use a key type the export accepts; see [Which keys each operation accepts](/api/authentication#which-keys-each-operation-accepts). | | `403` when reading findings | Give the key owner Security read access for Deep Scan findings or the `bug_scan:read` permission for Bug Scan findings, and check that the repository is in the key's scope. | | `410` | Replace the key marked **Legacy** with a new API key; those keys can't read findings. | | `413` | Narrow the request with `repo_id`, `scan_id`, or `severity`. | For response formats and other codes, see [Errors](/api/conventions#errors) and [Rate limits](/api/conventions#rate-limits). ## What's next > [card] [CodeRabbit Security](/security) > > Learn how Deep Scan works, what it reports, and how to triage findings in the app. > [card] [Runtime verification](/security/runtime-verification) > > Reproduce Deep Scan findings in a test environment before you fix them. > [card] [Authenticate requests](/api/authentication) > > Pick the API key type each security operation accepts. # Manage users, seats, and roles Source: https://docs.coderabbit.ai/api/guides/users-and-seats List users, assign seats in bulk, set the seat assignment mode, change built-in and custom roles, add self-hosted users, and read audit logs with the CodeRabbit API. Enterprise Plan (This feature is available exclusively as part of the Enterprise plan. Please refer to our pricing page for more information about our plans and features.) Keep CodeRabbit seats and roles in sync with your directory, and pull audit logs into your security tooling. ## Before you start * Your organization is on the Enterprise plan; see [Plans](/api#plans). See [Authentication](/api/authentication#which-keys-each-operation-accepts) for the keys each operation accepts, including [workspace API tokens](/api/workspace-api-tokens) for Enterprise SSO workspaces, and [Conventions](/api/conventions) for base URLs, pagination, errors, and rate limits. * The key owner has the access the task needs: the Admin role to manage seats, set the seat assignment mode, add users, and read audit logs; the `user_management:read` permission to list users; and `user_management:write` to change roles. See [Role-based access](/management/roles). * The curl examples read the key from `CODERABBIT_API_KEY`. The CLI examples use the [`coderabbit api` command](/api/cli) with a key file. Custom role definitions and the role lookup are product operations. Every other operation on this page is an export and user-management operation. ### Which credential does what | Task | Enterprise SSO workspace | Any other organization | | - | - | - | | List users, read audit logs | Workspace API token | User key | | Assign or unassign seats | Workspace API token, with the `members` body | User key | | Change roles | Workspace API token, with `org_id` | User key | | Look up role IDs, create and edit custom roles | Workspace API token, with a GitHub Cloud organization selected, or a user key from one of the workspace's GitHub Cloud organizations | User key | | Set the seat assignment mode, add users | Not available | User key or instance key, self-hosted only | In an SSO workspace, a workspace token covers every task that the API offers. For the general rules, see [Which key for which job](/api/authentication#which-key-for-which-job). ## List users 1. Call [List all users in the organization](/api/reference/list-users). To find who has a seat or a role, filter by seat status or by role. ```bash curl theme={null} curl --get "https://api.coderabbit.ai/v1/users" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "seat_filter=assigned" \ --data-urlencode "limit=100" ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key request '/users?seat_filter=assigned&limit=100' ``` 2. Read the response. `seats_purchased` and `seats_assigned` describe the subscription, and `seat_assignment_mode` shows whether seats are assigned automatically or manually. For each user, `user_id` is the Git provider's user ID, which the seat and role operations expect, and `role` is the user's role ID. 3. While `next_cursor` isn't `null`, request the next page with `cursor` set to that value and the same filters. See [Pagination](/api/conventions#pagination). The list includes only members of your organization by default. Set `membership=non_org` to list outside contributors, such as authors of pull requests on public repositories, or `membership=all` to list both. With a workspace token and no `org_id`, the response has one row per person across the workspace, with each person's linked Git accounts. Add `org_id` to list a single organization of the workspace. ## Assign or unassign seats in bulk > [!WARNING] > > In an Enterprise SSO workspace, use a workspace API token and the `members` body described in [Workspace tokens](#workspace-tokens-and-offboarding). The examples below use `action` and `user_ids`, which a workspace token rejects, and user and agentic keys reject `members`. 1. Collect the Git provider user IDs from `user_id` in the [user list](#list-users). 2. Call [Assign or unassign seats for multiple users](/api/reference/manage-seats) with the `action` to take and the users' IDs in `user_ids`. ```bash curl theme={null} curl "https://api.coderabbit.ai/v1/users/seats" \ --request POST \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data '{"action": "assign", "user_ids": ["121358802", "22605247"]}' ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.config/coderabbit/api-key request /users/seats --input seats.json ``` The CLI reads the body from the file you pass with `--input` and sends a `POST`. 3. Check the result. A `200` response can still report failures for some users. `status` is `success`, `partial_success`, or `failure`, `succeeded` lists the processed IDs, and each `failed` entry has a `code`, such as `SEAT_NOT_AVAILABLE` when no seat is free. Send large batches one after another rather than in parallel. For how seats are counted and released, see [Seat assignment](/management/seat-assignment). ### Workspace tokens and offboarding A workspace token sends a `members` array keyed by email, or by `cr_user_id` for a member without an email. [Manage seats and identities](/management/sso/user-management-api#manage-seats-and-identities) shows the body. A workspace token sets one seat per person for the whole workspace, not one per organization. CodeRabbit keeps the seat on the workspace member and applies it to every linked Git account, so one call changes the seat in all of the workspace's organizations. A Git account that isn't linked to a member keeps its own seat; find it in the workspace user list and send its `cr_user_id`. To take a seat from a leaver, send `"seat_assigned": false` for the member. This works in Automatic mode too: the Automatic and Manual modes control who gets a seat when a pull request opens, and don't block an unassignment through the API. In Automatic mode, the person gets a seat again when one of their linked Git accounts opens a new pull request, as long as a seat is free. If your identity provider provisions members through SCIM, remove the person there instead. SCIM deprovisioning removes the member, their linked Git identities, and their seat. See [SCIM](/management/sso/scim). ## Set the seat assignment mode In `automatic` mode, a person gets a seat when they open a new pull request, as long as a seat is available. In `manual` mode, admins assign seats. [Seat assignment](/management/seat-assignment) describes both modes, including when CodeRabbit releases inactive seats. The API changes the mode only for organizations on self-hosted CodeRabbit or on a self-managed Git provider. Other organizations get `403 SELF_HOSTED_ONLY` and change the mode in the app: an organization admin in **Team Management**, and an Enterprise SSO workspace admin in **Workspace Team Management**, as described in [Enterprise SSO workspaces](/management/seat-assignment#enterprise-sso-workspaces). 1. Read the current mode from `seat_assignment_mode` in the [user list](#list-users). 2. Call [Update the seat assignment mode](/api/reference/update-seat-assignment-mode) with `mode` set to `automatic` or `manual`. ```bash theme={null} curl "https://api.coderabbit.ai/v1/users/seats/assignment" \ --request POST \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data '{"mode": "manual"}' ``` During some trials, the mode can't change and the request returns `400`. ### Seat new joiners before their first pull request In an Enterprise SSO workspace, Automatic mode assigns a seat only when someone opens a pull request. To give a new joiner a seat earlier, for example when your HR system adds them, call [Assign or unassign seats for multiple users](/api/reference/manage-seats) with a workspace token and send their email with `"seat_assigned": true` in `members`. CodeRabbit creates the workspace member when the email is new. To link their Git account in the same request, add it in `identities`. [Manage seats and identities](/management/sso/user-management-api#manage-seats-and-identities) shows the body. ## Change roles 1. Pick the role ID: `cr_admin` for Admin, `cr_member` for Member, or a custom role's UUID. On GitHub Cloud, [List organization roles](/api/reference/list-roles) returns every role ID. It is a product operation, so a workspace token must [select the organization](/api/authentication#select-an-organization). On other platforms, read the `role` field of a user who already has the custom role in the [user list](#list-users). The API can't assign Billing Admin (`cr_billing_admin`) or change the role of a Billing Admin. 2. Call [Change roles for multiple users](/api/reference/change-roles) with `role` and up to 500 Git provider user IDs in `user_ids`. A workspace token also needs [`org_id`](/api/authentication#select-an-organization), the `provider_organization_id` that [List organizations](/api/reference/organizations-list) returns. ```bash theme={null} curl "https://api.coderabbit.ai/v1/users/roles" \ --request POST \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --header "Content-Type: application/json" \ --data '{"role": "cr_admin", "user_ids": ["121358802"]}' ``` With a workspace token, add the organization in `org_id`: ```bash theme={null} curl "https://api.coderabbit.ai/v1/users/roles" \ --request POST \ --header "x-coderabbitai-api-key: $CODERABBIT_WORKSPACE_TOKEN" \ --header "Content-Type: application/json" \ --data '{"role": "cr_admin", "user_ids": ["121358802"], "org_id": "98765432"}' ``` 3. Check `status`, `succeeded`, and `failed`, as for seats. A `CANNOT_CHANGE_BILLING_ADMIN_ROLE` failure marks a Billing Admin. ### Change a role on every organization of a self-hosted instance With a self-hosted instance key, set `org_id` to `ALL`, in any case, to apply the change to every active organization on the instance, or to one organization's ID to change only that organization. CodeRabbit writes each organization separately, so an `ALL` change isn't atomic. A user is listed in `succeeded` only when the change succeeded in every organization. If any organization failed, the user is listed in `failed` with the first error code; send the request again for those users. Other key types that send `ALL` get `400 INVALID_REQUEST`. ## Create and edit custom roles The custom role operations are product operations, so they work for GitHub Cloud organizations; check [which keys they accept](/api/authentication#which-keys-each-operation-accepts). Use a workspace token with one of the workspace's GitHub Cloud organizations [selected](/api/authentication#select-an-organization), or a user key from one of them. A user key's owner needs the Role Management permission in that organization: `role_management:read` to list and read roles, `role_management:write` to create and update them, and `role_management:delete` to delete them. The built-in Admin role has all three. Billing Admin has only read and can't create API keys. A workspace admin who needs this key creates it in an organization where they hold the Admin role. Every organization in a workspace shares the same custom roles. In a workspace with several organizations, such as an Enterprise SSO workspace, create a role once with a key from any of its GitHub Cloud organizations, and the role is available in all of them. You still assign it per organization. 1. Call [List supported role permissions](/api/reference/list-role-permission-options) to get the `resource_ids` and `access_types` (`read`, `write`, `delete`) a role can hold. 2. Call [Create a custom role](/api/reference/create-role) with `name`, an optional `description`, and an optional `duplicate_from`, the ID of the role to copy. This operation doesn't accept permissions. The response returns the new role with its ID in `role`. 3. Call [Update a custom role](/api/reference/update-role) with the role's complete `name` and its full `permissions` list, each entry with a `resource_id` and an `access_type`. The list replaces all of the role's permissions. 4. Assign the role to users with [Change roles](#change-roles), once for each organization where they need it. [List organization roles](/api/reference/list-roles) returns role metadata without permissions or member counts; [Read a role and its permissions](/api/reference/get-role) returns one role's permissions. [Delete an unassigned custom role](/api/reference/delete-role) works only when no user has the role. For what each permission controls, see [Custom roles and permissions](/management/custom-roles). ## Add users to a self-hosted organization This operation works only for organizations on self-hosted CodeRabbit or on a self-managed Git provider. 1. Call [Add users and assign seats for a self-hosted organization](/api/reference/add-users) with up to 500 entries in `users`, each with the Git provider `user_id` and `user_name`, and optionally `email` and `name`. 2. Check `status`, `succeeded`, and `failed` for each user. If no seat is free, CodeRabbit can reclaim seats from users who have been inactive for at least 30 days. A repeated `user_id` is processed once, using its first entry. SSO workspaces can't use this operation and get `400 SSO_WORKSPACE_UNSUPPORTED`; use [workspace seat management](/management/sso/user-management-api#manage-seats-and-identities) instead. ## Read audit logs 1. Call [List audit log entries](/api/reference/audit-logs-list), filtered by actor, action, resource type, or date range. Write `date_from` and `date_to` as UTC timestamps that end in `Z`: a date without a time, or a time with an offset such as `+02:00`, returns `400`. ```bash theme={null} curl --get "https://api.coderabbit.ai/v1/audit-logs" \ --header "x-coderabbitai-api-key: $CODERABBIT_API_KEY" \ --data-urlencode "date_from=2026-10-01T00:00:00.000Z" \ --data-urlencode "date_to=2026-10-31T23:59:59.999Z" \ --data-urlencode "actions=create,delete" \ --data-urlencode "page_size=100" ``` 2. Read `data` for the entries and `filter_options` for the values you can filter by. Each entry's `createdAt` is a UTC timestamp. 3. While `pagination.has_next_page` is `true`, increase `page` by one and repeat the request. `page_size` accepts up to 100. The response is JSON only. The operation has no CSV option, and unknown query parameters, including `format`, return `400`. To hand the log to a tool that expects CSV, collect every page and convert the entries. With a workspace token, omit `org_id` to read every organization in the workspace together with workspace-level events. For what CodeRabbit logs, see [Audit Logs](/management/audit-logs). ## Handle errors | Response | What to do | | - | - | | `410 LEGACY_API_KEY` | Replace the key marked **Legacy** with a new API key; those keys can't use these operations. | | `403 SSO_WORKSPACE_ORG_KEY_FORBIDDEN` | Use a workspace API token in an SSO workspace. | | `403 NOT_ADMIN` | Use a key whose owner has the Admin role. | | `403 FORBIDDEN` | Give the key owner's role the permission the operation needs. | | `403 SELF_HOSTED_ONLY` | Change the seat assignment mode in the app, as described in [Set the seat assignment mode](#set-the-seat-assignment-mode). | | `402 NO_ACTIVE_SUBSCRIPTION` | Renew the subscription. | | `429` | Wait for the `Retry-After` interval, then retry. | For response formats and other codes, see [Errors](/api/conventions#errors) and [Rate limits](/api/conventions#rate-limits). ## What's next > [card] [SSO user management API](/management/sso/user-management-api) > > Manage workspace members, seats, and linked Git identities with a workspace API token. > [card] [Seat assignment](/management/seat-assignment) > > Learn how automatic and manual seat assignment work and when seats are released. > [card] [Custom roles and permissions](/management/custom-roles) > > Decide which permissions each custom role grants before you script role changes. # Get started with the CodeRabbit API Source: https://docs.coderabbit.ai/api/index Automate CodeRabbit reviews, coding tasks, scans, and administration over REST, from the CLI, or through the hosted MCP server. The CodeRabbit API lets your scripts, services, and AI agents do what people do in the CodeRabbit app: read review status, start coding tasks, run security scans, manage rules and settings, and export data for reporting and compliance. Requests and responses are JSON over HTTPS, except downloads you ask for in another format, such as CSV and SARIF exports of findings. ## What you can build Each area below matches a group in the API reference. Start with the operation named in the last column. | Area | What you can do | Start with | | - | - | - | | Organizations and repositories | Check which key and organization a request uses, list the repositories you can access, and list the organizations in a workspace. | [Get the authenticated principal](/api/reference/get-me), [list repositories](/api/reference/list-repositories) | | Pull requests and reviews | Read pull requests with their checks and review threads, read CodeRabbit's review status, summary, and Change Stack, and request a review of the current head. | [Read review status](/api/reference/get-pull-request-review), [request a review](/api/reference/request-pull-request-review) | | Coding Agent | Create coding tasks, follow their turns, answer questions, review a task's plan, and deliver patches. | [Create a coding task](/api/reference/create-code-task) | | Coding environments | Manage the environments, repository setup, and variables that coding tasks run with. | [Create a coding environment](/api/reference/create-code-environment) | | Verify | Register repositories and user journeys, start Verify jobs, and read findings and evidence. | [Start a Verify job](/api/reference/start-verify-job) | | Triage | Read Triage changes and teams, set a change's manual priority, and create, preview, and manage Triage rules. | [List Triage changes](/api/reference/list-triage-changes) | | Security | Start scans, read findings, dependencies, SBOMs, and secrets, request fixes, and export Deep Scan and Bug Scan findings. | [List security findings](/api/reference/list-security-findings), [export Deep Scan code findings](/api/reference/security-scans-code-list) | | Knowledge Base | Manage Learnings and connected knowledge repositories, and read architecture knowledge. | [List Learnings](/api/reference/list-learnings) | | Automations | Create, update, run, and pause [CodeRabbit Agent automations](/slack-agent/automations), and read their runs. | [Create an automation](/api/reference/create-automation) | | Reports | Create on-demand and scheduled reports, and manage their schedules. | [Create a report](/api/reference/create-report) | | Configuration | Read and change organization and repository settings, read a repository's effective configuration, and preview a change before you save it. | [Read effective repository configuration](/api/reference/get-effective-repository-configuration) | | Connections | Manage workspace connections and their requests, and discover the tools of an MCP connection. | [List connections](/api/reference/list-connections) | | Users and roles | List users, manage seats and roles, and export audit logs. | [List users](/api/reference/list-users), [export audit logs](/api/reference/audit-logs-list) | | Usage and metrics | Read usage, credits, and budgets, and export review and review comment metrics. | [Read usage](/api/reference/get-usage), [export review metrics](/api/reference/review-metrics) | An operation never grants more than the CodeRabbit app does: each request runs with the permissions of the key's owner, and a product that isn't enabled for your organization stays unavailable through the API. ## Choose how to connect | Client | Use it when | Authenticates with | | - | - | - | | REST | You build a service, dashboard, or integration in any language. Every operation is available. | An API key in the `x-coderabbitai-api-key` header, or a [workspace API token](/api/workspace-api-tokens) in an Enterprise SSO workspace | | [CLI](/api/cli) (`coderabbit api`) | You script CodeRabbit from a shell or a CI job. Dedicated commands cover identity, repositories, and pull requests, and `coderabbit api request` calls any other operation. Output is JSON. | An API key or a workspace API token | | [Hosted MCP server](/api/mcp) | You want an AI agent, such as Claude or Codex, to act in CodeRabbit on your behalf. The server offers most product operations as tools. | OAuth: you sign in and approve access for one organization | The REST API and the CLI share the same keys, base URLs, and responses. The MCP server uses no API key. See [Authentication](/api/authentication) for keys and [Conventions](/api/conventions) for base URLs, pagination, errors, and rate limits. ## Availability ### Plans The API has no plan requirement of its own. What an operation needs depends on its [operation family](/api/authentication#which-keys-each-operation-accepts): * **Product operations**, such as coding tasks, Triage rules, and security scans, follow the access rules of the feature they act on. For example, creating a coding task needs access to Coding Agent, reports follow your plan's reporting access, and administration operations, such as listing organization roles, need the Enterprise plan. * **Export and user-management operations**, such as users, seats, role changes, audit logs, metrics, organization Learnings, and the organization inventory, need the Enterprise plan and return `403 ENTERPRISE_PLAN_REQUIRED` without it. Two exports are exceptions: Deep Scan code findings work on every plan, and Bug Scan findings need Bug Scan enabled for the organization. * **The hosted MCP server** has no plan requirement of its own. Each tool applies the checks of the operation behind it. ### Git platforms and keys * **Git platforms.** Product operations work for GitHub Cloud organizations. Export and user-management operations work on every Git platform CodeRabbit supports. * **Self-hosted.** Organizations on self-hosted CodeRabbit or on a self-managed Git provider, such as GitHub Enterprise Server or GitLab Self-Managed, can use the export and user-management operations with a self-hosted instance key. Product operations aren't available to them and return `404`. * **Keys.** Which operations accept a user key, an agentic key, a workspace API token, or a self-hosted instance key is listed in [Authentication](/api/authentication#which-keys-each-operation-accepts). ## Guides > [card] [Request and read reviews](/api/guides/pull-request-reviews) > > Find a pull request, request a review, and follow it to completion. > [card] [Run coding tasks](/api/guides/coding-tasks) > > Start a coding task, answer its questions, and deliver the patch. > [card] [Manage users, seats, and roles](/api/guides/users-and-seats) > > Automate seat assignment, role changes, and audit log exports. > [card] [Export metrics and usage](/api/guides/metrics-and-usage) > > Export review metrics, track usage and credits, and schedule reports. > [card] [Manage Learnings](/api/guides/learnings) > > Choose the right Learnings operations to export or manage Learnings. > [card] [Export security findings](/api/guides/security-findings) > > Export Deep Scan and Bug Scan findings into your security tools. ## What's next > [card] [Make your first API call](/api/quickstart) > > Create a key, call the API with curl or the CLI, and read a review status. > [card] [Browse the API reference](/api/reference/get-me) > > See every operation's parameters, responses, and errors. # CodeRabbit MCP server Source: https://docs.coderabbit.ai/api/mcp/index Connect Claude Code, Codex, Claude, or another MCP client to CodeRabbit's MCP server so your AI agent can read pull requests and reviews, request reviews, and run coding tasks. GitHub Cloud (The MCP server's product tools are available for GitHub Cloud organizations in CodeRabbit's US region.) The CodeRabbit MCP server turns CodeRabbit into tools for your AI agent. Connect it to Claude Code, Codex, or Claude, and the agent can read your pull requests and CodeRabbit's review threads, check review status, request a review, start and steer coding tasks, and work with Triage, security findings, Verify, automations, reports, Knowledge Base, and settings. The agent acts as you, in the organization you choose, within the permissions you approve. > [!NOTE] > > This page is about your AI agent calling CodeRabbit. It isn't **Connections** in CodeRabbit's settings, where CodeRabbit calls your own MCP servers during reviews and chat. For that, see [Connect MCP servers](/connections/mcp-servers). The CodeRabbit MCP server is also different from the docs MCP server that Mintlify provides for this documentation. The CodeRabbit MCP server acts in CodeRabbit: it reads your pull requests and starts reviews and coding tasks. The docs MCP server only searches these docs, and you add it from the menu at the top of any docs page. If one client uses both, give them different names, such as `coderabbit` for the CodeRabbit MCP server and `coderabbit-docs` for the docs MCP server. The MCP server suits interactive work: your agent acts with your own CodeRabbit account, in one organization, after you sign in through your browser. It doesn't suit unattended jobs, such as CI pipelines or scheduled scripts, because every connection starts with a person signing in. It doesn't suit managing users and seats across an Enterprise SSO workspace either, because each connection reaches one organization. For those jobs, use the API with a key; [Authentication](/api/authentication) says which key fits which job. ## How it works | Property | Value | | - | - | | Server URL | `https://mcp.coderabbit.ai/` | | Transport | Streamable HTTP | | Sign-in | OAuth authorization code flow with PKCE (`S256`) in your browser, with consent per organization. No API key. | | Consent page | `https://app.coderabbit.ai/mcp/connect` | | Clients | Public OAuth clients, registered through dynamic client registration or a client ID metadata document | | Region | US only | | Organization | One per connection, chosen when you approve it | Most tools come from the [CodeRabbit API](/api): an API operation becomes a tool with the same name as its `operationId`, such as `get_me` or `create_code_task`, the operation's summary and description as its title and description, and the same inputs and outputs. Tools run the same permission checks as the API and the CodeRabbit app, so the agent can only do what your role, repository access, and plan already allow. See [MCP tools](/api/mcp/tools) for the full list. ## Availability * **Plan:** the MCP server has no plan requirement of its own. Each tool applies the plan and access checks of the operation behind it; see [Plans](/api#plans). * **Region:** the MCP server serves organizations in CodeRabbit's US region. If your organization is in the EU region, use the [API](/api/conventions#base-urls-and-regions) with an API key, or [`coderabbit api`](/api/cli) from the CLI. * **Git platform:** GitHub Cloud organizations get all the tools in [MCP tools](/api/mcp/tools). You can connect an organization on another Git platform, but only the account tools work there: `connection_status`, `get_me`, and `get_usage`. * **Deployment:** organizations on self-hosted CodeRabbit or on a self-hosted Git provider, such as GitHub Enterprise Server, can't connect. * **GitHub identity:** `list_pull_requests` and `get_pull_request` need a GitHub account linked to your CodeRabbit user. If you sign in to CodeRabbit with GitHub, that account is linked already. In an Enterprise SSO workspace, connect your GitHub account in CodeRabbit or ask an admin to link it; see [How IdP members, Git identities, and seats relate](/management/seat-assignment#how-idp-members-git-identities-and-seats-relate). ## Choose scopes Scopes are the permissions your client asks for when it connects. CodeRabbit's consent page shows them, and the connection gets exactly the scopes you approve. A scope limits what the agent can do; it never grants access you don't already have in CodeRabbit. Decide on scopes before you connect. Every scope list must include `connection`: CodeRabbit refuses a sign-in whose list leaves it out. Claude Code and Codex request only the scopes you configure, and without a setting they request only `connection`, which is enough for `connection_status` and nothing else. ### Common setups | Job | Scopes | Tools the agent calls | | - | - | - | | Check the review status of your pull request and read its summary | `connection account:read repositories:read pull_requests:read` | `list_pull_requests` with `repository_url` and `head_branch`, or `get_pull_request` with the pull request URL. Both return the repository as `owner/name` and the pull request `number`, not the numeric repository ID. Call `list_repositories`, follow `next_page_token`, and take the `id` of the repository whose `full_name` matches. Then call `get_pull_request_review` with that `repository_id` and the `number`, and `get_pull_request_review_summary`. If `review` is `null`, CodeRabbit has no status for the current commit; see [follow the review status](/api/guides/pull-request-reviews#4-follow-the-review-status). Read the summary instead: `summary: null` means CodeRabbit hasn't posted one. | | Request a review after you push | The scopes above, plus `reviews:write` | `get_pull_request_review` first. Each request starts a review like a new push, so request again only when no review of the current head is running or completed. Then `request_pull_request_review` and `get_pull_request_review` to follow the status. The pull request must be open. No API key is involved. | | Read open plan feedback on a coding task | `connection account:read code:read` | `list_code_tasks`, then pick the task whose `pull_request_url` or `title` matches. `get_code_task`, `get_code_task_plan`, and `list_code_task_plan_comments` follow. Keep the threads with `status: open`. | | Work through your Triage queue | `connection account:read triage:read`, plus `triage:write` to set priorities | `list_triage_changes`, `get_triage_change`, and `list_triage_change_history`. With `triage:write`, `set_triage_change_priority` sets a change's manual priority: pass the `priority.revision` from `get_triage_change` as `expected_revision`, and reuse the same `idempotency_key` when you retry. | | Manage Triage rules | `connection account:read triage:read triage:write` | `list_triage_rules`, `preview_triage_rule`, `create_triage_rule`, `update_triage_rule`, and `transition_triage_rule`. | | Explore without changing anything | `connection account:read usage:read repositories:read pull_requests:read`, plus any other read scopes from the table below | `get_me`, `get_usage`, `list_repositories`, `list_pull_requests`, and `get_pull_request`, plus the read tools of the areas you add. | To combine jobs, join their scopes. For one agent that reads your pull request's review, requests a review, and reads plan feedback, use this list: ```text theme={null} connection account:read repositories:read pull_requests:read reviews:write code:read ``` Claude Code takes it space-separated in `oauth.scopes`. Codex takes it comma-separated. To read plan feedback, the agent passes each result to the next call: `get_code_task` returns the task's `plan_version`; `get_code_task_plan` takes it as `version` and returns the plan's `sha256`; `list_code_task_plan_comments` takes `version` and `sha256`. The result has open and resolved threads, so the agent keeps the threads whose `status` is `open`. ### Scopes by area | Area | Read scope | Write scope | What the agent can do | | - | - | - | - | | Connection | `connection` | | Check which account and organization the connection uses. Always include it: a sign-in whose scope list leaves it out fails. | | Account | `account:read` | | Read your profile and organization memberships. Include it in every list: nearly every tool also needs it. | | Usage | `usage:read` | | Read usage and credit balances. | | Repositories | `repositories:read` | | List and read the repositories you can access. | | Pull requests | `pull_requests:read` | `reviews:write` | Read pull requests, discussions, and review state; with the write scope, request reviews. | | Local reviews | | `review` | Start reviews of local code, which the CodeRabbit CLI uploads from your machine. | | Coding tasks | `code:read` | `code:write` | Read coding tasks; with the write scope, create tasks and make code changes through them. | | Triage | `triage:read` | `triage:write` | Read Triage changes and rules; with the write scope, set a change's manual priority and create, change, and delete rules. | | Security | `security:read` | `security:write` | Read security findings; with the write scope, start scans and request fixes. | | Settings, users, and roles | `configuration:read` | `configuration:write` | Read settings, users, roles, and audit logs; with the write scope, change organization and repository settings and manage roles and seats. | | Connections | `connections:read` | `connections:write` | Read the workspace connections in CodeRabbit's settings, such as the MCP servers CodeRabbit calls during reviews and chat; with the write scope, manage them. It isn't about the CodeRabbit MCP server your agent uses. | | Knowledge Base | `knowledge:read` | `knowledge:write` | Read Learnings, connected knowledge repositories, and architecture documents; with the write scope, manage Learnings and connected repositories. | | Reports | `reports:read` | `reports:write` | Read reports; with the write scope, generate and manage them. | | Verify | `verify:read` | `verify:write` | Read Verify jobs and findings; with the write scope, configure Verify and run jobs. | | Automations | `automations:read` | `automations:write` | Read automations and their runs; with the write scope, manage and run them. | A read scope doesn't include its write scope, so request both when the agent reads before it changes something. Triage rule changes need both. Write scopes that start work, such as `review`, `reviews:write`, `code:write`, `security:write`, `verify:write`, `automations:write`, `reports:write`, and `triage:write`, let the agent take actions that can consume credits or paid usage. When a tool needs a scope that your connection lacks, the call fails with `insufficient_scope` and names the missing scope. [MCP tools](/api/mcp/tools#scopes-by-area) lists the scopes for each group of tools. To add a scope later, add it to your client's scope list and sign in again. Keep `connection` in the list. A connection never gains scopes on its own. ## Connect your agent The Claude Code and Codex examples connect with the scopes for exploring without changing anything, from [Common setups](#common-setups). Add the scopes your jobs need before you sign in. > [tab] Claude Code > > 1. Add the server with the scopes you want in `oauth.scopes`. `--scope user` is Claude Code's configuration scope, which makes the server available in all your projects; it isn't a CodeRabbit permission. > > ```bash theme={null} > claude mcp add-json --scope user coderabbit '{"type":"http","url":"https://mcp.coderabbit.ai/","oauth":{"scopes":"connection account:read usage:read repositories:read pull_requests:read"}}' > ``` > > 2. In Claude Code, run `/mcp`, select **coderabbit**, and sign in. You can also run `claude mcp login coderabbit` from your shell. > > 3. Approve the connection in your browser. See [Approve the connection](#approve-the-connection). > > Claude Code requests exactly the scopes in `oauth.scopes`. To change them, run `claude mcp logout coderabbit` and `claude mcp remove coderabbit`, add the server again with the new list, and sign in again. See [Claude Code's MCP documentation](https://code.claude.com/docs/en/mcp) for configuration scopes and project `.mcp.json` files. > [tab] Codex > > 1. Add the server: > > ```bash theme={null} > codex mcp add coderabbit --url https://mcp.coderabbit.ai/ > ``` > > 2. Sign in with the scopes you want, separated by commas: > > ```bash theme={null} > codex mcp login coderabbit --scopes connection,account:read,usage:read,repositories:read,pull_requests:read > ``` > > 3. Approve the connection in your browser. See [Approve the connection](#approve-the-connection). > > In the Codex TUI, run `/mcp` to check that the server is connected. To change scopes, run `codex mcp login` again with the new list. See [Codex's MCP documentation](https://learn.chatgpt.com/docs/extend/mcp?surface=cli) for other configuration options. > [tab] Claude > > These steps add CodeRabbit as a custom connector in Claude on the web and in Claude Desktop. > > 1. Open the connector settings: > * **Pro and Max:** go to **Customize** > **Connectors**, then click **+ Add** > **Add custom connector**. > * **Team and Enterprise:** an owner goes to **Organization settings** > **Connectors**, clicks **Add**, hovers over **Custom**, and selects **Web**. > 2. Enter `CodeRabbit` as the name and `https://mcp.coderabbit.ai/` as the server URL, then click **Continue**. > 3. Under the OAuth client setting, select **Register automatically**. > 4. Click **Add**, then click **Connect** next to the connector. On Team and Enterprise plans, each member connects from **Customize** > **Connectors**. > 5. Check the permissions on the consent page, then approve. See [Approve the connection](#approve-the-connection). > > Claude's connector settings have no scope list, so the consent page shows the scopes that Claude requests. > > See [Claude's custom connector guide](https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp) for plan limits and per-chat settings. > [tab] Other clients > > Other MCP clients can connect if they support Streamable HTTP and OAuth with PKCE, and register either through dynamic client registration or with a client ID metadata document. Add `https://mcp.coderabbit.ai/` as a remote HTTP server, set the client's OAuth scopes if it has that setting, and sign in. See [Approve the connection](#approve-the-connection). > > CodeRabbit gives a sign-in that requests no scopes only `connection`. A client that can't set scopes therefore connects with `connection` alone, and the agent can call `connection_status` and nothing else. The consent page lists what the client requested. ## Approve the connection When your client signs in, your browser opens CodeRabbit. Sign in if you aren't already, then: 1. Choose the organization to connect. The connection works only in this organization, and tool arguments can't switch it. 2. Read the summary under **Allow *client* to access your selected organization?** It lists what the connection can read and do, based on the requested scopes, and warns when actions can consume credits or paid usage. 3. Check the hostname in **Return to *hostname* after connecting.** For a client on your computer, approve only connections you started. 4. Click **Connect to _organization_**, or **Cancel** to refuse. A consent request expires after 10 minutes. Your client refreshes its access automatically, and the connection lasts up to 30 days. It ends sooner if the CodeRabbit browser session you approved it in ends, for example when you sign out, or if you lose access to the organization. Then sign in again from your client. ## Check the connection Ask your agent to call the account tools: ```text theme={null} Use the coderabbit MCP server: call connection_status, then get_me, and tell me which organization and role you see. ``` `connection_status` returns your user ID, the connected organization, and the region. `get_me` needs `account:read` and returns your profile, your role in the connected organization, and your other organization memberships. Memberships don't give the connection access to those organizations. In Claude Code, `claude mcp list` also shows whether the server is connected or needs authentication. ## Disconnect * **Claude Code:** run `claude mcp logout coderabbit` to clear the stored sign-in, then `claude mcp remove coderabbit` to remove the server. * **Claude:** disconnect or remove the connector in **Customize** > **Connectors**. * **Other clients:** use the client's sign-out or remove action. CodeRabbit doesn't list MCP connections in its app, so disconnect from the client. A connection you don't disconnect still ends after 30 days at most. ## Troubleshooting | Problem | Cause | Fix | | - | - | - | | Sign-in fails with `invalid_scope` | The scope list leaves out `connection`, or it has a scope that CodeRabbit doesn't support. | Add `connection`, check the other scopes against [Choose scopes](#choose-scopes), and sign in again. | | The agent can call only `connection_status` | The connection has only the `connection` scope, because the client didn't request any other scopes. | Set the scopes in your client and sign in again. If the client has no scope setting, see the **Other clients** tab in [Connect your agent](#connect-your-agent). | | A tool fails with `insufficient_scope`, or Claude Code says the server needs additional permissions | The connection doesn't have a scope that the tool needs. | Add the scope named in the error to your client's scope list, then sign in again. | | The client reports `401` or says the server needs authentication | The connection ended: it expired, you signed out of CodeRabbit, your access changed, or it was revoked. | Sign in again from your client. | | The consent page says the connection request has ended | You took longer than 10 minutes, or the request was already used. | Start the sign-in again from your client. | | The consent page says connection access was denied | The selected organization can't be connected. | Select another organization in the organization picker. | | Only `connection_status`, `get_me`, and `get_usage` work | The connected organization isn't on GitHub Cloud. | The other tools need a GitHub Cloud organization. Sign in again and choose one. | | `list_pull_requests` or `get_pull_request` returns `unsupported_connection` | Your CodeRabbit user has no linked GitHub account, or the organization isn't on GitHub Cloud. | Link your GitHub account as [Availability](#availability) describes, or connect a GitHub Cloud organization. | | The agent works in the wrong organization | Each connection is bound to the organization you approved. | Disconnect, sign in again, and choose the other organization on the consent page. | | A tool returns `not_found` | The resource doesn't exist, or you can't access it. | Check the identifier and your access in CodeRabbit. | | A tool returns `rate_limit_exceeded` | MCP tools share your organization's API quota with API and CLI requests. | Wait for the `retry_after` seconds in the result. See [Rate limits](/api/conventions#rate-limits). | ## What's next > [card] [Browse MCP tools](/api/mcp/tools) > > Find the tool for each task and the scopes its group needs. > [card] [Call from the CLI](/api/cli) > > Run the same operations from a terminal or CI job with an API key. > [card] [Authenticate requests](/api/authentication) > > Create an API key for scripts and integrations that don't use MCP. # CodeRabbit MCP tools Source: https://docs.coderabbit.ai/api/mcp/tools Every tool the CodeRabbit MCP server offers, the scopes each group of tools needs, and the API operation behind each tool. The [CodeRabbit MCP server](/api/mcp) builds most of its tools from the CodeRabbit API. A tool has the same name as its API operation's `operationId`, and the operation's summary and description as its title and description: `create_code_task` is the tool for [Create a coding task](/api/reference/create-code-task). It takes the operation's path, query, and body fields as one set of arguments, returns the same response, and runs the same permission and plan checks. Leave out `org_id`: the connection already selects the organization. The **Access** column shows the hint each tool gives your client. **Read** marks tools that only read data, which your client sees as read-only. **Write** marks every other tool, including previews that change nothing, such as `preview_triage_rule` and `preview_repository_configuration`. Your client can use the hint to ask you before the agent runs a **Write** tool. ## Scopes by area A tool needs the read scope of its group to read data and the write scope to change it. Every tool except `connection_status`, `list_pull_requests`, `get_pull_request`, `start_code_review`, and `get_code_review` also needs `account:read`, so include it in every scope list. If your connection lacks a scope, the call fails with `insufficient_scope` and names the missing scope; add it in your client and sign in again, as [Choose scopes](/api/mcp#choose-scopes) describes. | Group | Read scope | Write scope | | - | - | - | | Organizations and repositories | `repositories:read` for repositories, `configuration:read` for organizations and linked repositories. `get_me` needs only `account:read`, and `connection_status` only `connection`. | | | Pull requests and reviews | `pull_requests:read`. `get_code_review` needs `review`. | `reviews:write` for `request_pull_request_review`. `start_code_review` needs `review`. | | Coding Agent | `code:read` | `code:write` | | Coding environments | `code:read` | `code:write` | | Verify | `verify:read` | `verify:write` | | Triage | `triage:read`, which is also enough for `preview_triage_rule` | `triage:write` together with `triage:read` | | Security | `security:read` | `security:write` | | Knowledge Base | `knowledge:read` | `knowledge:write` | | Automations | `automations:read` | `automations:write` | | Reports | `reports:read` | `reports:write` | | Configuration | `configuration:read` | `configuration:write` | | Connections | `connections:read` | `connections:write` | | Users and roles | `configuration:read` | `configuration:write` | | Usage and metrics | `usage:read` | | ## Differences from the API Tools marked **MCP only** have no API operation with the same name: * `connection_status` checks the connected account, organization, and region. * `list_pull_requests` and `get_pull_request` find and read pull requests by repository, branch, or pull request URL. They take the place of the [List pull requests](/api/reference/list-repository-pull-requests) and [Get a pull request](/api/reference/get-repository-pull-request) operations, which aren't tools. * `start_code_review` and `get_code_review` run a CodeRabbit review of local code, which the CodeRabbit CLI uploads from your machine. * `list_organizations`, `list_organization_repositories`, `list_linked_repositories`, `list_users`, `manage_seats`, and `list_audit_logs` do the jobs of export and user-management operations such as [List users](/api/reference/list-users) and [List audit log entries](/api/reference/audit-logs-list), in the connected organization only. `manage_seats` takes user IDs and doesn't work in an Enterprise SSO workspace; there, [manage seats with a workspace API token](/api/workspace-api-tokens). These API operations have no tool, so call them through the [API](/api) or the [CLI](/api/cli): * The metrics exports, such as [review metrics](/api/reference/review-metrics). * The organization Learnings operations on `/v1/learnings`. The Knowledge Base tools, such as `list_learnings`, work with Learnings too; see [Learnings](/api/guides/learnings). * The Deep Scan and Bug Scan findings exports. * Adding users to a self-hosted organization, changing roles, and changing the seat assignment mode. * `download_verify_evidence`, which returns a file. The `get_verify_evidence` tool returns the evidence details. ## Tools ### Organizations and repositories | Tool | What it does | Access | REST operation | | - | - | - | - | | `get_me` | Get the authenticated principal and selected organization | Read | [`GET /v1/me`](/api/reference/get-me) | | `list_repositories` | List accessible installed repositories | Read | [`GET /v1/repositories`](/api/reference/list-repositories) | | `get_repository` | Get an accessible installed repository | Read | [`GET /v1/repositories/{repository_id}`](/api/reference/get-repository) | | `connection_status` | Check the connected account and organization. | Read | MCP only | | `list_organizations` | Read the selected organization inventory | Read | MCP only | | `list_organization_repositories` | List onboarded organization repositories | Read | MCP only | | `list_linked_repositories` | List saved linked repository associations | Read | MCP only | ### Pull requests and reviews | Tool | What it does | Access | REST operation | | - | - | - | - | | `get_pull_request_change_stack` | Read a saved Change Stack overview and layers | Read | [`GET /v1/repositories/{repository_id}/pull-requests/{pull_request_number}/change-stack`](/api/reference/get-pull-request-change-stack) | | `get_pull_request_change_stack_layer_diff` | Read one saved Change Stack layer's diff | Read | [`GET /v1/repositories/{repository_id}/pull-requests/{pull_request_number}/change-stack/groups/{group_id}/layers/{layer_id}/diff`](/api/reference/get-pull-request-change-stack-layer-diff) | | `get_pull_request_review` | Read the existing CodeRabbit review status for a pull request | Read | [`GET /v1/repositories/{repository_id}/pull-requests/{pull_request_number}/review`](/api/reference/get-pull-request-review) | | `request_pull_request_review` | Request a review of the current pull-request head | Write | [`POST /v1/repositories/{repository_id}/pull-requests/{pull_request_number}/review`](/api/reference/request-pull-request-review) | | `get_pull_request_review_summary` | Read the full published CodeRabbit summary | Read | [`GET /v1/repositories/{repository_id}/pull-requests/{pull_request_number}/review/summary`](/api/reference/get-pull-request-review-summary) | | `list_pull_request_review_thread_comments` | List all comments in a pull-request review thread | Read | [`GET /v1/repositories/{repository_id}/pull-requests/{pull_request_number}/review-threads/{thread_id}/comments`](/api/reference/list-pull-request-review-thread-comments) | | `list_pull_requests` | Find accessible GitHub Cloud pull requests in the connected organization. | Read | MCP only | | `get_pull_request` | Get a GitHub Cloud PR's metadata, review state and known merge blockers using a linked GitHub account. | Read | MCP only | | `start_code_review` | Authorize one local code review in the connected organization. | Write | MCP only | | `get_code_review` | Read the saved result of an existing local review. | Read | MCP only | ### Coding Agent | Tool | What it does | Access | REST operation | | - | - | - | - | | `get_code_autofix` | Read existing autofix status for a task or pull request | Read | [`GET /v1/code/autofix`](/api/reference/get-code-autofix) | | `set_code_autofix` | Enable, disable, resume or recover existing autofix | Write | [`POST /v1/code/autofix/commands`](/api/reference/set-code-autofix) | | `list_code_tasks` | List accessible coding tasks | Read | [`GET /v1/code/tasks`](/api/reference/list-code-tasks) | | `create_code_task` | Create a coding task | Write | [`POST /v1/code/tasks`](/api/reference/create-code-task) | | `get_code_task` | Read an accessible coding task | Read | [`GET /v1/code/tasks/{task_id}`](/api/reference/get-code-task) | | `cancel_code_task_turn` | Request the existing human Stop action for a coding task | Write | [`POST /v1/code/tasks/{task_id}/cancel`](/api/reference/cancel-code-task-turn) | | `deliver_code_task` | Deliver a task patch using the caller's existing repository write authorization | Write | [`POST /v1/code/tasks/{task_id}/delivery`](/api/reference/deliver-code-task) | | `get_code_task_patch` | Read a coding task's stored patch | Read | [`GET /v1/code/tasks/{task_id}/patch`](/api/reference/get-code-task-patch) | | `get_code_task_plan` | Read a stored coding plan version | Read | [`GET /v1/code/tasks/{task_id}/plan`](/api/reference/get-code-task-plan) | | `set_code_task_plan_approval` | Approve or withdraw approval of a coding plan | Write | [`PUT /v1/code/tasks/{task_id}/plan/approval`](/api/reference/set-code-task-plan-approval) | | `list_code_task_plan_comments` | Read feedback on a specific stored plan version | Read | [`GET /v1/code/tasks/{task_id}/plan/comments`](/api/reference/list-code-task-plan-comments) | | `replace_code_task_plan_comment` | Replace your Plan comment text | Write | [`PUT /v1/code/tasks/{task_id}/plan/comments/{comment_id}`](/api/reference/replace-code-task-plan-comment) | | `delete_code_task_plan_comment` | Delete your Plan comment | Write | [`DELETE /v1/code/tasks/{task_id}/plan/comments/{comment_id}`](/api/reference/delete-code-task-plan-comment) | | `reopen_code_task_plan_comment_thread` | Reopen a Plan feedback thread | Write | [`POST /v1/code/tasks/{task_id}/plan/comments/threads/{thread_id}/reopen`](/api/reference/reopen-code-task-plan-comment-thread) | | `reply_code_task_plan_comment_thread` | Reply to an existing Plan feedback thread | Write | [`POST /v1/code/tasks/{task_id}/plan/comments/threads/{thread_id}/replies`](/api/reference/reply-code-task-plan-comment-thread) | | `resolve_code_task_plan_comment_thread` | Resolve a Plan feedback thread | Write | [`POST /v1/code/tasks/{task_id}/plan/comments/threads/{thread_id}/resolve`](/api/reference/resolve-code-task-plan-comment-thread) | | `implement_code_task_plan` | Implement a stored plan after its existing readiness checks | Write | [`POST /v1/code/tasks/{task_id}/plan/implementation`](/api/reference/implement-code-task-plan) | | `revise_code_task_plan` | Queue a plan revision using the existing replan operation | Write | [`POST /v1/code/tasks/{task_id}/plan/revisions`](/api/reference/revise-code-task-plan) | | `list_code_task_questions` | Read questions recorded in a task's recent execution history | Read | [`GET /v1/code/tasks/{task_id}/questions`](/api/reference/list-code-task-questions) | | `answer_code_task_question` | Answer an existing coding task interaction | Write | [`POST /v1/code/tasks/{task_id}/questions/{interaction_id}/answers`](/api/reference/answer-code-task-question) | | `get_code_task_queue` | Read queued coding task messages | Read | [`GET /v1/code/tasks/{task_id}/queue`](/api/reference/get-code-task-queue) | | `list_code_task_turns` | List retained coding execution turns | Read | [`GET /v1/code/tasks/{task_id}/turns`](/api/reference/list-code-task-turns) | | `create_code_task_turn` | Queue a follow-up coding message | Write | [`POST /v1/code/tasks/{task_id}/turns`](/api/reference/create-code-task-turn) | | `get_code_task_turn` | Read a retained coding execution turn by its native start sequence | Read | [`GET /v1/code/tasks/{task_id}/turns/{turn_start_seq}`](/api/reference/get-code-task-turn) | ### Coding environments | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_code_environment_assignments` | List existing repository environment assignments | Read | [`GET /v1/code/environment-assignments`](/api/reference/list-code-environment-assignments) | | `list_code_environments` | List coding environments | Read | [`GET /v1/code/environments`](/api/reference/list-code-environments) | | `create_code_environment` | Create a coding environment with existing preparation behavior | Write | [`POST /v1/code/environments`](/api/reference/create-code-environment) | | `get_code_environment` | Read environment configuration without secret values | Read | [`GET /v1/code/environments/{environmentId}`](/api/reference/get-code-environment) | | `update_code_environment` | Update environment configuration with native revision checks | Write | [`PUT /v1/code/environments/{environmentId}`](/api/reference/update-code-environment) | | `archive_code_environment` | Archive a coding environment | Write | [`DELETE /v1/code/environments/{environmentId}`](/api/reference/archive-code-environment) | | `add_code_environment_repository` | Assign a repository to a coding environment | Write | [`POST /v1/code/environments/{environmentId}/repositories`](/api/reference/add-code-environment-repository) | | `update_code_environment_repository` | Update repository setup using its native revision check | Write | [`PUT /v1/code/environments/{environmentId}/repositories/{repositoryAssignmentId}`](/api/reference/update-code-environment-repository) | | `remove_code_environment_repository` | Remove a repository environment assignment | Write | [`DELETE /v1/code/environments/{environmentId}/repositories/{repositoryAssignmentId}`](/api/reference/remove-code-environment-repository) | | `set_code_environment_variable` | Set an environment variable using existing encrypted storage | Write | [`PUT /v1/code/environments/{environmentId}/variables`](/api/reference/set-code-environment-variable) | | `delete_code_environment_variable` | Delete an environment variable | Write | [`DELETE /v1/code/environments/{environmentId}/variables/{variableId}`](/api/reference/delete-code-environment-variable) | ### Verify | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_verify_repositories` | List registered Verify repositories | Read | [`GET /v1/verify/repositories`](/api/reference/list-verify-repositories) | | `register_verify_repository` | Register an accessible repository with an existing execution environment | Write | [`POST /v1/verify/repositories`](/api/reference/register-verify-repository) | | `get_verify_repository` | Read a Verify repository and its recent jobs | Read | [`GET /v1/verify/repositories/{repository_id}`](/api/reference/get-verify-repository) | | `configure_verify_repository` | Configure an existing Verify repository | Write | [`PUT /v1/verify/repositories/{repository_id}`](/api/reference/configure-verify-repository) | | `get_verify_bug_history` | Read a Verify bug's observed history | Read | [`GET /v1/verify/repositories/{repository_id}/bugs/{bug_id}/history`](/api/reference/get-verify-bug-history) | | `get_verify_execution` | Read a Verify execution result | Read | [`GET /v1/verify/repositories/{repository_id}/executions/{execution_id}`](/api/reference/get-verify-execution) | | `get_verify_evidence` | Read published Verify evidence metadata | Read | [`GET /v1/verify/repositories/{repository_id}/executions/{execution_id}/evidence/{artifact_id}`](/api/reference/get-verify-evidence) | | `list_verify_findings` | List current Verify findings | Read | [`GET /v1/verify/repositories/{repository_id}/findings`](/api/reference/list-verify-findings) | | `list_verify_jobs` | List Verify jobs | Read | [`GET /v1/verify/repositories/{repository_id}/jobs`](/api/reference/list-verify-jobs) | | `start_verify_job` | Start an existing Verify authoring, testability or execution operation | Write | [`POST /v1/verify/repositories/{repository_id}/jobs`](/api/reference/start-verify-job) | | `get_verify_job` | Read a Verify job and execution statuses | Read | [`GET /v1/verify/repositories/{repository_id}/jobs/{job_id}`](/api/reference/get-verify-job) | | `get_verify_job_bugs` | Read observed bugs from a Verify job | Read | [`GET /v1/verify/repositories/{repository_id}/jobs/{job_id}/bugs`](/api/reference/get-verify-job-bugs) | | `list_verify_journeys` | List registered user journeys | Read | [`GET /v1/verify/repositories/{repository_id}/journeys`](/api/reference/list-verify-journeys) | | `create_verify_journey` | Create a user journey | Write | [`POST /v1/verify/repositories/{repository_id}/journeys`](/api/reference/create-verify-journey) | | `update_verify_journey` | Update or archive a user journey with native revision checks | Write | [`PUT /v1/verify/repositories/{repository_id}/journeys/{cuj_id}`](/api/reference/update-verify-journey) | | `list_verify_schedules` | List Verify schedules | Read | [`GET /v1/verify/repositories/{repository_id}/schedules`](/api/reference/list-verify-schedules) | | `get_verify_schedule_history` | Read Verify schedule occurrences | Read | [`GET /v1/verify/repositories/{repository_id}/schedules/{schedule_id}/history`](/api/reference/get-verify-schedule-history) | | `change_verify_schedule` | Create, update or delete a Verify schedule with native revision checks | Write | [`POST /v1/verify/repositories/{repository_id}/schedules/changes`](/api/reference/change-verify-schedule) | ### Triage | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_triage_changes` | List the caller's accessible Triage changes | Read | [`GET /v1/triage/changes`](/api/reference/list-triage-changes) | | `get_triage_change` | Read an accessible Triage change | Read | [`GET /v1/triage/changes/{id}`](/api/reference/get-triage-change) | | `list_triage_change_history` | Read the recorded priority and close-candidacy history | Read | [`GET /v1/triage/changes/{id}/history`](/api/reference/list-triage-change-history) | | `set_triage_change_priority` | Set a change's manual priority | Write | [`PUT /v1/triage/changes/{id}/priority`](/api/reference/set-triage-change-priority) | | `list_triage_rules` | List Triage rules | Read | [`GET /v1/triage/rules`](/api/reference/list-triage-rules) | | `create_triage_rule` | Create a Triage rule | Write | [`POST /v1/triage/rules`](/api/reference/create-triage-rule) | | `get_triage_rule` | Read a Triage rule and its definition | Read | [`GET /v1/triage/rules/{ruleId}`](/api/reference/get-triage-rule) | | `update_triage_rule` | Replace a Triage rule definition | Write | [`PUT /v1/triage/rules/{ruleId}`](/api/reference/update-triage-rule) | | `delete_triage_rule` | Delete a Triage rule | Write | [`DELETE /v1/triage/rules/{ruleId}`](/api/reference/delete-triage-rule) | | `list_triage_rule_executions` | Read executions for a rule revision | Read | [`GET /v1/triage/rules/{ruleId}/executions`](/api/reference/list-triage-rule-executions) | | `transition_triage_rule` | Activate, pause, or resume a Triage rule | Write | [`POST /v1/triage/rules/{ruleId}/transition`](/api/reference/transition-triage-rule) | | `preview_triage_rule` | Preview existing changes matching a rule definition | Write | [`POST /v1/triage/rules/preview`](/api/reference/preview-triage-rule) | | `list_triage_teams` | List accessible Triage teams | Read | [`GET /v1/triage/teams`](/api/reference/list-triage-teams) | ### Security | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_security_dependencies` | List vulnerable dependencies | Read | [`GET /v1/security/dependencies`](/api/reference/list-security-dependencies) | | `list_security_findings` | List code and secret findings | Read | [`GET /v1/security/findings`](/api/reference/list-security-findings) | | `get_security_dependency` | Read a dependency and its advisories | Read | [`GET /v1/security/repositories/{repository_id}/dependencies/{dependency_id}`](/api/reference/get-security-dependency) | | `get_security_finding` | Read a code security finding | Read | [`GET /v1/security/repositories/{repository_id}/findings/{finding_id}`](/api/reference/get-security-finding) | | `dismiss_security_finding` | Dismiss a security finding | Write | [`POST /v1/security/repositories/{repository_id}/findings/{finding_id}/dismiss`](/api/reference/dismiss-security-finding) | | `fix_security_finding` | Request an AI fix for a security finding | Write | [`POST /v1/security/repositories/{repository_id}/findings/{finding_id}/fix`](/api/reference/fix-security-finding) | | `reopen_security_finding` | Reopen a code security finding | Write | [`POST /v1/security/repositories/{repository_id}/findings/{finding_id}/reopen`](/api/reference/reopen-security-finding) | | `get_security_runtime_validation_capability` | Read runtime validation availability for a finding | Read | [`GET /v1/security/repositories/{repository_id}/findings/{finding_id}/validation-capability`](/api/reference/get-security-runtime-validation-capability) | | `get_security_scan` | Read an existing security scan | Read | [`GET /v1/security/repositories/{repository_id}/scans/{scan_id}`](/api/reference/get-security-scan) | | `get_security_scan_quote` | Estimate an AI Deep Scan | Read | [`GET /v1/security/repositories/{repository_id}/scans/quote`](/api/reference/get-security-scan-quote) | | `get_security_secret_finding` | Read a secret finding | Read | [`GET /v1/security/repositories/{repository_id}/secrets/{finding_id}`](/api/reference/get-security-secret-finding) | | `list_security_runtime_validations` | List runtime validation attempts for a finding | Read | [`GET /v1/security/repositories/{repository_id}/validations`](/api/reference/list-security-runtime-validations) | | `get_security_runtime_validation` | Read a runtime validation result | Read | [`GET /v1/security/repositories/{repository_id}/validations/{validation_id}`](/api/reference/get-security-runtime-validation) | | `list_security_sbom` | List software bill of materials components | Read | [`GET /v1/security/sbom`](/api/reference/list-security-sbom) | | `export_security_sbom` | Export a software bill of materials | Read | [`GET /v1/security/sbom/export`](/api/reference/export-security-sbom) | | `list_security_scans` | List security scan activity | Read | [`GET /v1/security/scans`](/api/reference/list-security-scans) | | `start_security_scans` | Request security scans for installed repositories | Write | [`POST /v1/security/scans`](/api/reference/start-security-scans) | | `list_security_secret_findings` | List secret scanner findings | Read | [`GET /v1/security/secrets`](/api/reference/list-security-secret-findings) | ### Knowledge Base | Tool | What it does | Access | REST operation | | - | - | - | - | | `get_architecture_capabilities` | Read available architecture knowledge scopes | Read | [`GET /v1/knowledge/architecture/capabilities`](/api/reference/get-architecture-capabilities) | | `get_architecture_document` | Read an architecture knowledge document at an observed revision | Read | [`GET /v1/knowledge/architecture/document`](/api/reference/get-architecture-document) | | `list_architecture_repositories` | List repositories with architecture knowledge | Read | [`GET /v1/knowledge/architecture/repositories`](/api/reference/list-architecture-repositories) | | `get_architecture_tree` | List the current architecture knowledge document tree | Read | [`GET /v1/knowledge/architecture/tree`](/api/reference/get-architecture-tree) | | `list_knowledge_connections` | List connected knowledge repositories | Read | [`GET /v1/knowledge/connected-repositories`](/api/reference/list-knowledge-connections) | | `connect_knowledge_repository` | Connect an installed repository as a knowledge source | Write | [`POST /v1/knowledge/connected-repositories`](/api/reference/connect-knowledge-repository) | | `disconnect_knowledge_repository` | Disconnect a knowledge repository | Write | [`DELETE /v1/knowledge/connected-repositories/{repository_id}`](/api/reference/disconnect-knowledge-repository) | | `reindex_knowledge_repository` | Request a connected repository index refresh | Write | [`POST /v1/knowledge/connected-repositories/{repository_id}/reindex`](/api/reference/reindex-knowledge-repository) | | `list_learnings` | List saved Learnings | Read | [`GET /v1/knowledge/learnings`](/api/reference/list-learnings) | | `create_learnings` | Create Learnings | Write | [`POST /v1/knowledge/learnings`](/api/reference/create-learnings) | | `get_learning` | Read a saved Learning | Read | [`GET /v1/knowledge/learnings/{learning_id}`](/api/reference/get-learning) | | `delete_learning` | Delete a Learning | Write | [`DELETE /v1/knowledge/learnings/{learning_id}`](/api/reference/delete-learning) | | `update_learning` | Update a Learning | Write | [`PATCH /v1/knowledge/learnings/{learning_id}`](/api/reference/update-learning) | | `export_learnings` | Export saved Learnings | Read | [`GET /v1/knowledge/learnings/export`](/api/reference/export-learnings) | | `get_learning_filters` | Read available Learning filters | Read | [`GET /v1/knowledge/learnings/filters`](/api/reference/get-learning-filters) | | `get_learning_statistics` | Read recorded Learning usage statistics | Read | [`GET /v1/knowledge/learnings/statistics`](/api/reference/get-learning-statistics) | ### Automations | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_automations` | List accessible automations | Read | [`GET /v1/automations`](/api/reference/list-automations) | | `create_automation` | Create an ordinary Automation | Write | [`POST /v1/automations`](/api/reference/create-automation) | | `get_automation` | Read an ordinary Automation and its editable definition | Read | [`GET /v1/automations/{automation_id}`](/api/reference/get-automation) | | `update_automation` | Replace an ordinary Automation definition at its observed revision | Write | [`PUT /v1/automations/{automation_id}`](/api/reference/update-automation) | | `command_automation` | Run, pause, resume, or delete an ordinary Automation | Write | [`POST /v1/automations/{automation_id}/commands`](/api/reference/command-automation) | | `list_automation_runs` | List recorded ordinary Automation runs | Read | [`GET /v1/automations/{automation_id}/runs`](/api/reference/list-automation-runs) | ### Reports | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_reports` | List existing report configurations | Read | [`GET /v1/reports`](/api/reference/list-reports) | | `create_report` | Create an on-demand or scheduled report | Write | [`POST /v1/reports`](/api/reference/create-report) | | `get_report` | Read an existing report configuration | Read | [`GET /v1/reports/{report_id}`](/api/reference/get-report) | | `update_report` | Replace a recurring report configuration | Write | [`PUT /v1/reports/{report_id}`](/api/reference/update-report) | | `delete_report` | Delete a report configuration | Write | [`DELETE /v1/reports/{report_id}`](/api/reference/delete-report) | | `set_report_status` | Enable or disable a report schedule | Write | [`PATCH /v1/reports/{report_id}`](/api/reference/set-report-status) | ### Configuration | Tool | What it does | Access | REST operation | | - | - | - | - | | `get_organization_configuration` | Read organization review configuration | Read | [`GET /v1/configuration/organization`](/api/reference/get-organization-configuration) | | `set_organization_configuration` | Replace organization review configuration | Write | [`PUT /v1/configuration/organization`](/api/reference/set-organization-configuration) | | `get_workspace_configuration` | Read workspace review configuration | Read | [`GET /v1/configuration/workspace`](/api/reference/get-workspace-configuration) | | `get_workspace_configuration_defaults` | Read the workspace configuration-default policy | Read | [`GET /v1/configuration/workspace-defaults`](/api/reference/get-workspace-configuration-defaults) | | `set_workspace_configuration_defaults` | Set the workspace configuration-default policy | Write | [`PUT /v1/configuration/workspace-defaults`](/api/reference/set-workspace-configuration-defaults) | | `get_repository_configuration` | Read repository review configuration | Read | [`GET /v1/repositories/{repository_id}/configuration`](/api/reference/get-repository-configuration) | | `set_repository_configuration` | Replace repository review configuration | Write | [`PUT /v1/repositories/{repository_id}/configuration`](/api/reference/set-repository-configuration) | | `get_effective_repository_configuration` | Read the effective review configuration and its layers | Read | [`GET /v1/repositories/{repository_id}/configuration/effective`](/api/reference/get-effective-repository-configuration) | | `preview_repository_configuration` | Preview effective repository configuration without saving | Write | [`POST /v1/repositories/{repository_id}/configuration/preview`](/api/reference/preview-repository-configuration) | | `get_repository_configuration_source` | Read a repository's configuration source | Read | [`GET /v1/repositories/{repository_id}/configuration/source`](/api/reference/get-repository-configuration-source) | | `set_repository_configuration_source` | Set a repository's configuration source | Write | [`PUT /v1/repositories/{repository_id}/configuration/source`](/api/reference/set-repository-configuration-source) | ### Connections | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_connections` | List accessible workspace connections | Read | [`GET /v1/connections`](/api/reference/list-connections) | | `create_connection` | Create a workspace connection | Write | [`POST /v1/connections`](/api/reference/create-connection) | | `get_connection` | Read masked saved-connection configuration | Read | [`GET /v1/connections/{connectionId}`](/api/reference/get-connection) | | `update_connection` | Update a workspace connection | Write | [`PUT /v1/connections/{connectionId}`](/api/reference/update-connection) | | `delete_connection` | Delete a workspace connection | Write | [`DELETE /v1/connections/{connectionId}`](/api/reference/delete-connection) | | `patch_connection_metadata` | Update a connection's name or description | Write | [`PATCH /v1/connections/{connectionId}`](/api/reference/patch-connection-metadata) | | `complete_connection_requests` | Verify a saved connection and complete matching requests | Write | [`POST /v1/connections/{connectionId}/complete-requests`](/api/reference/complete-connection-requests) | | `discover_connection_mcp_tools` | Discover tools from a configured MCP connection | Write | [`POST /v1/connections/mcp/tools`](/api/reference/discover-connection-mcp-tools) | | `list_connection_requests` | List pending workspace connection requests | Read | [`GET /v1/connections/requests`](/api/reference/list-connection-requests) | | `get_connection_request` | Read an existing connection-request intent | Read | [`GET /v1/connections/requests/{intent}`](/api/reference/get-connection-request) | | `submit_connection_request` | Submit an existing connection-request intent | Write | [`POST /v1/connections/requests/{intent}`](/api/reference/submit-connection-request) | | `test_connection` | Test a connection with existing credential and provider checks | Write | [`POST /v1/connections/test`](/api/reference/test-connection) | ### Users and roles | Tool | What it does | Access | REST operation | | - | - | - | - | | `list_roles` | List organization roles | Read | [`GET /v1/configuration/roles`](/api/reference/list-roles) | | `create_role` | Create a custom role by copying an existing role | Write | [`POST /v1/configuration/roles`](/api/reference/create-role) | | `get_role` | Read a role and its permissions | Read | [`GET /v1/configuration/roles/{roleId}`](/api/reference/get-role) | | `delete_role` | Delete an unassigned custom role | Write | [`DELETE /v1/configuration/roles/{roleId}`](/api/reference/delete-role) | | `update_role` | Update a custom role | Write | [`PATCH /v1/configuration/roles/{roleId}`](/api/reference/update-role) | | `list_role_permission_options` | List supported role permissions | Read | [`GET /v1/configuration/roles/permissions`](/api/reference/list-role-permission-options) | | `list_users` | List organization users and seat assignments | Read | MCP only | | `manage_seats` | Assign or unassign organization seats | Write | MCP only | | `list_audit_logs` | List organization audit logs | Read | MCP only | ### Usage and metrics | Tool | What it does | Access | REST operation | | - | - | - | - | | `get_credits` | Read permitted credit balances | Read | [`GET /v1/credits`](/api/reference/get-credits) | | `get_usage` | Read current usage and permitted credit balances | Read | [`GET /v1/usage`](/api/reference/get-usage) | | `get_usage_budget` | Read current usage budget policy and consumption | Read | [`GET /v1/usage/budget`](/api/reference/get-usage-budget) | | `list_usage_budget_members` | Read paginated member usage budgets | Read | [`GET /v1/usage/budget/members`](/api/reference/list-usage-budget-members) | ## What's next > [card] [Connect an MCP client](/api/mcp) > > Connect your agent and choose the scopes for the tools it calls. > [card] [Request and read reviews](/api/guides/pull-request-reviews) > > Find a pull request, request a review, and follow its status. # Make your first API call Source: https://docs.coderabbit.ai/api/quickstart Create a CodeRabbit API key, check it, list your repositories, and read a pull request's review status with curl or the CLI. GitHub Cloud (The operations on this page are available for GitHub Cloud organizations.) In this quickstart you create an API key and make three calls: check which organization the key belongs to, list the repositories you can access, and read CodeRabbit's review status for a pull request. It takes about five minutes. ## Before you start * CodeRabbit is installed on a GitHub Cloud organization, and you know a pull request it reviewed. * You know your organization's region: US if you sign in at `app.coderabbit.ai`, EU if you sign in at `app.eu.coderabbit.ai`. * You have `curl`, or the CodeRabbit CLI for the CLI examples. See [CLI](/api/cli) for the version that includes `coderabbit api`. ## Create an API key In the CodeRabbit app for your region, open **API keys** ([US](https://app.coderabbit.ai/settings/api-keys) or [EU](https://app.eu.coderabbit.ai/settings/api-keys)) and create a key of type **User**, as [Create a user or agentic key](/api/authentication#create-a-user-or-agentic-key) describes. If **Type** offers only **Agentic**, choose it: an agentic key works for every call on this page. Copy the key when you save it, because CodeRabbit shows it only once. ## Set up your shell Read the key into an environment variable without echoing it or writing it to your shell history: ```bash theme={null} read -rs CODERABBIT_API_KEY # paste the key, then press Enter export CODERABBIT_API_KEY ``` Set the API host of the region where you created the key. The EU settings also point the CLI at the EU region; see [Choose the region](/api/cli#choose-the-region). ```bash US theme={null} export CODERABBIT_API_HOST=https://api.coderabbit.ai ``` ```bash EU theme={null} export CODERABBIT_API_HOST=https://api.eu.coderabbit.ai export CODERABBIT_HOST_URL=https://app.eu.coderabbit.ai ``` For the CLI, also save the key to a file that only you can read. `--api-key-file` passes the file to each command without changing your CLI sign-in: ```bash theme={null} (umask 077 && printf '%s\n' "$CODERABBIT_API_KEY" > ~/.coderabbit-api-key) ``` ## Check the key Ask the API who you are with [Get the authenticated principal](/api/reference/get-me): ```bash curl theme={null} curl -sS "$CODERABBIT_API_HOST/v1/me" \ -H "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.coderabbit-api-key me ``` The response names the key, its owner's role, and the CodeRabbit organization the key belongs to: ```json Response (trimmed) theme={null} { "principal": { "type": "api_key", "key_type": "user", "owner": { "provider_user_id": "583231", "role": "cr_member" } }, "scope": { "type": "organization", "id": "0b6f3d2e-5a1c-4e8b-9f27-6c4d8a1e3b95", "provider": "github", "workspace_id": "7e2a9c41-3d8f-4b6e-a015-9c8d2f4b7a63" } } ``` If you get `401 unauthenticated`, the key is missing, mistyped, deleted, or expired, or `CODERABBIT_API_HOST` isn't the host of the region where you created the key. If you get `404 not_found`, the key belongs to an organization that isn't on GitHub Cloud, or it's a self-hosted instance key. See [Errors](/api/conventions#errors) for the other codes. ## List your repositories [List repositories](/api/reference/list-repositories) returns the repositories in the organization that you can access: ```bash curl theme={null} curl -sS "$CODERABBIT_API_HOST/v1/repositories?page_size=10" \ -H "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.coderabbit-api-key repositories list --page-size 10 ``` Each entry in `data` has an `id`, GitHub's numeric repository ID, and a `full_name` such as `acme/api`. Copy the `id` of the repository that has your pull request. When `next_page_token` isn't `null`, more repositories are available: see [Pagination](/api/conventions#pagination). ## Read a pull request's review status [Read review status](/api/reference/get-pull-request-review) takes the repository ID and the pull request number. Replace `123456789` and `42` with yours: ```bash curl theme={null} curl -sS "$CODERABBIT_API_HOST/v1/repositories/123456789/pull-requests/42/review" \ -H "x-coderabbitai-api-key: $CODERABBIT_API_KEY" ``` ```bash CLI theme={null} coderabbit api --api-key-file ~/.coderabbit-api-key pull-requests review-status 123456789 42 ``` ```json Response (trimmed) theme={null} { "head_sha": "9f2c1e74b0a1d3c5e8f7a6b5c4d3e2f1a0b9c8d7", "review": { "status": "completed", "target_commit_sha": "9f2c1e74b0a1d3c5e8f7a6b5c4d3e2f1a0b9c8d7", "updated_at": "2026-11-10T09:14:03Z" } } ``` `head_sha` is the pull request's current head commit. To read `review.status` and check whether it covers that commit, see [Follow the review status](/api/guides/pull-request-reviews#4-follow-the-review-status). This call only reads the status; to start a review, see [Request a review](/api/guides/pull-request-reviews#3-request-a-review). ## What's next > [card] [Authenticate requests](/api/authentication) > > Choose between user keys, agentic keys, and workspace API tokens, and keep them safe. > [card] [Handle responses](/api/conventions) > > Learn the base URLs, identifiers, pagination styles, errors, and rate limits that every operation shares. > [card] [Request and read reviews](/api/guides/pull-request-reviews) > > Request a CodeRabbit review and follow it until the current head is reviewed. # Assign a repository to a coding environment Source: https://docs.coderabbit.ai/api/reference/add-code-environment-repository /openapi.json post /v1/code/environments/{environmentId}/repositories Assigns a repository to the environment with its setup configuration, in the preparing status. The repository must match the organization's Git provider. Returns a conflict if the repository is already assigned and not preparing. > [tab] CLI Tool > > ```bash > coderabbit api request "/code/environments/$ENVIRONMENT_ID/repositories" --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `add_code_environment_repository` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "add_code_environment_repository", > "arguments": { > "environmentId": "", > "repository": {}, > "setup": {} > } > } > } > ``` # Add users and assign seats for a self-hosted organization Source: https://docs.coderabbit.ai/api/reference/add-users /openapi.json put /v1/users Add up to 500 provider-identified users to a self-hosted organization and assign seats. Requires an Enterprise plan and administrator access; self-hosted organization keys retain their existing administrator exemption. SSO-managed workspaces are unsupported; use POST /v1/users/seats with workspace member identities instead. If seats are unavailable, the operation can reclaim seats from users inactive for at least 30 days. Duplicate user_id values are processed once, keeping the first entry. HTTP 200 can contain partial success or failure; inspect status and failed for per-user results. > [tab] CLI Tool > > ```bash > coderabbit api request -X PUT /users --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > This operation isn't a tool on the [CodeRabbit MCP server](/api/mcp). Call it over REST or from the CLI. # Answer an existing coding task interaction Source: https://docs.coderabbit.ai/api/reference/answer-code-task-question /openapi.json post /v1/code/tasks/{task_id}/questions/{interaction_id}/answers Provider delegation and delivery authorization interactions continue through their existing product authorization flow. > [tab] CLI Tool > > ```bash > coderabbit api request "/code/tasks/$TASK_ID/questions/$INTERACTION_ID/answers" --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `answer_code_task_question` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "answer_code_task_question", > "arguments": { > "task_id": "", > "interaction_id": "", > "client_operation_id": "", > "answers": {} > } > } > } > ``` # Archive a coding environment Source: https://docs.coderabbit.ai/api/reference/archive-code-environment /openapi.json delete /v1/code/environments/{environmentId} Archives a coding environment. Archived environments are not returned by list or read operations. > [tab] CLI Tool > > ```bash > coderabbit api request -X DELETE "/code/environments/$ENVIRONMENT_ID" > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `archive_code_environment` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "archive_code_environment", > "arguments": { > "environmentId": "" > } > } > } > ``` # List audit log entries Source: https://docs.coderabbit.ai/api/reference/audit-logs-list /openapi.json get /v1/audit-logs Retrieve audit log entries for the organization. Supports filtering by actions, resource types, and date range. Returns paginated results with filter options. > [tab] CLI Tool > > ```bash > coderabbit api request /audit-logs > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > This operation isn't a tool on the [CodeRabbit MCP server](/api/mcp). Call it over REST or from the CLI. # List or export Bug Scan findings Source: https://docs.coderabbit.ai/api/reference/bug-scan-findings-list /openapi.json get /v1/bug-scan/findings Returns one repository's Bug Scan findings from its latest completed scan, or from scan_id. Cursor-paginated JSON by default; CSV and SARIF 2.1.0 download every matching finding of the scan (up to 50,000 records and 16 MB). Findings are in the scan's rank order. Each finding carries its fingerprint, severity, category, location, every location it applies to, explanation, the prompt for AI agents, the verifier's account, and its state (open, fixed or dismissed) with the dismiss reason. Requires a non-agentic API key with bug_scan:read permission, and Bug Scan enabled for the organization; other organizations receive 403 BUG_SCAN_NOT_ENABLED. > [tab] CLI Tool > > ```bash > coderabbit api request "/bug-scan/findings?repo_id=$REPO_ID" > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > This operation isn't a tool on the [CodeRabbit MCP server](/api/mcp). Call it over REST or from the CLI. # Request the existing human Stop action for a coding task Source: https://docs.coderabbit.ai/api/reference/cancel-code-task-turn /openapi.json post /v1/code/tasks/{task_id}/cancel Stops the current coding turn using the existing runtime cancellation owner. Pending messages follow existing pause behavior; this does not cancel reviews. > [tab] CLI Tool > > ```bash > coderabbit api request -X POST "/code/tasks/$TASK_ID/cancel" > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `cancel_code_task_turn` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "cancel_code_task_turn", > "arguments": { > "task_id": "" > } > } > } > ``` # Change roles for multiple users Source: https://docs.coderabbit.ai/api/reference/change-roles /openapi.json post /v1/users/roles Bulk change roles for users in the organization. Supports up to 500 users per request. Cannot modify billing admin roles. Rate limited to 10 requests per 60 seconds with max 3 concurrent requests per organization. > [tab] CLI Tool > > ```bash > coderabbit api request /users/roles --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > This operation isn't a tool on the [CodeRabbit MCP server](/api/mcp). Call it over REST or from the CLI. With `org_id` set to `ALL`, CodeRabbit changes each organization separately, so the change isn't atomic: a user is listed in `succeeded` only when every organization succeeded. See [Change a role on every organization of a self-hosted instance](/api/guides/users-and-seats#change-a-role-on-every-organization-of-a-self-hosted-instance). # Create, update or delete a Verify schedule with native revision checks Source: https://docs.coderabbit.ai/api/reference/change-verify-schedule /openapi.json post /v1/verify/repositories/{repository_id}/schedules/changes Accepts a schedule configuration change. Read list_verify_schedules for saved configuration, runtime_state and any pending recovery; schedule_id is not confirmation that a run has completed. > [tab] CLI Tool > > ```bash > coderabbit api request "/verify/repositories/$REPOSITORY_ID/schedules/changes" --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `change_verify_schedule` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "change_verify_schedule", > "arguments": { > "repository_id": "", > "mutation_id": "", > "change": "" > } > } > } > ``` # Run, pause, resume, or delete an ordinary Automation Source: https://docs.coderabbit.ai/api/reference/command-automation /openapi.json post /v1/automations/{automation_id}/commands Uses native ownership and revision checks. run_now accepts work; poll the recorded runs for completion. > [tab] CLI Tool > > ```bash > coderabbit api request "/automations/$AUTOMATION_ID/commands" --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `command_automation` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "command_automation", > "arguments": { > "automation_id": "", > "expected_revision": 1, > "action": "run_now" > } > } > } > ``` # Verify a saved connection and complete matching requests Source: https://docs.coderabbit.ai/api/reference/complete-connection-requests /openapi.json post /v1/connections/{connectionId}/complete-requests Tests a saved runtime-access connection and, if the test passes, schedules notifications for the pending requests for its connector. If the test fails, the requests stay pending. Requires permission to manage connection requests. > [tab] CLI Tool > > ```bash > coderabbit api request -X POST "/connections/$CONNECTION_ID/complete-requests" > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `complete_connection_requests` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "complete_connection_requests", > "arguments": { > "connectionId": "" > } > } > } > ``` # Configure an existing Verify repository Source: https://docs.coderabbit.ai/api/reference/configure-verify-repository /openapi.json put /v1/verify/repositories/{repository_id} Saves configuration only; does not start a job. Omitted optional settings remain unchanged. Read get_verify_repository for normalized saved values and the new config_revision. > [tab] CLI Tool > > ```bash > coderabbit api request -X PUT "/verify/repositories/$REPOSITORY_ID" --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `configure_verify_repository` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "configure_verify_repository", > "arguments": { > "repository_id": "", > "branch": "", > "environment_id": "", > "expected_revision": 1 > } > } > } > ``` # Connect an installed repository as a knowledge source Source: https://docs.coderabbit.ai/api/reference/connect-knowledge-repository /openapi.json post /v1/knowledge/connected-repositories Preserves the existing connected-KB flag and plan limit. A failed initial index request can leave the repository connected; read the connections before retrying. > [tab] CLI Tool > > ```bash > coderabbit api request /knowledge/connected-repositories --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `connect_knowledge_repository` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "connect_knowledge_repository", > "arguments": { > "repository_id": "" > } > } > } > ``` # Create an ordinary Automation Source: https://docs.coderabbit.ai/api/reference/create-automation /openapi.json post /v1/automations Saves an ordinary Automation through native authoring and admission. The returned revision identifies the saved configuration, not completion of a scheduled run. > [tab] CLI Tool > > ```bash > coderabbit api request /automations --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `create_automation` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "create_automation", > "arguments": { > "definition": {} > } > } > } > ``` # Create a coding environment with existing preparation behavior Source: https://docs.coderabbit.ai/api/reference/create-code-environment /openapi.json post /v1/code/environments Creates an environment with its packages, encrypted variables and 1 to 50 repositories, and starts environment preparation. Repositories start in the preparing status. The name is limited to 48 characters. > [tab] CLI Tool > > ```bash > coderabbit api request /code/environments --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `create_code_environment` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "create_code_environment", > "arguments": { > "name": "", > "repositories": [] > } > } > } > ``` # Create a coding task Source: https://docs.coderabbit.ai/api/reference/create-code-task /openapi.json post /v1/code/tasks Uses the existing coding task admission, permissions, billing and product flags. Delivery initially produces a proposed patch. > [tab] CLI Tool > > ```bash > coderabbit api request /code/tasks --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `create_code_task` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "create_code_task", > "arguments": { > "repository_id": "", > "branch": "", > "instructions": "", > "client_request_id": "" > } > } > } > ``` # Queue a follow-up coding message Source: https://docs.coderabbit.ai/api/reference/create-code-task-turn /openapi.json post /v1/code/tasks/{task_id}/turns Returns the native pending-message queue, not a completed turn. Read GET /code/tasks/{task_id} for current status and GET /code/tasks/{task_id}/turns for execution turns; read an individual turn for its final reply or public error. > [tab] CLI Tool > > ```bash > coderabbit api request "/code/tasks/$TASK_ID/turns" --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `create_code_task_turn` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "create_code_task_turn", > "arguments": { > "task_id": "", > "message": "", > "client_operation_id": "" > } > } > } > ``` CodeRabbit accepts the work and finishes it later: read the result with [Get code task](/api/reference/get-code-task). # Create a workspace connection Source: https://docs.coderabbit.ai/api/reference/create-connection /openapi.json post /v1/connections Creates a workspace connection from the supplied configuration and credentials, and returns its metadata without credentials. Requires workspace_integration_management:write. > [tab] CLI Tool > > ```bash > coderabbit api request /connections --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `create_connection` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "create_connection", > "arguments": { > "connection": {} > } > } > } > ``` # Create Learnings Source: https://docs.coderabbit.ai/api/reference/create-learnings /openapi.json post /v1/knowledge/learnings Creates one Learning for each submitted item. The request has no Learning ID, so repeating it can create duplicates. Returns the created IDs. Read each with GET /knowledge/learnings/{learning_id}. learning_ids is null when an older serving writer cannot return identity metadata; do not replay the write to discover IDs. > [tab] CLI Tool > > ```bash > coderabbit api request /knowledge/learnings --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `create_learnings` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "create_learnings", > "arguments": { > "learnings": [] > } > } > } > ``` # Create an on-demand or scheduled report Source: https://docs.coderabbit.ai/api/reference/create-report /openapi.json post /v1/reports Saves a configuration through the existing report creator, destination authorization and scheduling behavior. ONDEMAND requests also trigger native generation; the returned ID identifies configuration, not completed report content. The separate legacy /api/v1/report.generate API retains its existing generation contract. > [tab] CLI Tool > > ```bash > coderabbit api request /reports --input request.json > ``` > > To install and sign in to the CLI, see [Call from the CLI](/api/cli). > [tab] MCP Server > > An agent connected to the [CodeRabbit MCP server](/api/mcp) runs this operation as the `create_report` tool. The connection selects the organization, so the arguments have no `org_id` or `org_name`. > > ```json > { > "method": "tools/call", > "params": { > "name": "create_report", > "arguments": { > "name": "", > "time": "