Create a GitHub pull request
github_pr_createCreates a pull request from a pushed branch, setting title, body, draft status, labels, assignees, reviewers, milestone, closing issues, and project board fields in one validated call.
Instructions
Open a pull request from a pushed branch of a repository the viewer may write to into another branch of it (default: the default branch), and settle its place in the same call: draft, labels, assignees and reviewers (they are notified), milestone, the issues it closes (a Closes #12 line at the end of the body) and a project board with field values (the Status starts as Todo). Pull requests from forks are not supported yet. Everything that can fail is checked before the pull request is made: the branches exist, head_sha (when given) is still the head, no pull request is open from head into base already, the milestone exists and the board accepts the values. A pull request that was made is always returned, even when GitHub reported a failure while making it or a later step fails (labels, assignees, reviewers and milestone are applied right after it is made; then the read-back, board and field steps): what failed after it is listed in errors, keyed by step (create, attachments, metadata, read, head_sha, project, fields.). GitHub links closing issues only for a pull request into the default branch, and a moment after it exists: the call waits up to a few seconds for the link, and notes say when this pull request is not into the default branch or an issue was not linked yet. A pull request is 12, #12, owner/repo#12 or its URL; a bare number in closes means the pull request's repository. A board is named by project: its number, owner/number or its URL, used as it is; any other project is a title, and no project is Roadmap: the open board of that whole title is looked up, never guessed, in owner's boards if owner is given, else in the boards linked to repo, then its organization's, then the viewer's. Field values are set by field name and option or iteration name, matched without regard to case: text as a string, number as a number or numeric string, date as YYYY-MM-DD, single select as an option name, iteration as an iteration title or @current (the iteration containing today, UTC). Only text, number, date, single select and iteration fields can be set; a column that mirrors an issue field is set with the issue tools' issue_fields, not here. GitHub's own (Title, Assignees, Labels, Milestone, Repository, Linked pull requests, …) are set on the issue, and github_issue_edit sets assignees, labels and milestone. Every field and value is checked before anything is written. Needs a token with the project scope; if GitHub reports missing scopes, run gh auth refresh -s project. Attachments are images (png, jpg, gif, webp, svg, up to 10 MiB) and videos (mp4, mov, webm, up to 100 MiB), up to 50, uploaded with the text: a body reference like  becomes the uploaded file and the others are appended; they need gh 2.99 or newer, and a file that fails to upload is listed under errors.attachments while the rest goes through.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| base | No | The branch of the repository to merge into; defaults to its default branch. | |
| body | No | Markdown body; empty when left out. | |
| head | Yes | The branch of the repository to merge from; it must be pushed already. | |
| repo | No | owner/name; defaults to the working tree's repository (its origin). | |
| draft | No | Open it as a draft (default false). | |
| title | Yes | The pull request's title. | |
| closes | No | Issues this pull request closes when it merges, as 12, #12, owner/repo#12 or an issue URL (a bare number means the pull request's repository): a `Closes #12` line is added to the end of the body. GitHub links them only for a pull request into the default branch. | |
| fields | No | Board field values to set, by field name: {"Target": "2026-12-01"}; needs project. A Status given here replaces the Todo default. | |
| labels | No | Labels to add; they must exist. | |
| project | No | A board to put the pull request on: its number, owner/number or its URL, or its title; none by default. The pull request starts as Todo on the board when it has that Status option. | |
| head_sha | No | The commit the head branch must be at (40 hex characters): the call fails with stale, creating nothing, when the branch moved. | |
| assignees | No | Logins, or "@me". | |
| milestone | No | A milestone title; it must exist. | |
| reviewers | No | Logins, or org/team, to request a review from; they are notified. | |
| attachments | No | Images and videos to upload with the text. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pr | Yes | ||
| base | Yes | ||
| head | Yes | ||
| repo | Yes | ||
| draft | Yes | ||
| notes | Yes | What to know about the result; [] when nothing. | |
| errors | Yes | Failed steps, keyed by step (fields.<Field name>, blocked_by, kind, labels, milestone); {} when none. | |
| foreign | Yes | ||
| project | Yes | The board item; null when no project was given or its step failed. | |
| head_sha | Yes | The commit the head branch is at, as read after the pull request was created. | |
| attachments | Yes | The files that were sent; [] when none were given. | |
| closing_issues | Yes | The issues GitHub links as closed by the pull request; [] when none or when it could not be read. |