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

# List pull requests and review data

> List tracked pull and merge requests, including those with zero findings. Requires pull_requests:read and advanced insights. Request functional_validation to include issue checklists when entitled. Batch lookup returns one row per matched PR. Unmatched URLs are omitted. Use updated_after for incremental reads and upsert by id.

An organization admin can create a **Review data (read only)** key in **Settings > API Keys**. The key reads review data for the organization. The organization needs API access and advanced insights.

To look up known pull or merge requests, repeat the URL parameter. Each matched request appears once, including reviewed requests with zero findings. Keep unmatched URLs in the source dataset when calculating coverage.

```sh theme={null}
curl -G https://api.gitar.ai/v1/external/pull_requests \
  -H "Authorization: Bearer $GITAR_API_TOKEN" \
  --data-urlencode "url=https://gitlab.example.com/team/api/-/merge_requests/32" \
  --data-urlencode "url=https://gitlab.example.com/team/api/-/merge_requests/45"
```

Finding counts describe the latest stored review for each PR and reflect later status changes for those findings. To measure coverage of the current revision, request `expand=review` and compare `review.commit_sha` with the current head SHA on the code host.

For incremental syncs, pass an inclusive RFC 3339 `updated_after` timestamp, follow `next_cursor` with the same filters and upsert by `id`. Save the time the sync started after processing its last page so changes during pagination are picked up on the next sync.


## OpenAPI

````yaml get /external/pull_requests
openapi: 3.1.0
info:
  title: Gitar External API
  description: Read review data and manage your Gitar installation and integrations
  contact:
    name: Gitar
    url: https://gitar.ai
    email: noreply@gitar.ai
  license:
    name: ''
  version: 1.0.0
servers:
  - url: https://api.gitar.ai/v1
security: []
paths:
  /external/pull_requests:
    get:
      tags:
        - Pull requests
      summary: List pull requests and review data
      description: >-
        List tracked pull and merge requests, including those with zero
        findings. Requires pull_requests:read and advanced insights. Request
        functional_validation to include issue checklists when entitled. Batch
        lookup returns one row per matched PR. Unmatched URLs are omitted. Use
        updated_after for incremental reads and upsert by id.
      operationId: listPullRequests
      parameters:
        - name: url
          in: query
          description: >-
            Match a PR or MR web URL. Repeat up to 100 times. Overrides
            collection filters.
          required: false
          schema:
            type: array
            items:
              type: string
        - name: repository
          in: query
          description: Full repository path. Repeat to select multiple repositories.
          required: false
          schema:
            type: array
            items:
              type: string
        - name: state
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/RequestState'
        - name: merged_after
          in: query
          description: Inclusive lower bound on merge time.
          required: false
          schema:
            type: string
            format: date-time
        - name: merged_before
          in: query
          description: Exclusive upper bound on merge time.
          required: false
          schema:
            type: string
            format: date-time
        - name: updated_after
          in: query
          description: Inclusive lower bound on changes to the resource.
          required: false
          schema:
            type: string
            format: date-time
        - name: expand
          in: query
          description: Related data to include. Repeat for both expansions.
          required: false
          schema:
            type: array
            items:
              $ref: '#/components/schemas/Expansion'
        - name: limit
          in: query
          description: Page size, default 50.
          required: false
          schema:
            type: integer
            format: int32
            maximum: 100
            minimum: 1
        - name: cursor
          in: query
          description: >-
            Continue with the opaque next_cursor from the previous page and the
            same filters.
          required: false
          schema:
            type: string
      responses:
        '200':
          description: Pull request page
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestList'
        '400':
          description: Invalid filter, cursor or expansion
        '401':
          description: Invalid or missing token
        '403':
          description: Missing scope or entitlement
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
      security:
        - bearerAuth: []
