> ## 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.

# Metrics Data

> Returns finalized pull request metrics with CodeRabbit review comments. Merged PRs use merge time and closed-unmerged PRs use close time for the requested range and cursor. Supports cursor-based pagination, paged in write order rather than by merge/close time, so a row written after your cursor already passed its merge or close date (a backfill, or a reopen/reclose) still appears on a later page instead of being silently skipped. Each page request consumes one token when admitted by the request rate limiter. Reviews, review comments, and MCP share the Metrics quota for the configured quota owner. With verified owner scope, coordinate calls across API keys for the same organization, workspace, or Git-provider instance; changing an organization selector does not add quota.



## OpenAPI

````yaml /openapi.json get /v1/metrics/reviews
openapi: 3.0.3
info:
  title: CodeRabbit API spec
  version: 1.0.0
servers:
  - url: https://api.coderabbit.ai
security:
  - ApiKeyAuth: []
paths:
  /v1/metrics/reviews:
    get:
      summary: Metrics Data
      description: >-
        Returns finalized pull request metrics with CodeRabbit review comments.
        Merged PRs use merge time and closed-unmerged PRs use close time for the
        requested range and cursor. Supports cursor-based pagination, paged in
        write order rather than by merge/close time, so a row written after your
        cursor already passed its merge or close date (a backfill, or a
        reopen/reclose) still appears on a later page instead of being silently
        skipped. Each page request consumes one token when admitted by the
        request rate limiter. Reviews, review comments, and MCP share the
        Metrics quota for the configured quota owner. With verified owner scope,
        coordinate calls across API keys for the same organization, workspace,
        or Git-provider instance; changing an organization selector does not add
        quota.
      operationId: review-metrics
      parameters:
        - name: x-coderabbitai-api-key
          description: Your CodeRabbit API key
          required: true
          example: cr-xxxxxxxxxx
          schema:
            type: string
          in: header
        - in: query
          name: org_id
          required: false
          schema:
            type: string
          description: >-
            Workspace-scoped API tokens only. When provided, scopes metrics to
            that single git-provider organization within the token's workspace;
            when omitted, aggregates every organization in the workspace.
            Ignored for organization and self-hosted keys.
        - name: start_date
          description: Start date in ISO 8601 format (YYYY-MM-DD)
          required: true
          example: '2026-01-01'
          schema:
            type: string
            format: date
          in: query
        - name: end_date
          description: End date in ISO 8601 format (YYYY-MM-DD)
          required: true
          example: '2026-01-20'
          schema:
            type: string
            format: date
          in: query
        - name: status
          description: Filter finalized pull requests by status
          required: false
          schema:
            type: string
            enum:
              - merged
              - closed
              - all
            default: merged
          in: query
        - name: organization_ids
          description: >-
            Filter by organization Git provider IDs (comma-separated, max 10).
            Self-hosted instances only.
          required: false
          schema:
            type: string
          in: query
        - name: repository_ids
          description: Filter by repository Git provider IDs (comma-separated, max 10).
          required: false
          example: 672319970,849426160
          schema:
            type: string
          in: query
        - name: user_ids
          description: Filter by author Git provider IDs (comma-separated, max 10).
          required: false
          schema:
            type: string
          in: query
        - name: format
          description: Response format
          required: false
          schema:
            type: string
            enum:
              - json
              - csv
            default: json
          in: query
        - name: limit
          description: Maximum records to return
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1000
          in: query
        - name: cursor
          description: Pagination cursor for fetching next page of results
          required: false
          schema:
            type: string
          in: query
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ReviewMetric'
                  next_cursor:
                    type: string
                    description: >-
                      Cursor for fetching the next page of results, or null when
                      there are no more results.
                    nullable: true
                required:
                  - data
              example:
                data:
                  - pr_url: https://github.com/org/repo/pull/123
                    organization_id: '132028505'
                    organization_name: my-org
                    repository_id: '672319970'
                    repository_name: my-repo
                    author_id: '14079159'
                    author_username: john123
                    created_at: '2025-01-15T10:00:00Z'
                    ready_for_review_at: '2025-01-15T10:15:00Z'
                    first_human_review_at: '2025-01-15T10:00:00Z'
                    last_commit_at: '2025-01-15T10:00:00Z'
                    merged_at: '2025-01-16T14:30:00Z'
                    status: merged
                    review_iterations: 3
                    estimated_complexity: 3
                    estimated_review_minutes: 45
                    coderabbit_comments:
                      total:
                        posted: 8
                        accepted: 5
                      severity:
                        critical:
                          posted: 2
                          accepted: 1
                        major:
                          posted: 3
                          accepted: 2
                        minor:
                          posted: 2
                          accepted: 1
                        trivial:
                          posted: 1
                          accepted: 1
                        info:
                          posted: 0
                          accepted: 0
                      category:
                        SECURITY_AND_PRIVACY:
                          posted: 2
                          accepted: 1
                        PERFORMANCE_AND_SCALABILITY:
                          posted: 1
                          accepted: 1
                        FUNCTIONAL_CORRECTNESS:
                          posted: 2
                          accepted: 1
                        MAINTAINABILITY_AND_CODE_QUALITY:
                          posted: 2
                          accepted: 1
                        DATA_INTEGRITY_AND_INTEGRATION:
                          posted: 1
                          accepted: 1
                        STABILITY_AND_AVAILABILITY:
                          posted: 0
                          accepted: 0
                next_cursor: '2025-01-16T10:30:00Z'
            text/csv:
              schema:
                type: string
                description: >-
                  CSV file with one row per PR. The coderabbit_comments object
                  is flattened into individual columns.
        '400':
          description: >-
            Invalid request parameters or response exceeding 16MB
            (RESPONSE_TOO_LARGE). Use a smaller date range or add filters for an
            oversized response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                errors:
                  - code: INVALID_PARAMETER
                    message: 'start_date: start_date is required'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                    example:
                      - message: Invalid or inactive API key
        '403':
          description: Forbidden - Enterprise plan required or agentic key not allowed
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      message:
                        type: string
                        example: 'Forbidden:: This API requires an Enterprise plan'
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            example: KEY_TYPE_FORBIDDEN
                          message:
                            type: string
                            example: >-
                              Agentic API keys cannot access this endpoint. Use
                              a user API key.
                  - type: object
                    properties:
                      errors:
                        type: array
                        items:
                          type: object
                          properties:
                            code:
                              type: string
                              example: FEATURE_NOT_AVAILABLE
                            message:
                              type: string
                              example: >-
                                The status and review_iterations metrics
                                extensions are not enabled for this organization
        '429':
          description: >-
            Request rate limit exceeded (RATE_LIMIT_EXCEEDED), active metrics
            query capacity reached (METRICS_BUSY), or an identical authorized
            query is still running (METRICS_QUERY_IN_PROGRESS). Wait at least
            the full Retry-After interval after receiving the response, then
            retry the same cursor and query parameters. Do not advance the
            cursor on an error. Other calls sharing the quota can cause another
            rejection after the wait. X-RateLimit headers are present only for
            RATE_LIMIT_EXCEEDED, not for the other 429 errors.
          headers:
            Retry-After:
              schema:
                type: integer
              description: >-
                Seconds to wait before retrying; dynamic for request rate
                limits, 5 for METRICS_BUSY or METRICS_QUERY_IN_PROGRESS
            X-RateLimit-Limit:
              required: false
              schema:
                type: integer
              description: >-
                Token bucket burst capacity, not the number of requests allowed
                per minute
            X-RateLimit-Remaining:
              required: false
              schema:
                type: integer
              description: Whole tokens remaining; 0 on request rate rejection
            X-RateLimit-Reset:
              required: false
              schema:
                type: integer
              description: >-
                Estimated Unix timestamp in seconds when the bucket will be full
                if no more tokens are consumed, or when a temporary local rate
                block ends. Use Retry-After to schedule the next retry.
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                        code:
                          type: string
                          enum:
                            - RATE_LIMIT_EXCEEDED
                            - METRICS_BUSY
                            - METRICS_QUERY_IN_PROGRESS
              example:
                errors:
                  - code: RATE_LIMIT_EXCEEDED
                    message: Too many requests. Please retry after 60 seconds.
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                    example:
                      - message: Internal server error
        '503':
          description: >-
            Metrics are preparing (METRICS_PREPARING), active-query admission
            cannot safely proceed (METRICS_UNAVAILABLE), or API quota custody
            cannot be proved (POLICY_SCOPE_UNAVAILABLE). Retry the same request
            after Retry-After when present; otherwise retry later.
          headers:
            Retry-After:
              required: false
              schema:
                type: integer
              description: >-
                Seconds to wait for METRICS_PREPARING, or 5 for
                METRICS_UNAVAILABLE; absent for POLICY_SCOPE_UNAVAILABLE
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          enum:
                            - METRICS_PREPARING
                            - METRICS_UNAVAILABLE
                            - POLICY_SCOPE_UNAVAILABLE
                        message:
                          type: string
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |-
            curl --request GET \
              --url 'https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20' \
              --header 'x-coderabbitai-api-key: <api-key>'
        - lang: Python
          label: Python
          source: |-
            import requests

            url = 'https://api.coderabbit.ai/v1/metrics/reviews'

            headers = {'x-coderabbitai-api-key': '<api-key>'}

            params = {'start_date': '2026-01-01', 'end_date': '2026-01-20'}

            response = requests.get(url, headers=headers, params=params)

            print(response.text)
        - lang: JavaScript
          label: JavaScript
          source: >-
            const options = {method: 'GET', headers: {'x-coderabbitai-api-key':
            '<api-key>'}};


            fetch('https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20',
            options)
              .then(res => res.json())
              .then(res => console.log(res))
              .catch(err => console.error(err));
        - lang: PHP
          label: PHP
          source: |-
            <?php
            $curl = curl_init();

            curl_setopt_array($curl, [
              CURLOPT_URL => 'https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20',
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => '',
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 30,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => 'GET',
              CURLOPT_HTTPHEADER => [
                'x-coderabbitai-api-key: <api-key>'
              ],
            ]);

            $response = curl_exec($curl);
            $err = curl_error($curl);
            curl_close($curl);

            if ($err) {
              echo 'cURL Error #:' . $err;
            } else {
              echo $response;
            }
            ?>
        - lang: Go
          label: Go
          source: "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io\"\n)\n\nfunc main() {\n\n\turl := \"https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"x-coderabbitai-api-key\", \"<api-key>\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := io.ReadAll(res.Body)\n\n\tfmt.Println(string(body))\n\n}"
        - lang: Java
          label: Java
          source: >-
            HttpResponse<String> response =
            Unirest.get("https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20")
              .header("x-coderabbitai-api-key", "<api-key>")
              .asString();
        - lang: Ruby
          label: Ruby
          source: >-
            require 'uri'

            require 'net/http'


            url =
            URI("https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20")


            http = Net::HTTP.new(url.host, url.port)

            http.use_ssl = true


            request = Net::HTTP::Get.new(url)

            request["x-coderabbitai-api-key"] = "<api-key>"


            response = http.request(request)

            puts response.read_body
