---
title: "Create a deployment branch policy"
method: POST
path: "/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies"
tags: ["repos"]
---

# Create a deployment branch policy

`POST /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies`

Creates a deployment branch policy for an environment.

You must authenticate using an access token with the `repo` scope to use this endpoint. GitHub Apps must have the `administration:write` permission for the repository to use this endpoint.

## Path parameters

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

## Request body

- DeploymentBranchPolicyNamePattern
  - `name` string, required — The name pattern that branches must match in order to deploy to the environment. Wildcard characters will not match `/`. For example, to match branches that begin with `release/` and contain an additional single slash, use `release/*/*`. For more information about pattern matching syntax, see the [Ruby File.fnmatch documentation](https://ruby-doc.org/core-2.5.1/File.html#method-c-fnmatch).

## Response `200`

Response

- DeploymentBranchPolicy — Details of a deployment branch policy.
  - `id` integer — The unique identifier of the branch policy.
  - `node_id` string
  - `name` string — The name pattern that branches must match in order to deploy to the environment.

## Other responses

- `303` — Response if the same branch name pattern already exists
- `404` — Not Found or `deployment_branch_policy.custom_branch_policies` property for the environment is set to false

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-4.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-4/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-4/versions/ee6c7a46328e/schema)
