{"meta":{"title":"Dependabot 存储库访问的 REST API 终结点","intro":"使用 REST API 管理 Dependabot 在组织内可访问的仓库。","product":"REST API","breadcrumbs":[{"href":"/zh/enterprise-cloud@latest/rest","title":"REST API"},{"href":"/zh/enterprise-cloud@latest/rest/dependabot","title":"Dependabot"},{"href":"/zh/enterprise-cloud@latest/rest/dependabot/repository-access","title":"存储库访问"}],"documentType":"article"},"body":"# {% data variables.product.prodname_dependabot %} 存储库访问的 REST API 终结点\n\n使用 REST API 管理 Dependabot 在组织内可访问的仓库。\n\n## 关于 Dependabot 存储库访问\n\n可以列出 Dependabot 已有权访问的仓库，并为 Dependabot 设置默认仓库访问级别。\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## Lists the repositories Dependabot can access in an enterprise\n\n```\nGET /enterprises/{enterprise}/dependabot/repository-access\n```\n\nLists repositories that enterprise admins have allowed Dependabot to access when updating dependencies across organizations in the enterprise.\nThe authenticated user must be an enterprise owner to use this endpoint.\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- **`enterprise`** (string) (required)\n  The slug version of the enterprise name.\n\n- **`page`** (integer)\n  The page number of results to fetch.\n  Default: `1`\n\n- **`per_page`** (integer)\n  Number of results per page.\n  Default: `30`\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **403** - Forbidden\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/enterprises/ENTERPRISE/dependabot/repository-access\n```\n\n**Response schema (Status: 200):**\n\n* `default_level`: string or null, enum: `public`, `internal`, `null`\n* `accessible_repositories`: array of object\n\n## Updates Dependabot's repository access list for an enterprise\n\n```\nPATCH /enterprises/{enterprise}/dependabot/repository-access\n```\n\nUpdates repositories according to the list of repositories that enterprise admins have given Dependabot access to when they've updated dependencies across organizations in the enterprise.\nThe authenticated user must be an enterprise owner to use this endpoint.\nExample request body:\n{\n  \"repository_ids_to_add\": [123, 456],\n  \"repository_ids_to_remove\": [789]\n}\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- **`enterprise`** (string) (required)\n  The slug version of the enterprise name.\n\n#### Body parameters\n\n- **`repository_ids_to_add`** (array of integers)\n  List of repository IDs to add.\n\n- **`repository_ids_to_remove`** (array of integers)\n  List of repository IDs to remove.\n\n### HTTP response status codes\n\n- **204** - No Content\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example with a 'succeeded' status.\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PATCH \\\n  https://api.github.com/enterprises/ENTERPRISE/dependabot/repository-access\n```\n\n**Response schema (Status: 204):**\n\n## Set the default repository access level for Dependabot in an enterprise\n\n```\nPUT /enterprises/{enterprise}/dependabot/repository-access/default-level\n```\n\nSets the default level of repository access Dependabot will have while performing an update across organizations in the enterprise. Available values are:\n\n'public' - Dependabot will only have access to public repositories, unless access is explicitly granted to non-public repositories.\n'internal' - Dependabot will only have access to public and internal repositories, unless access is explicitly granted to private repositories.\n\nThe authenticated user must be an enterprise owner to use this endpoint.\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- **`enterprise`** (string) (required)\n  The slug version of the enterprise name.\n\n#### Body parameters\n\n- **`default_level`** (string) (required)\n  The default repository access level for Dependabot updates.\n  Can be one of: `public`, `internal`\n\n### HTTP response status codes\n\n- **204** - No Content\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example with a 'succeeded' status.\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PUT \\\n  https://api.github.com/enterprises/ENTERPRISE/dependabot/repository-access/default-level \\\n  -d '{\n  \"default_level\": \"public\"\n}'\n```\n\n**Response schema (Status: 204):**\n\n## Lists the repositories Dependabot can access in an organization\n\n```\nGET /orgs/{org}/dependabot/repository-access\n```\n\nLists repositories that organization admins have allowed Dependabot to access when updating dependencies.\nNote\n\nThis operation supports both server-to-server and user-to-server access.\nUnauthorized users will not see the existence of this endpoint.\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- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`page`** (integer)\n  The page number of results to fetch.\n  Default: `1`\n\n- **`per_page`** (integer)\n  Number of results per page.\n  Default: `30`\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **403** - Forbidden\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/orgs/ORG/dependabot/repository-access\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Lists the repositories Dependabot can access in an enterprise](#lists-the-repositories-dependabot-can-access-in-an-enterprise).\n\n## Updates Dependabot's repository access list for an organization\n\n```\nPATCH /orgs/{org}/dependabot/repository-access\n```\n\nUpdates repositories according to the list of repositories that organization admins have given Dependabot access to when they've updated dependencies.\nNote\n\nThis operation supports both server-to-server and user-to-server access.\nUnauthorized users will not see the existence of this endpoint.\n\nExample request body:\n{\n  \"repository_ids_to_add\": [123, 456],\n  \"repository_ids_to_remove\": [789]\n}\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- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n#### Body parameters\n\n- **`repository_ids_to_add`** (array of integers)\n  List of repository IDs to add.\n\n- **`repository_ids_to_remove`** (array of integers)\n  List of repository IDs to remove.\n\n### HTTP response status codes\n\n- **204** - No Content\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example with a 'succeeded' status.\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PATCH \\\n  https://api.github.com/orgs/ORG/dependabot/repository-access\n```\n\n**Response schema (Status: 204):**\n\n## Set the default repository access level for Dependabot\n\n```\nPUT /orgs/{org}/dependabot/repository-access/default-level\n```\n\nSets the default level of repository access Dependabot will have while performing an update.  Available values are:\n\n'public' - Dependabot will only have access to public repositories, unless access is explicitly granted to non-public repositories.\n'internal' - Dependabot will only have access to public and internal repositories, unless access is explicitly granted to private repositories.\n\nUnauthorized users will not see the existence of this endpoint.\nThis operation supports both server-to-server and user-to-server access.\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- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n#### Body parameters\n\n- **`default_level`** (string) (required)\n  The default repository access level for Dependabot updates.\n  Can be one of: `public`, `internal`\n\n### HTTP response status codes\n\n- **204** - No Content\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example with a 'succeeded' status.\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PUT \\\n  https://api.github.com/orgs/ORG/dependabot/repository-access/default-level \\\n  -d '{\n  \"default_level\": \"public\"\n}'\n```\n\n**Response schema (Status: 204):**"}