# 배포 분기 정책에 대한 REST API 엔드포인트

REST API를 사용하여 사용자 지정 배포 분기 정책을 관리합니다.

## 배포 분기 정책 정보

REST API를 사용하면 환경에 배포하기 위해 분기가 일치해야 하는 사용자 지정 이름 패턴을 지정할 수 있습니다. 이러한 엔드포인트를 사용하려면 환경의 `deployment_branch_policy.custom_branch_policies` 속성이 `true`로 설정되어야 합니다. 환경에 대한 `deployment_branch_policy`를 업데이트하려면 [배포 환경을 위한 REST API 엔드포인트](/ko/enterprise-server@3.22/rest/deployments/environments#create-or-update-an-environment)을(를) 참조하세요.

환경 배포를 특정 분기로 제한하는 방법에 대한 자세한 정보는 [배포 환경 관리](/ko/enterprise-server@3.22/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments)을(를) 참조하세요.

> \[!NOTE]
> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.

## List deployment branch policies

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

Lists the deployment branch policies for an environment.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`environment_name`** (string) (required)
  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

* **`per_page`** (integer)
  The number of results per page (max 100). For more information, see "Using pagination in the REST API."
  Default: `30`

* **`page`** (integer)
  The page number of the results to fetch. For more information, see "Using pagination in the REST API."
  Default: `1`

### HTTP response status codes

* **200** - OK

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies
```

**Response schema (Status: 200):**

* `total_count`: required, integer
* `branch_policies`: required, array of `Deployment branch policy`:
  * `id`: integer
  * `node_id`: string
  * `name`: string
  * `type`: string, enum: `branch`, `tag`

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

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`environment_name`** (string) (required)
  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

#### Body parameters

* **`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.

* **`type`** (string)
  Whether this rule targets a branch or tag
  Can be one of: `branch`, `tag`

### HTTP response status codes

* **200** - OK

* **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

### Code examples

#### Example of a wildcard name pattern

**Request:**

```curl
curl -L \
  -X POST \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies \
  -d '{
  "name": "release/*"
}'
```

**Response schema (Status: 200):**

* `id`: integer
* `node_id`: string
* `name`: string
* `type`: string, enum: `branch`, `tag`

#### Example of a single branch name pattern

**Request:**

```curl
curl -L \
  -X POST \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies \
  -d '{
  "name": "main",
  "type": "branch"
}'
```

**Response schema (Status: 200):**

* `id`: integer
* `node_id`: string
* `name`: string
* `type`: string, enum: `branch`, `tag`

#### Example of a single tag name pattern

**Request:**

```curl
curl -L \
  -X POST \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies \
  -d '{
  "name": "v1",
  "type": "tag"
}'
```

**Response schema (Status: 200):**

* `id`: integer
* `node_id`: string
* `name`: string
* `type`: string, enum: `branch`, `tag`

## Get a deployment branch policy

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

Gets a deployment branch or tag policy for an environment.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`environment_name`** (string) (required)
  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

* **`branch_policy_id`** (integer) (required)
  The unique identifier of the branch policy.

### HTTP response status codes

* **200** - OK

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID
```

**Response schema (Status: 200):**

Same response schema as [Create a deployment branch policy](#create-a-deployment-branch-policy).

## Update a deployment branch policy

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

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

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`environment_name`** (string) (required)
  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

* **`branch_policy_id`** (integer) (required)
  The unique identifier of the branch policy.

#### Body parameters

* **`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.

### HTTP response status codes

* **200** - OK

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X PUT \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID \
  -d '{
  "name": "release/*"
}'
```

**Response schema (Status: 200):**

Same response schema as [Create a deployment branch policy](#create-a-deployment-branch-policy).

## Delete a deployment branch policy

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

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

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`environment_name`** (string) (required)
  The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

* **`branch_policy_id`** (integer) (required)
  The unique identifier of the branch policy.

### HTTP response status codes

* **204** - No Content

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X DELETE \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID
```

**Response schema (Status: 204):**