Skip to main content
You may need to measure impact of cubic, but already have a set of analytics tools. The Analytics API gives you PR-level data on how many issues were flagged, how many were fixed, how much AI code was authored, etc.

Get an API key

Analytics API access requires a Pro or Max plan.
The Analytics API accepts your personal API key or an organization API key. Both are on Settings > API, CLI & MCP.
1

Get a key

For your personal key, click Generate API key under Personal API key. Personal keys start with cbk_. If you already use one with the cubic CLI or MCP server, use the same key, because regenerating it replaces the key for every tool.For an organization key, an organization admin clicks Create API key under Organization API keys. Organization keys start with cok_, and both Read and Admin access work.
2

Store it securely

cubic only shows the full value once. Save the key in your secret manager or local environment. If you revoke or regenerate the key, the previous value stops working immediately.
Use an organization key for dashboards and BI tools. It belongs to the organization, so it keeps working when the person who set up the dashboard leaves. Analytics API keys that start with cak_ keep working, but cubic no longer creates them. Move your tools to a personal or organization key, then revoke the cak_ key on the cubic API page.
A personal key reads only the organizations and repositories you can already access in cubic. An organization key reads only its own organization.

Endpoint

Use this endpoint to fetch merged pull requests that have completed cubic reviews in the selected time window.
Analytics responses may reflect normal read-replica lag. Recent reviews, pull request updates, and custom-rule changes can take a short time to appear, so do not use these responses for immediate read-after-write verification.

Authentication

Send a personal or organization key in the Authorization header as a bearer token.
The same keys work with the Members API. See the API overview to compare the two APIs. Requests with personal and organization keys count toward the Members API rate limits of 1,000 requests per 15 minutes per person, or per organization for organization keys. When you run out, cubic answers 429 with a Retry-After header in seconds. The interactive reference includes all query parameters, response schemas, and code examples. Enter your API key to try a request. You can also use the OpenAPI spec to generate a client.

Example requests

Query parameters

See the endpoint reference for the full parameter list. org is required. Use repo to filter to one repository and perPage to choose a page size from 1 to 100. Values outside that range return 400. String query values are trimmed before validation; blank optional values are ignored. The date window selects completed cubic reviews created in that period. The returned pull requests must be merged, but their merge dates can fall outside the selected review window.
If you do not send startDate or endDate, cubic picks a default window based on how much data is available for that installation: the last 30 days, last 7 days, or last 24 hours.
Date-only values are interpreted in UTC. For example, endDate=2026-04-30 includes the full day through 23:59:59.999Z.
If you send only one date bound, cubic fills in the other one for you:
  • startDate only: endDate defaults to the current time
  • endDate only: startDate defaults to the start of available data

Response format

The API returns one page of PR rows plus an optional cursor for the next page.
See the endpoint reference for field descriptions and nullable values. totalAiLinesAuthored is capped at the pull request’s total added and deleted lines; it is null when no AI authorship data is available.

Pagination

When nextCursor is present, send it back in the next request to continue from the previous page.

Errors

Analytics errors include an error message and may include validation details. Check the HTTP status and display the message when a request fails. See the endpoint reference for error statuses and response schemas.