---
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 or tag policy for an environment.

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

## Path parameters

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

## Request body

- DeploymentBranchPolicyNamePatternWithType
  - `name` string, required — The name pattern that branches or tags 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).
  - `type` 'branch' | 'tag' — Whether this rule targets a branch or tag

## Response `200`

Response

- DeploymentBranchPolicy — Details of a deployment branch or tag policy.
  - `id` integer — The unique identifier of the branch or tag policy.
  - `node_id` string
  - `name` string — The name pattern that branches or tags must match in order to deploy to the environment.
  - `type` 'branch' | 'tag' — Whether this rule targets a branch or tag.

## 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-3.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-3/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-3/versions/dc0584ac4e13/schema)
