# createBranchPolicy

```graphql
mutation CreateBranchPolicy($input: CreateBranchPolicyInput!) {
  createBranchPolicy(input: $input) {
    id
    projectId
    name
    isEnabled
    targetBranchPattern
    requiredApprovals
    allowSelfApproval
    requiredReviewerIds
    createdAt
    updatedAt
  }
}
```

Create a merge policy for branches matching a pattern. Requires project.settings.manage.

## Arguments

| Name                        | Type                     | Required | Description                                                                                                            |
| --------------------------- | ------------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------- |
| `input`                     | CreateBranchPolicyInput! | Yes      |                                                                                                                        |
| `input.projectReference`    | String                   |          |                                                                                                                        |
| `input.name`                | String!                  | Yes      |                                                                                                                        |
| `input.isEnabled`           | Boolean                  |          | Enable this policy. Null and omission use the true default.                                                            |
| `input.targetBranchPattern` | String                   |          |                                                                                                                        |
| `input.requiredApprovals`   | Int                      |          | Required approval count. Null and omission default to 0; MCP create\_branch\_policy defaults to 1.                     |
| `input.allowSelfApproval`   | Boolean                  |          | Allow the merger’s approval to count. Null and omission default to true; MCP create\_branch\_policy defaults to false. |
| `input.requiredReviewerIds` | \[String!]               |          | Reviewer UUIDs required for merge. Null and omission impose no specific reviewers; an empty list is accepted.          |

## Variables

```json
{
  "input": {
    "name": "string"
  }
}
```

## Responses

| Status | Description                                   |
| ------ | --------------------------------------------- |
| 200    | The BranchPolicy! in data.createBranchPolicy. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation CreateBranchPolicy($input: CreateBranchPolicyInput!) {\n  createBranchPolicy(input: $input) {\n    id\n    projectId\n    name\n    isEnabled\n    targetBranchPattern\n    requiredApprovals\n    allowSelfApproval\n    requiredReviewerIds\n    createdAt\n    updatedAt\n  }\n}",
  "variables": {
    "input": {
      "name": "string"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createBranchPolicy": {
      "id": "string",
      "projectId": "string",
      "name": "string",
      "isEnabled": false,
      "targetBranchPattern": "string",
      "requiredApprovals": 0,
      "allowSelfApproval": false,
      "requiredReviewerIds": [
        "string"
      ],
      "createdAt": "string",
      "updatedAt": "string"
    }
  }
}
```
