---
title: "POST /v1/{+parent}/branchRules"
method: POST
path: "/v1/{+parent}/branchRules"
tags: ["projects"]
---

# POST /v1/{+parent}/branchRules

`POST /v1/{+parent}/branchRules`

CreateBranchRule creates a branch rule in a given repository.

## Path parameters

- `parent` string, required

## Query parameters

- `branchRuleId` string

## Request body

- BranchRule — Metadata of a BranchRule. BranchRule is the protection rule to enforce pre-defined rules on designated branches within a repository.
  - `requirePullRequest` boolean — Optional. Determines if the branch rule requires a pull request or not.
  - `requireCodeOwnerApproval` boolean — Optional. Determines if code owners must approve before merging to the branch.
  - `annotations` object — Optional. User annotations. These attributes can only be set and used by the user. See https://google.aip.dev/128#annotations for more details such as format and size limitations.
  - `requiredStatusChecks` Check[] — Optional. List of required status checks before merging to the branch.
    - `context` string — Required. The context of the check.
  - `includePattern` string — Optional. The pattern of the branch that can match to this BranchRule. Specified as regex. .* for all branches. Examples: main, (main|release.*). Current MVP phase only support `.*` for wildcard.
  - `minimumApprovalsCount` integer — Optional. The minimum number of approvals required for the branch rule to be matched.
  - `disabled` boolean — Optional. Determines if the branch rule is disabled or not.
  - `allowStaleReviews` boolean — Optional. Determines if allow stale reviews or approvals before merging to the branch.
  - `minimumReviewsCount` integer — Optional. The minimum number of reviews required for the branch rule to be matched.
  - `uid` string — Output only. Unique identifier of the repository.
  - `requireLinearHistory` boolean — Optional. Determines if require linear history before merging to the branch.
  - `createTime` string, google-datetime — Output only. Create timestamp.
  - `updateTime` string, google-datetime — Output only. Update timestamp.
  - `etag` string — Optional. This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
  - `name` string — Identifier. A unique identifier for a BranchRule. The name should be of the format: `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}`
  - `requireCommentsResolved` boolean — Optional. Determines if require comments resolved before merging to the branch.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/securesourcemanager.md) · [All operations](https://skmtc.net/google/apis/securesourcemanager/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/securesourcemanager/versions/4c9890b46a17/schema)
