{"meta":{"title":"Actions 并发组的 REST API 终结点","intro":"使用 REST API 查看和管理GitHub Actions工作流的并发组。","product":"REST API","breadcrumbs":[{"href":"/zh/rest","title":"REST API"},{"href":"/zh/rest/actions","title":"操作"},{"href":"/zh/rest/actions/concurrency-groups","title":"操作并发组"}],"documentType":"article"},"body":"# Actions 并发组的 REST API 终结点\n\n使用 REST API 查看和管理GitHub Actions工作流的并发组。\n\n## 关于GitHub Actions中的并发组\n\n可以使用 REST API 读取并发组GitHub Actions的状态，该组可以确保只有一个使用同一组的作业或工作流能够运行，而其他运行将根据配置处于待定或取消状态。 有关详细信息，请参阅“[控制工作流和作业的并发性](/zh/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency)”。\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 concurrency groups for a repository\n\n```\nGET /repos/{owner}/{repo}/actions/concurrency_groups\n```\n\nLists the active concurrency groups for a repository.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private 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* **`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* **`after`** (string)\n  A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see \"Using pagination in the REST API.\"\n\n### HTTP response status codes\n\n* **200** - OK\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/actions/concurrency_groups\n```\n\n**Response schema (Status: 200):**\n\n* `total_count`: required, integer\n* `concurrency_groups`: required, array of objects:\n  * `group_name`: required, string\n  * `group_url`: required, string, format: uri\n  * `last_acquired_at`: required, string or null, format: date-time\n\n## Get a concurrency group for a repository\n\n```\nGET /repos/{owner}/{repo}/actions/concurrency_groups/{concurrency_group_name}\n```\n\nGets a specific concurrency group for a repository, including all instances in the group's queue.\nReturns 404 if the group is inactive or does not exist.\nOptionally, pass ahead\\_of\\_run or ahead\\_of\\_job to filter the results to only the items\nahead of the specified workflow run or job in the queue, plus the specified item itself\n(returned as the last element). This is useful for determining what is blocking a particular\nrun or job. Returns 422 if the specified run or job is not in this concurrency group.\nWhen using ahead\\_of\\_run, this matches workflow-level concurrency and any reusable-workflow\nleases held on behalf of that run. Job-level leases within the run are not considered to\nblock the run as a whole. Use ahead\\_of\\_job to match job-level concurrency and reusable-workflow\nleases on the job's ancestor paths.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private 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* **`concurrency_group_name`** (string) (required)\n  The name of the concurrency group.\n\n* **`ahead_of_run`** (integer)\n  Filter to items ahead of this workflow run ID in the queue, plus the run itself.\n  Matches workflow-level concurrency and reusable-workflow leases held on behalf of\n  the run. Mutually exclusive with ahead\\_of\\_job.\n\n* **`ahead_of_job`** (integer)\n  Filter to items ahead of this job ID in the queue, plus the job itself.\n  Matches job-level concurrency and reusable-workflow leases on the job's\n  ancestor paths. Mutually exclusive with ahead\\_of\\_run.\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/actions/concurrency_groups/CONCURRENCY_GROUP_NAME\n```\n\n**Response schema (Status: 200):**\n\n* `group_name`: required, string\n* `group_url`: required, string, format: uri\n* `total_count`: required, integer\n* `group_members`: required, array of objects:\n  * `run_id`: required, integer\n  * `run_name`: required, string\n  * `run_url`: required, string or null, format: uri\n  * `run_html_url`: required, string or null, format: uri\n  * `job_id`: integer\n  * `job_name`: string\n  * `job_url`: string or null, format: uri\n  * `job_html_url`: string or null, format: uri\n  * `status`: required, string, enum: `in_progress`, `pending`\n\n## List concurrency groups for a workflow run\n\n```\nGET /repos/{owner}/{repo}/actions/runs/{run_id}/concurrency_groups\n```\n\nLists all concurrency groups associated with a workflow run or its jobs.\nThe set of groups is derived from the run's configuration, so a group is\nincluded even when the run no longer has any items currently holding or\nwaiting in it. In that case the group\\_members array will be empty.\ntotal\\_count reflects the number of groups the run participates in by\nconfiguration, not the number with active items.\nThis differs from GET /repos/{owner}/{repo}/actions/concurrency\\_groups/{group\\_name},\nwhich returns 404 when a group has no active items. That endpoint reports\nthe live state of a group repo-wide, while this endpoint reports the\ngroups associated with a specific run by configuration.\nResults are sorted by group name and support cursor-based pagination via\nbefore and after. The after cursor paginates forward only and does\nnot emit a rel=\"prev\" Link; use before to page backward from a\nforward page's next cursor.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private 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* **`run_id`** (integer) (required)\n  The unique identifier of the workflow run.\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* **`before`** (string)\n  A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see \"Using pagination in the REST API.\"\n\n* **`after`** (string)\n  A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see \"Using pagination in the REST API.\"\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/actions/runs/RUN_ID/concurrency_groups\n```\n\n**Response schema (Status: 200):**\n\n* `total_count`: required, integer\n* `concurrency_groups`: required, array of objects:\n  * `group_name`: required, string\n  * `group_url`: required, string, format: uri\n  * `group_members`: required, array of objects:\n    * `run_id`: required, integer\n    * `run_name`: required, string\n    * `run_url`: required, string or null, format: uri\n    * `run_html_url`: required, string or null, format: uri\n    * `position`: required, integer\n    * `position_url`: required, string, format: uri\n    * `job_id`: integer or null\n    * `job_name`: string or null\n    * `job_url`: string or null, format: uri\n    * `job_html_url`: string or null, format: uri\n    * `status`: required, string, enum: `in_progress`, `pending`"}