components:
  schemas:
    ReviewMetric:
      type: object
      properties:
        pr_url:
          type: string
          description: Full URL to the pull request
        author_id:
          type: string
          description: Unique identifier assigned by Git provider
        author_username:
          type: string
          description: Username of the PR author
          nullable: true
        organization_id:
          type: string
          description: Unique identifier for the organization assigned by Git provider
        organization_name:
          type: string
          description: Organization name
        repository_id:
          type: string
          description: Unique identifier assigned by Git provider
        repository_name:
          type: string
          description: Repository name
          nullable: true
        created_at:
          type: string
          format: date-time
          description: When the PR was created
          nullable: true
        ready_for_review_at:
          type: string
          format: date-time
          description: >-
            When the PR became ready for review. Matches created_at if the PR
            was never a draft, and may be null for older records where this
            timestamp was not collected.
          nullable: true
        first_human_review_at:
          type: string
          format: date-time
          description: When the first human review was submitted
          nullable: true
        last_commit_at:
          type: string
          format: date-time
          description: When the last non-merge, non-rebased commit was pushed
          nullable: true
        merged_at:
          type: string
          format: date-time
          description: When the PR was merged
          nullable: true
        status:
          type: string
          enum:
            - merged
            - closed
          description: Current pull request status
        review_iterations:
          type: integer
          minimum: 0
          description: Number of CodeRabbit review events recorded for the pull request
        estimated_complexity:
          type: integer
          description: Complexity score (1-5)
          nullable: true
        estimated_review_minutes:
          type: integer
          description: Estimated time to review in minutes
          nullable: true
        coderabbit_comments:
          type: object
          description: CodeRabbit comment metrics grouped by total, severity, and category
          properties:
            total:
              $ref: '#/components/schemas/CommentCount'
            severity:
              type: object
              properties:
                critical:
                  $ref: '#/components/schemas/CommentCount'
                major:
                  $ref: '#/components/schemas/CommentCount'
                minor:
                  $ref: '#/components/schemas/CommentCount'
                trivial:
                  $ref: '#/components/schemas/CommentCount'
                info:
                  $ref: '#/components/schemas/CommentCount'
            category:
              type: object
              properties:
                SECURITY_AND_PRIVACY:
                  $ref: '#/components/schemas/CommentCount'
                PERFORMANCE_AND_SCALABILITY:
                  $ref: '#/components/schemas/CommentCount'
                FUNCTIONAL_CORRECTNESS:
                  $ref: '#/components/schemas/CommentCount'
                MAINTAINABILITY_AND_CODE_QUALITY:
                  $ref: '#/components/schemas/CommentCount'
                DATA_INTEGRITY_AND_INTEGRATION:
                  $ref: '#/components/schemas/CommentCount'
                STABILITY_AND_AVAILABILITY:
                  $ref: '#/components/schemas/CommentCount'
    Error:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
              message:
                type: string
            required:
              - code
              - message
      required:
        - errors
    CommentCount:
      type: object
      properties:
        posted:
          type: integer
          description: Number of comments posted
        accepted:
          type: integer
          description: Number of comments accepted
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-coderabbitai-api-key
      description: >-
        API key for authentication. You can create an API key from the
        CodeRabbit dashboard.

````

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