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

# Get a pull request and its review data

> Read one tracked pull or merge request by its Gitar ID. Requires pull_requests:read and advanced insights. Expand review for the latest completed review or functional_validation for linked issue objectives. The latter requires functional validation access.

Use the ID from the collection. Request `expand=review` for the latest stored review. Add `expand=functional_validation` to include linked issue checklists, available with Enterprise.

```sh theme={null}
curl -G "https://api.gitar.ai/v1/external/pull_requests/$PR_ID" \
  -H "Authorization: Bearer $GITAR_API_TOKEN" \
  --data-urlencode "expand=review" \
  --data-urlencode "expand=functional_validation"
```

`gitar_reviewed: true` means Gitar has completed at least one review on this PR, including reviews with zero findings. The expanded review includes its commit SHA and recorded risk assessment. Compare `review.commit_sha` with the current head SHA on the code host to check whether the review covers the latest revision. Older reviews can have a risk level without a reason.

Functional validation requires the corresponding feature entitlement. Each checklist identifies the issue and diff revision assessed. Its active objectives describe what the change covers. A pending objective may be addressed in a later change.


## OpenAPI

````yaml get /external/pull_requests/{id}
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/{id}:
    get:
      tags:
        - Pull requests
      summary: Get a pull request and its review data
      description: >-
        Read one tracked pull or merge request by its Gitar ID. Requires
        pull_requests:read and advanced insights. Expand review for the latest
        completed review or functional_validation for linked issue objectives.
        The latter requires functional validation access.
      operationId: getPullRequest
      parameters:
        - name: id
          in: path
          description: Gitar PR ID from the collection
          required: true
          schema:
            type: string
            format: uuid
        - name: expand
          in: query
          description: Related data to include. Repeat for both expansions.
          required: false
          schema:
            type: array
            items:
              $ref: '#/components/schemas/Expansion'
      responses:
        '200':
          description: Pull request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequest'
        '400':
          description: Invalid ID or expansion
        '401':
          description: Invalid or missing token
        '403':
          description: Missing scope or entitlement
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
        '404':
          description: Pull request unavailable to this organization
      security:
        - bearerAuth: []
components:
  schemas:
    Expansion:
      type: string
      enum:
        - review
        - functional_validation
    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
    ResponseFailure:
      type: object
      required:
        - message
      properties:
        error_code:
          type:
            - string
            - 'null'
        message:
          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.