Overview
The Pull Requests API enables you to manage pull requests in your repositories. You can create PRs, list them with various filters, update their properties, merge them, and check merge status.Pull Request Object
The PullRequest object represents a pull request with the following structure:integer
The unique identifier of the pull request
integer
The pull request number (index) in the repository
string
The title of the pull request
string
The description body content of the pull request
string
default:"open"
The current state of the pull request. Possible values:
open, closedboolean
Whether the pull request is a draft (work in progress)
object
The user who created the pull request
object
Information about the target (base) branch
object
Information about the source (head) branch
string
The commit SHA of the merge base
boolean
Whether the pull request can be merged
boolean
Whether the pull request has been merged
string
Timestamp when the PR was merged (RFC 3339 format)
object
The user who merged the pull request
boolean
Whether maintainers can edit the pull request
array
Array of label objects attached to the pull request
array
Array of user objects assigned to review the pull request
array
Array of user objects requested to review the pull request
integer
The number of comments on the pull request
integer
The number of review comments on the pull request diff
integer
The number of lines added in the pull request
integer
The number of lines deleted in the pull request
integer
The number of files changed in the pull request
Operations
- List Pull Requests
- Get Pull Request
- Create Pull Request
- Update Pull Request
- Merge Pull Request
List Repository Pull Requests
List all pull requests in a specific repository.Endpoint:GET /api/v1/repos/{owner}/{repo}/pullsPath Parameters
string
required
Owner of the repository
string
required
Name of the repository
Query Parameters
string
default:"open"
Filter by pull request state. Options:
open, closed, allstring
Filter by target base branch of the pull request
string
Sort order. Options:
oldest, recentupdate, recentclose, leastupdate, mostcomment, leastcomment, priorityinteger
Filter by milestone ID
array
Array of label IDs to filter by
string
Filter by pull request author username
integer
default:"1"
Page number for pagination (1-based)
integer
Number of items per page
Example Request
Response
Additional Operations
Check Merge Status
Check if a pull request has been merged. Endpoint:GET /api/v1/repos/{owner}/{repo}/pulls/{index}/merge
Path Parameters
string
required
Owner of the repository
string
required
Name of the repository
integer
required
Index number of the pull request
Example Request
Response
- 204 No Content - Pull request has been merged
- 404 Not Found - Pull request has not been merged
Update Pull Request Branch
Merge the base branch into the head branch to update the pull request. Endpoint:POST /api/v1/repos/{owner}/{repo}/pulls/{index}/update
Path Parameters
string
required
Owner of the repository
string
required
Name of the repository
integer
required
Index number of the pull request
Query Parameters
string
How to update the pull request. Options:
merge, rebaseExample Request
Response (200 OK)
No response body is returned on success.Cancel Auto-Merge
Cancel a scheduled auto-merge for a pull request. Endpoint:DELETE /api/v1/repos/{owner}/{repo}/pulls/{index}/merge
Path Parameters
string
required
Owner of the repository
string
required
Name of the repository
integer
required
Index number of the pull request
Example Request
Response (204 No Content)
No response body is returned on success.Get Pull Request by Base and Head
Get a pull request by specifying base and head branches. Endpoint:GET /api/v1/repos/{owner}/{repo}/pulls/{base}/{head}
Path Parameters
string
required
Owner of the repository
string
required
Name of the repository
string
required
Base branch name
string
required
Head branch. Format:
branch or username:branch for forksExample Request
Get Pull Request Commits
Get all commits for a pull request. Endpoint:GET /api/v1/repos/{owner}/{repo}/pulls/{index}/commits
Query Parameters
integer
default:"1"
Page number for pagination
integer
Number of items per page
boolean
default:"true"
Include verification for every commit
boolean
default:"true"
Include list of affected files for every commit
Example Request
Get Pull Request Files
Get all changed files in a pull request. Endpoint:GET /api/v1/repos/{owner}/{repo}/pulls/{index}/files
Query Parameters
string
Skip to given file
string
Whitespace behavior. Options:
ignore-all, ignore-change, ignore-eol, show-allinteger
default:"1"
Page number for pagination
integer
Number of items per page
Example Request
Download Diff or Patch
Download the diff or patch file for a pull request. Endpoint:GET /api/v1/repos/{owner}/{repo}/pulls/{index}.{diffType}
Path Parameters
string
required
Output format. Options:
diff, patchQuery Parameters
boolean
Whether to include binary file changes
Example Request
Error Responses
Forbidden
User does not have permission to perform the operation
Not Found
Repository or pull request not found
Method Not Allowed
Operation not allowed (e.g., cannot merge a work-in-progress PR)
Conflict
Merge conflict or duplicate pull request
Unprocessable Entity
Validation error (e.g., invalid base/head branches)
Locked
Repository is archived and cannot be modified