---
title: "Create a custom deployment protection rule on an environment"
method: POST
path: "/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules"
tags: ["repos"]
---

# 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](https://docs.github.com/rest/apps/apps#get-an-app), as well as the [guide to creating custom deployment protection rules](https://docs.github.com/actions/managing-workflow-runs-and-deployments/managing-deployments/creating-custom-deployment-protection-rules).

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

## Path parameters

- `environment_name` string, required
- `repo` string, required
- `owner` string, required

## Request body

- object
  - `integration_id` integer — The ID of the custom app that will be enabled on the environment.

## Response `201`

The enabled custom deployment protection rule

- DeploymentProtectionRule — Deployment protection rule
  - `id` integer, required — The unique identifier for the deployment protection rule.
  - `node_id` string, required — The node ID for the deployment protection rule.
  - `enabled` boolean, required — Whether the deployment protection rule is enabled for the environment.
  - `app` CustomDeploymentRuleApp, required — A GitHub App that is providing a custom deployment protection rule.
    - `id` integer, required — The unique identifier of the deployment protection rule integration.
    - `slug` string, required — The slugified name of the deployment protection rule integration.
    - `integration_url` string, required — The URL for the endpoint to get details about the app.
    - `node_id` string, required — The node ID for the deployment protection rule integration.

---

[API](https://skmtc.net/github/apis/api-github-com.md) · [All operations](https://skmtc.net/github/apis/api-github-com/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/api-github-com/revisions/a367f7028301/schema)
