{"meta":{"title":"REST API endpoints for stacked pull requests","intro":"Use the REST API to interact with stacked pull requests.","product":"REST API","breadcrumbs":[{"href":"/en/rest","title":"REST API"},{"href":"/en/rest/pulls","title":"Pull requests"},{"href":"/en/rest/pulls/stacks","title":"Stacked pull requests"}],"documentType":"article"},"body":"# REST API endpoints for stacked pull requests\n\nUse the REST API to interact with stacked pull requests.\n\n> [!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## List pull request stacks\n\n```\nGET /repos/{owner}/{repo}/stacks\n```\n\nLists pull request stacks in a repository.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`pull_request`** (integer)\n  Filter to the stack containing this repository pull request number.\n\n- **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n- **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **404** - Resource not found\n\n- **422** - Validation failed, or the endpoint has been spammed.\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/stacks\n```\n\n**Response schema (Status: 200):**\n\nArray of `Pull Request Stack Minimal`:\n  * `id`: required, integer\n  * `number`: required, integer\n  * `node_id`: required, string\n  * `url`: required, string, format: uri\n  * `base`: required, object:\n    * `ref`: required, string\n  * `open`: required, boolean\n  * `created_at`: required, string, format: date-time\n  * `pull_requests`: required, array of objects:\n    * `number`: required, integer\n    * `state`: required, string, enum: `open`, `closed`\n    * `draft`: required, boolean\n    * `merged_at`: required, string or null, format: date-time\n    * `head`: required, object:\n      * `ref`: required, string\n      * `sha`: required, string\n\n## Create a pull request stack\n\n```\nPOST /repos/{owner}/{repo}/stacks\n```\n\nCreates a stack from an ordered list of pull request numbers. Provide the pull\nrequest numbers from the bottom of the stack to the top. Each pull request's\nbase ref must match the previous pull request's head ref.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n#### Body parameters\n\n- **`pull_requests`** (array of integers) (required)\n  An ordered list of pull request numbers forming the stack from bottom to top.\n\n### HTTP response status codes\n\n- **201** - Created\n\n- **404** - Resource not found\n\n- **422** - Validation failed. Returned when the request references pull requests that\ndon't exist in the repository, or when the pull requests can't form a\nvalid stack.\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/repos/OWNER/REPO/stacks \\\n  -d '{\n  \"pull_requests\": [\n    101,\n    102,\n    103\n  ]\n}'\n```\n\n**Response schema (Status: 201):**\n\n* `id`: required, integer\n* `number`: required, integer\n* `node_id`: required, string\n* `url`: required, string, format: uri\n* `base`: required, object:\n  * `ref`: required, string\n* `open`: required, boolean\n* `created_at`: required, string, format: date-time\n* `pull_requests`: required, array of object\n\n## Get a pull request stack\n\n```\nGET /repos/{owner}/{repo}/stacks/{stack_number}\n```\n\nGets a pull request stack by providing its stack number.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`stack_number`** (integer) (required)\n  The number that identifies the pull request stack.\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/stacks/STACK_NUMBER\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a pull request stack](#create-a-pull-request-stack).\n\n## Add pull requests to a pull request stack\n\n```\nPOST /repos/{owner}/{repo}/stacks/{stack_number}/add\n```\n\nAppends an ordered list of pull request numbers onto the top of an existing\nstack. Provide only the pull requests you want to add, from the current top of\nthe stack upward. The first new pull request's base ref must match the current\ntop pull request's head ref.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`stack_number`** (integer) (required)\n  The number that identifies the pull request stack.\n\n#### Body parameters\n\n- **`pull_requests`** (array of integers) (required)\n  An ordered list of pull request numbers to append to the stack, from the current top upward.\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **404** - Resource not found\n\n- **409** - Conflict. Returned when the stack is being modified by another request.\n\n- **422** - Validation failed. Returned when the request references pull requests that\ndon't exist in the repository, or when the pull requests can't be appended\nto the stack.\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/repos/OWNER/REPO/stacks/STACK_NUMBER/add \\\n  -d '{\n  \"pull_requests\": [\n    104,\n    102\n  ]\n}'\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a pull request stack](#create-a-pull-request-stack).\n\n## Remove pull requests from a pull request stack\n\n```\nPOST /repos/{owner}/{repo}/stacks/{stack_number}/unstack\n```\n\nRemoves the unmerged pull requests from a stack. Pull requests that cannot be\nunstacked (for example, those that are queued for merge) are left in place. When pull requests remain in the stack, the updated\nstack is returned with a 200. When no pull requests remain, the stack is\ndissolved and a 204 is returned.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`stack_number`** (integer) (required)\n  The number that identifies the pull request stack.\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **204** - A header with no content is returned.\n\n- **404** - Resource not found\n\n- **409** - Conflict. Returned when the stack is being modified by another request.\n\n- **422** - Validation failed. Returned when the stack can't be unstacked because every\npull request in it is locked and cannot be removed.\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/repos/OWNER/REPO/stacks/STACK_NUMBER/unstack\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a pull request stack](#create-a-pull-request-stack)."}