Skip to content

Create a custom deployment protection rule on an environment

POST
/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules

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.

API method documentation

environment_name
required
string

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

owner
required
string

The account owner of the repository. The name is not case sensitive.

Media type application/json
object
integration_id

The ID of the custom app that will be enabled on the environment.

integer
Examples
Example default
{
"integration_id": 5
}

The enabled custom deployment protection rule

Media type application/json
Deployment protection rule

Deployment protection rule

object
id
required

The unique identifier for the deployment protection rule.

integer
node_id
required

The node ID for the deployment protection rule.

string
enabled
required

Whether the deployment protection rule is enabled for the environment.

boolean
app
required
Custom deployment protection rule app

A GitHub App that is providing a custom deployment protection rule.

object
id
required

The unique identifier of the deployment protection rule integration.

integer
slug
required

The slugified name of the deployment protection rule integration.

string
integration_url
required

The URL for the endpoint to get details about the app.

string
node_id
required

The node ID for the deployment protection rule integration.

string
Examples
Example default
{
"id": 3,
"node_id": "IEH37kRlcGxveW1lbnRTdGF0ddiv",
"enabled": true,
"app": {
"id": 1,
"node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy",
"slug": "a-custom-app",
"integration_url": "https://api.github.com/apps/a-custom-app"
}
}