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

1

Open the Analytics API integration

2

Generate a personal key

Click Generate API key. Analytics API keys start with cak_, and cubic only shows the full value once.
3

Store it securely

Save the key in your secret manager or local environment. If you revoke or regenerate the key, the previous value stops working immediately.
API keys are personal. Each team member should generate their own key, and every request is limited to the organizations and repositories that key owner can already access in cubic.

Endpoint

Use this endpoint to fetch merged pull requests that have completed cubic reviews in the selected time window.
MethodEndpoint
GEThttps://www.cubic.dev/api/analytics/v1/prs

Authentication

Send the Analytics API key in the Authorization header as a bearer token.
Authorization: Bearer cak_your_api_key

Example requests

curl --request GET \
  --url 'https://www.cubic.dev/api/analytics/v1/prs?org=your-org&perPage=100' \
  --header 'Authorization: Bearer cak_your_api_key' \
  --header 'Accept: application/json'

Query parameters

ParameterRequiredDescription
orgYesGitHub organization or owner whose pull request analytics you want to fetch.
repoNoLimit the request to a single repository inside the selected owner.
startDateNoStart of the time window. Supports ISO 8601 timestamps and date-only values like 2026-04-01.
endDateNoEnd of the time window. Supports ISO 8601 timestamps and date-only values like 2026-04-30.
perPageNoNumber of results per page. Defaults to 100 and is capped at 100.
cursorNoCursor from the previous response. Use it to fetch the next page.
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.
{
  "data": [
    {
      "org": "acme",
      "repo": "backend",
      "prNumber": 4645,
      "author": "john-doe",
      "createdAt": "2026-04-16T12:00:00.000Z",
      "mergedAt": "2026-04-17T12:00:00.000Z",
      "linesAdded": 543,
      "linesDeleted": 12,
      "numberOfCubicIssuesFlagged": 5,
      "numberOfCubicIssuesFixed": 4,
      "cubicFirstReviewedAt": "2026-04-17T00:00:00.000Z",
      "totalAiLinesAuthored": 523
    }
  ],
  "nextCursor": "2026-04-16T12:00:00.000Z|102"
}

Top-level fields

FieldDescription
dataThe current page of pull request analytics rows.
nextCursorCursor for the next page, or null when there are no more results.

Pull request row fields

FieldDescription
orgGitHub owner used for the request.
repoRepository name.
prNumberPull request number.
authorGitHub login of the pull request author.
createdAtPull request creation timestamp in ISO 8601 format.
mergedAtPull request merge timestamp in ISO 8601 format.
linesAddedLines added in the pull request, or null when unavailable.
linesDeletedLines deleted in the pull request, or null when unavailable.
numberOfCubicIssuesFlaggedNumber of cubic issues flagged on the pull request.
numberOfCubicIssuesFixedNumber of cubic issues fixed on the pull request.
cubicFirstReviewedAtTimestamp of the first completed cubic review for the pull request.
totalAiLinesAuthoredTotal AI-authored lines attributed to the pull request, or 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.
curl --request GET \
  --url 'https://www.cubic.dev/api/analytics/v1/prs?org=your-org&perPage=100&cursor=2026-04-16T12%3A00%3A00.000Z%7C102' \
  --header 'Authorization: Bearer cak_your_api_key' \
  --header 'Accept: application/json'

Common errors

StatusWhen it happens
400Missing org, invalid query parameters, invalid cursor, or invalid date range.
401Missing bearer token, invalid API key, or expired API key.
403The API key owner does not have access to the requested organization or repository.
404cubic cannot resolve the org to an installation.