{"meta":{"title":"保護ルール用の REST API エンドポイント","intro":"REST API を使って、デプロイ保護ルールを作成、構成、削除します。","product":"REST API","breadcrumbs":[{"href":"/ja/rest","title":"REST API"},{"href":"/ja/rest/deployments","title":"デプロイメント"},{"href":"/ja/rest/deployments/protection-rules","title":"保護ルール"}],"documentType":"article"},"body":"# 保護ルール用の REST API エンドポイント\n\nREST API を使って、デプロイ保護ルールを作成、構成、削除します。\n\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\n## Get all deployment protection rules for an environment\n\n```\nGET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules\n```\n\nGets all custom deployment protection rules that are enabled for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see \"Using environments for deployment.\"\nFor more information about the app that is providing this custom deployment rule, see the documentation for the GET /apps/{app_slug} endpoint.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.\n\n\n### Parameters\n\n\n#### Headers\n\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n\n\n#### Path and query parameters\n\n- **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n\n\n\n\n\n### HTTP response status codes\n\n\n- **200** - List of deployment protection rules\n\n\n\n\n### Code examples\n\n\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment_protection_rules\n```\n\n**Response schema (Status: 200):**\n\n* `total_count`: integer\n* `custom_deployment_protection_rules`: array of `Deployment protection rule`:\n  * `id`: required, integer\n  * `node_id`: required, string\n  * `enabled`: required, boolean\n  * `app`: required, `Custom deployment protection rule app`:\n    * `id`: required, integer\n    * `slug`: required, string\n    * `integration_url`: required, string\n    * `node_id`: required, string\n\n\n\n\n\n## Create a custom deployment protection rule on an environment\n\n```\nPOST /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules\n```\n\nEnable a custom deployment protection rule for an environment.\nThe authenticated user must have admin or owner permissions to the repository to use this endpoint.\nFor more information about the app that is providing this custom deployment rule, see the documentation for the GET /apps/{app_slug} endpoint, as well as the guide to creating custom deployment protection rules.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.\n\n\n### Parameters\n\n\n#### Headers\n\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n\n\n#### Path and query parameters\n\n- **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n\n\n\n#### Body parameters\n\n- **`integration_id`** (integer)\n  The ID of the custom app that will be enabled on the environment.\n\n\n\n\n\n### HTTP response status codes\n\n\n- **201** - The enabled custom deployment protection rule\n\n\n\n\n### Code examples\n\n\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment_protection_rules \\\n  -d '{\n  \"integration_id\": 5\n}'\n```\n\n**Response schema (Status: 201):**\n\n* `id`: required, integer\n* `node_id`: required, string\n* `enabled`: required, boolean\n* `app`: required, `Custom deployment protection rule app`:\n  * `id`: required, integer\n  * `slug`: required, string\n  * `integration_url`: required, string\n  * `node_id`: required, string\n\n\n\n\n\n## List custom deployment rule integrations available for an environment\n\n```\nGET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps\n```\n\nGets all custom deployment protection rule integrations that are available for an environment.\nThe authenticated user must have admin or owner permissions to the repository to use this endpoint.\nFor more information about environments, see \"Using environments for deployment.\"\nFor more information about the app that is providing this custom deployment rule, see \"GET an app\".\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.\n\n\n### Parameters\n\n\n#### Headers\n\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n\n\n#### Path and query parameters\n\n- **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\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- **`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\n\n\n\n\n### HTTP response status codes\n\n\n- **200** - A list of custom deployment rule integrations available for this environment.\n\n\n\n\n### Code examples\n\n\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment_protection_rules/apps\n```\n\n**Response schema (Status: 200):**\n\n* `total_count`: integer\n* `available_custom_deployment_protection_rule_integrations`: array of `Custom deployment protection rule app`:\n  * `id`: required, integer\n  * `slug`: required, string\n  * `integration_url`: required, string\n  * `node_id`: required, string\n\n\n\n\n\n## Get a custom deployment protection rule\n\n```\nGET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}\n```\n\nGets an enabled custom deployment protection rule for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see \"Using environments for deployment.\"\nFor more information about the app that is providing this custom deployment rule, see GET /apps/{app_slug}.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.\n\n\n### Parameters\n\n\n#### Headers\n\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n\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- **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n- **`protection_rule_id`** (integer) (required)\n  The unique identifier of the protection rule.\n\n\n\n\n\n\n### HTTP response status codes\n\n\n- **200** - OK\n\n\n\n\n### Code examples\n\n\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment_protection_rules/PROTECTION_RULE_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a custom deployment protection rule on an environment](#create-a-custom-deployment-protection-rule-on-an-environment).\n\n\n\n\n\n## Disable a custom protection rule for an environment\n\n```\nDELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}\n```\n\nDisables a custom deployment protection rule for an environment.\nThe authenticated user must have admin or owner permissions to the repository to use this endpoint.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.\n\n\n### Parameters\n\n\n#### Headers\n\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n\n\n#### Path and query parameters\n\n- **`environment_name`** (string) (required)\n  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.\n\n- **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n- **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n- **`protection_rule_id`** (integer) (required)\n  The unique identifier of the protection rule.\n\n\n\n\n\n\n### HTTP response status codes\n\n\n- **204** - No Content\n\n\n\n\n### Code examples\n\n\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment_protection_rules/PROTECTION_RULE_ID\n```\n\n**Response schema (Status: 204):**"}