デプロイ ブランチ ポリシー用の REST API エンドポイント
REST API を使って、カスタム デプロイ ブランチ ポリシーを管理します。
デプロイ ブランチ ポリシーについて
REST API を使って、環境にデプロイするためにブランチが一致する必要があるカスタム名パターンを指定できます。 これらのエンドポイントを使用するには、環境の deployment_branch_policy.custom_branch_policies プロパティを true に設定する必要があります。 環境の deployment_branch_policy を更新する方法については、「デプロイメント環境向けREST APIエンドポイント」を参照してください。
環境の配置を特定のブランチに制限する方法については、「デプロイメント用の環境管理」を参照してください。
List 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.
Fine-grained access tokens for "List deployment branch policies"
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- "Actions" repository permissions (read)
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
"List deployment branch policies" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
environment_name string 必須The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
| 名前, タイプ, 説明 |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." デフォルト: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." デフォルト: |
HTTP response status codes for "List deployment branch policies"
| Status code | 説明 |
|---|---|
200 | OK |
Code samples for "List deployment branch policies"
Request example
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policiesResponse
Status: 200{
"total_count": 2,
"branch_policies": [
{
"id": 361471,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzE=",
"name": "release/*"
},
{
"id": 361472,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzI=",
"name": "main"
}
]
}Create a deployment branch policy
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.
Fine-grained access tokens for "Create a deployment branch policy"
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- "Administration" repository permissions (write)
"Create a deployment branch policy" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
environment_name string 必須The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
| 名前, タイプ, 説明 |
|---|
name string 必須The name pattern that branches or tags must match in order to deploy to the environment. Wildcard characters will not match |
type string Whether this rule targets a branch or tag 次のいずれかにできます: |
HTTP response status codes for "Create a deployment branch policy"
| Status code | 説明 |
|---|---|
200 | OK |
303 | Response if the same branch name pattern already exists |
404 | Not Found or |
Code samples for "Create a deployment branch policy"
Request examples
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies \
-d '{"name":"release/*"}'Response
Status: 200{
"id": 364662,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=",
"name": "release/*"
}Get a deployment branch policy
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.
Fine-grained access tokens for "Get a deployment branch policy"
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- "Actions" repository permissions (read)
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
"Get a deployment branch policy" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
environment_name string 必須The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
branch_policy_id integer 必須The unique identifier of the branch policy. |
HTTP response status codes for "Get a deployment branch policy"
| Status code | 説明 |
|---|---|
200 | OK |
Code samples for "Get a deployment branch policy"
Request example
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_IDResponse
Status: 200{
"id": 364662,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=",
"name": "release/*"
}Update a deployment branch policy
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.
Fine-grained access tokens for "Update a deployment branch policy"
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- "Administration" repository permissions (write)
"Update a deployment branch policy" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
environment_name string 必須The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
branch_policy_id integer 必須The unique identifier of the branch policy. |
| 名前, タイプ, 説明 |
|---|
name string 必須The name pattern that branches must match in order to deploy to the environment. Wildcard characters will not match |
HTTP response status codes for "Update a deployment branch policy"
| Status code | 説明 |
|---|---|
200 | OK |
Code samples for "Update a deployment branch policy"
Request example
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID \
-d '{"name":"release/*"}'Response
Status: 200{
"id": 364662,
"node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=",
"name": "release/*"
}Delete a deployment branch policy
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.
Fine-grained access tokens for "Delete a deployment branch policy"
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- "Administration" repository permissions (write)
"Delete a deployment branch policy" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
environment_name string 必須The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
branch_policy_id integer 必須The unique identifier of the branch policy. |
HTTP response status codes for "Delete a deployment branch policy"
| Status code | 説明 |
|---|---|
204 | No Content |
Code samples for "Delete a deployment branch policy"
Request example
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_IDResponse
Status: 204