Skip to main content
Feed CodeRabbit review data into your analytics tools, watch spend, and schedule reports from code.

Before you start

  • See Authentication for the keys each operation accepts and 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.
  • The curl examples read the key from CODERABBIT_API_KEY. The CLI examples use the coderabbit api command 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.

Export review metrics

  1. Call Get PR metrics for organization with start_date and end_date. status decides whether the dates match merge dates, close dates, or both; merged pull requests are the default.
  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 describes the other columns.
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 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 measures how CodeRabbit used the MCP servers you connected to CodeRabbit for review context. It has nothing to do with the CodeRabbit MCP server 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. 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.
  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 permitted credit balances 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. 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 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 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. 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 (weekly and monthly reports only), Enable or disable a report schedule, and Delete a report configuration. Read a report configuration returns the configuration, not report content or delivery status.
For filters, grouping, templates, and delivery channels, see Schedule reports and Customize reports.

What’s next

Data Export

Look up what each exported review metrics column means.

Reports overview

Learn what CodeRabbit reports contain and how teams use them.

Handle responses

Review pagination, error formats, and rate limits shared by every operation.