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

# Get PR metrics for organization

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

> [tab] CLI Tool
>
> ```bash
> coderabbit api request "/metrics/reviews?start_date=$START_DATE&end_date=$END_DATE"
> ```
>
> To install and sign in to the CLI, see [Call from the CLI](https://docs.coderabbit.ai/api/cli.md).

> [tab] MCP Server
>
> This operation isn't a tool on the [CodeRabbit MCP server](https://docs.coderabbit.ai/api/mcp.md). Call it over REST or from the CLI.

With `format=csv`, the file has one row per pull request, and the nested `coderabbit_comments` object becomes flat columns such as `total_coderabbit_comments_posted`. A CSV response is a single page of up to `limit` rows, with no cursor. See [Download review metrics as CSV](https://docs.coderabbit.ai/api/guides/metrics-and-usage.md#download-review-metrics-as-csv).


## OpenAPI

````yaml /openapi.json get /v1/metrics/reviews
openapi: 3.0.0
info:
  title: CodeRabbit API
  version: 1.0.0
  description: >-
    Read and manage CodeRabbit reviews, coding tasks, Verify, Triage, security
    findings, Knowledge Base, configuration, and users for your organization.
servers:
  - url: https://api.coderabbit.ai
    description: US region
  - url: https://api.eu.coderabbit.ai
    description: EU region
security:
  - ApiKeyAuth: []
tags:
  - name: Organizations and repositories
  - name: Pull requests and reviews
  - name: Coding Agent
  - name: Coding environments
  - name: Verify
  - name: Triage
  - name: Security
  - name: Knowledge Base
  - name: Automations
  - name: Reports
  - name: Configuration
  - name: Connections
  - name: Users and roles
  - name: Usage and metrics
paths:
  /v1/metrics/reviews:
    get:
      tags:
        - Usage and metrics
      summary: Get PR metrics for organization
      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:
        - $ref: '#/components/parameters/WorkspaceOrgName'
        - in: query
          name: org_id
          required: false
          schema:
            type: string
          description: >-
            Workspace-scoped API tokens only. Supply this git-provider
            organization ID or org_name, never both, to scope metrics to one
            organization. When both selectors are omitted, aggregates every
            organization in the workspace. This org_id parameter is ignored for
            organization and self-hosted keys.
        - in: query
          name: start_date
          required: true
          schema:
            type: string
            format: date
            example: '2025-10-15'
          description: >-
            Inclusive merge date for merged PRs or close date for closed PRs
            (YYYY-MM-DD format)
        - in: query
          name: end_date
          required: true
          schema:
            type: string
            format: date
            example: '2025-11-15'
          description: >-
            Inclusive merge date for merged PRs or close date for closed PRs
            (YYYY-MM-DD format)
        - in: query
          name: status
          schema:
            type: string
            enum:
              - merged
              - closed
              - all
            default: merged
          description: >-
            Merged selects reviewed PRs by merge time, closed selects
            closed-unmerged reviewed PRs by close time, and all combines both
            finalized states.
        - in: query
          name: repository_ids
          schema:
            type: string
            example: 1027529638,987654321
          description: >-
            Comma-separated list of provider repository IDs to filter (e.g.,
            GitHub repo IDs). Max 10.
        - in: query
          name: user_ids
          schema:
            type: string
            example: 87397876,12345678
          description: >-
            Comma-separated list of provider user IDs to filter (e.g., GitHub
            user IDs). Max 10.
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1000
          description: Maximum number of results to return
        - in: query
          name: cursor
          schema:
            type: string
          description: Pagination cursor from previous response
        - in: query
          name: organization_ids
          schema:
            type: string
            example: 184456712,103539130
          description: >-
            Comma-separated list of provider organization IDs to filter (e.g.,
            GitHub org IDs). Only supported for self-hosted instances.
        - in: query
          name: format
          schema:
            type: string
            enum:
              - json
              - csv
            default: json
          description: >-
            Response format. JSON returns structured data with pagination. CSV
            returns flat file download.
      responses:
        '200':
          description: Successfully retrieved PR metrics
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      required:
                        - pr_url
                        - organization_id
                        - organization_name
                        - repository_id
                        - author_id
                        - created_at
                        - coderabbit_comments
                      properties:
                        pr_url:
                          type: string
                          example: https://github.com/org/repo/pull/123
                        organization_id:
                          type: string
                          description: Provider organization ID (e.g., GitHub org ID)
                          example: '184456712'
                        organization_name:
                          type: string
                        repository_id:
                          type: string
                        repository_name:
                          type: string
                          nullable: true
                        author_id:
                          type: string
                        author_username:
                          type: string
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: Pull request creation time.
                        ready_for_review_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: Time the pull request became ready for review.
                        first_human_review_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: >-
                            First human review comment timestamp. Excludes the
                            pull request author, blank or whitespace-only
                            usernames, recognized service or automation
                            accounts, and accounts marked as bots in the
                            matching tenant and source-control provider. Null if
                            no qualifying human review exists.
                        last_commit_at:
                          type: string
                          format: date-time
                          nullable: true
                        merged_at:
                          type: string
                          format: date-time
                          nullable: true
                        status:
                          type: string
                          enum:
                            - closed
                            - merged
                          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
                          nullable: true
                        estimated_review_minutes:
                          type: integer
                          nullable: true
                        coderabbit_comments:
                          type: object
                          properties:
                            total:
                              type: object
                              properties:
                                posted:
                                  type: integer
                                accepted:
                                  type: integer
                            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:
                                DATA_INTEGRITY_AND_INTEGRATION:
                                  $ref: '#/components/schemas/CommentCount'
                                FUNCTIONAL_CORRECTNESS:
                                  $ref: '#/components/schemas/CommentCount'
                                MAINTAINABILITY_AND_CODE_QUALITY:
                                  $ref: '#/components/schemas/CommentCount'
                                PERFORMANCE_AND_SCALABILITY:
                                  $ref: '#/components/schemas/CommentCount'
                                SECURITY_AND_PRIVACY:
                                  $ref: '#/components/schemas/CommentCount'
                                STABILITY_AND_AVAILABILITY:
                                  $ref: '#/components/schemas/CommentCount'
                  next_cursor:
                    type: string
                    nullable: true
                    description: Cursor for fetching the next page of results
            text/csv:
              schema:
                type: string
                format: binary
                description: CSV file download with flat columns for all metrics fields
        '400':
          description: Bad request - Invalid input parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        message:
                          type: string
              examples:
                invalidDateFormat:
                  value:
                    errors:
                      - message: 'start_date: start_date must be YYYY-MM-DD format'
        '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:
                        code:
                          type: string
                          enum:
                            - RATE_LIMIT_EXCEEDED
                            - METRICS_BUSY
                            - METRICS_QUERY_IN_PROGRESS
                        message:
                          type: string
              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: []
components:
  parameters:
    WorkspaceOrgName:
      in: query
      name: org_name
      required: false
      schema:
        $ref: '#/components/schemas/PlatformOrgName'
      description: >-
        GitHub organization login for a workspace API key, matched
        case-insensitively within that workspace. Supply either org_name or
        org_id, never both; omit for an organization-bound key.
  schemas:
    CommentCount:
      type: object
      properties:
        posted:
          type: integer
          description: Number of comments posted
        accepted:
          type: integer
          description: Number of comments accepted
    PlatformOrgName:
      type: string
      pattern: ^[A-Za-z0-9][A-Za-z0-9-]{0,38}$
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-coderabbitai-api-key
      description: >-
        See [Authentication](/api/authentication) for the key types and where to
        create a key.

````

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