components:
  schemas:
    RequestState:
      type: string
      enum:
        - open
        - merged
        - closed
        - declined
    Expansion:
      type: string
      enum:
        - review
        - functional_validation
    PullRequestList:
      type: object
      required:
        - data
        - has_more
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/PullRequest'
        has_more:
          type: boolean
        next_cursor:
          type:
            - string
            - 'null'
    ResponseFailure:
      type: object
      required:
        - message
      properties:
        error_code:
          type:
            - string
            - 'null'
        message:
          type: string
    PullRequest:
      type: object
      required:
        - id
        - url
        - repository_id
        - repository
        - state
        - first_seen_at
        - updated_at
        - gitar_reviewed
        - findings_summary
      properties:
        author:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Author'
        closed_at:
          type:
            - string
            - 'null'
          format: date-time
        findings_summary:
          $ref: '#/components/schemas/FindingsSummary'
        first_seen_at:
          type: string
          format: date-time
          description: When Gitar first tracked this PR.
        functional_validation:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/IssueChecklist'
          description: >-
            Omitted unless expanded. Includes the active objectives of visible
            linked issues.
        gitar_reviewed:
          type: boolean
          description: Gitar has completed and stored at least one review on this PR.
        id:
          type: string
          format: uuid
        merged_at:
          type:
            - string
            - 'null'
          format: date-time
        number:
          type:
            - integer
            - 'null'
          format: int32
        opened_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the code host opened the PR, when recorded.
        platform:
          type:
            - string
            - 'null'
        repository:
          type: string
        repository_id:
          type: string
          format: uuid
        review:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Review'
              description: Omitted unless expanded. Null when there is no stored review.
        state:
          type: string
        updated_at:
          type: string
          format: date-time
        url:
          type: string
    Author:
      type: object
      required:
        - username
      properties:
        username:
          type: string
    FindingsSummary:
      type: object
      required:
        - total
        - by_category
        - by_severity
      properties:
        by_category:
          type: object
          description: Categories can grow as new kinds of findings are added.
          additionalProperties:
            $ref: '#/components/schemas/FindingCounts'
          propertyNames:
            type: string
        by_severity:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/FindingCounts'
          propertyNames:
            type: string
        total:
          $ref: '#/components/schemas/FindingCounts'
    IssueChecklist:
      type: object
      required:
        - provider
        - issue_key
        - objectives
      properties:
        assessed_diff_sha:
          type:
            - string
            - 'null'
        issue_key:
          type: string
        issue_url:
          type:
            - string
            - 'null'
        objectives:
          type: array
          items:
            $ref: '#/components/schemas/ChecklistObjective'
        provider:
          type: string
    Review:
      type: object
      required:
        - id
        - commit_sha
        - reviewed_at
      properties:
        commit_sha:
          type: string
        id:
          type: string
          format: uuid
        reviewed_at:
          type: string
          format: date-time
        risk:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ReviewRisk'
        verdict:
          type:
            - string
            - 'null'
    FindingCounts:
      type: object
      required:
        - total
        - open
        - resolved
        - dismissed
        - wont_fix
      properties:
        dismissed:
          type: integer
          format: int64
          minimum: 0
        open:
          type: integer
          format: int64
          minimum: 0
        resolved:
          type: integer
          format: int64
          description: >-
            Includes finalized acknowledgements. Resolution alone does not
            establish a code fix.
          minimum: 0
        total:
          type: integer
          format: int64
          minimum: 0
        wont_fix:
          type: integer
          format: int64
          minimum: 0
    ChecklistObjective:
      type: object
      required:
        - id
        - text
        - status
      properties:
        id:
          type: string
          description: Stable within the linked issue.
        status:
          type: string
          description: 'Assessment against the PR diff: complete or pending.'
        text:
          type: string
    ReviewRisk:
      type: object
      required:
        - level
      properties:
        level:
          type: string
          description: 'Whole-PR risk: low, medium, or high.'
        reason:
          type:
            - string
            - 'null'
          description: Older reviews can have a level without a recorded reason.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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