> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coderabbit.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Export metrics, read usage, and schedule reports

> 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](https://docs.coderabbit.ai/api/authentication.md#which-keys-each-operation-accepts) for the keys each operation accepts and [Conventions](https://docs.coderabbit.ai/api/conventions.md) 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](https://docs.coderabbit.ai/api.md#plans).
* The curl examples read the key from `CODERABBIT_API_KEY`. The CLI examples use the [`coderabbit api` command](https://docs.coderabbit.ai/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](https://docs.coderabbit.ai/api/conventions.md#rate-limits).

## Export review metrics

1. Call [Get PR metrics for organization](https://docs.coderabbit.ai/api/reference/review-metrics.md) 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](https://docs.coderabbit.ai/guides/data-export.md#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](https://docs.coderabbit.ai/api/reference/review-comment-metrics.md) 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](https://docs.coderabbit.ai/api/reference/mcp-metrics.md) measures how CodeRabbit used the MCP servers you [connected to CodeRabbit](https://docs.coderabbit.ai/connections/mcp-servers.md) for review context. It has nothing to do with the CodeRabbit [MCP server](https://docs.coderabbit.ai/api/mcp.md) 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](https://docs.coderabbit.ai/api/reference/get-usage.md). 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](https://docs.coderabbit.ai/api/reference/get-credits.md) 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](https://docs.coderabbit.ai/management/roles.md). 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](https://docs.coderabbit.ai/api/reference/get-usage-budget.md) 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](https://docs.coderabbit.ai/api/reference/list-usage-budget-members.md) 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](https://docs.coderabbit.ai/api/reference/create-report.md). 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](https://docs.coderabbit.ai/api/reference/update-report.md) (weekly and monthly reports only), [Enable or disable a report schedule](https://docs.coderabbit.ai/api/reference/set-report-status.md), and [Delete a report configuration](https://docs.coderabbit.ai/api/reference/delete-report.md). [Read a report configuration](https://docs.coderabbit.ai/api/reference/get-report.md) returns the configuration, not report content or delivery status.

For filters, grouping, templates, and delivery channels, see [Schedule reports](https://docs.coderabbit.ai/guides/scheduled-reports.md) and [Customize reports](https://docs.coderabbit.ai/guides/custom-reports.md).

## What's next

> [card] [Data Export](https://docs.coderabbit.ai/guides/data-export.md)
>
> Look up what each exported review metrics column means.

> [card] [Reports overview](https://docs.coderabbit.ai/management/reports.md)
>
> Learn what CodeRabbit reports contain and how teams use them.

> [card] [Handle responses](https://docs.coderabbit.ai/api/conventions.md)
>
> Review pagination, error formats, and rate limits shared by every operation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.