Sample - GitHub REST API
POST/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules

Create a custom deployment protection rule on an environment

Enable a custom deployment protection rule for an environment.

The authenticated user must have admin or owner permissions to the repository to use this endpoint.

For 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.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters · 1 body field
environment_namestringrequired
The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
integration_idintegeroptional
The ID of the custom app that will be enabled on the environment.

1 status code
201The enabled custom deployment protection rule
idintegerrequired
The unique identifier for the deployment protection rule.
node_idstringrequired
The node ID for the deployment protection rule.
enabledbooleanrequired
Whether the deployment protection rule is enabled for the environment.
appobjectrequired
A GitHub App that is providing a custom deployment protection rule.