# createBranch

```graphql
mutation CreateBranch($input: CreateBranchInput!) {
  createBranch(input: $input) {
    id
    projectId
    name
    baseBranchId
    createdAt
    createdBy
    mergedAt
    mergedBy
    updatedAt
    version
    description
    status
    autoDeleteOnMerge
  }
}
```

Create a branch from the project root or from another branch, snapshotting its files. Requires project.files.write.

## Arguments

| Name                      | Type               | Required | Description                                                             |
| ------------------------- | ------------------ | -------- | ----------------------------------------------------------------------- |
| `input`                   | CreateBranchInput! | Yes      |                                                                         |
| `input.projectReference`  | String             |          |                                                                         |
| `input.name`              | String!            | Yes      |                                                                         |
| `input.baseBranchId`      | ID                 |          |                                                                         |
| `input.description`       | String             |          |                                                                         |
| `input.autoDeleteOnMerge` | Boolean            |          | Delete the branch after merge. Null and omission use the false default. |

## Variables

```json
{
  "input": {
    "name": "feature-new-header"
  }
}
```

## Responses

| Status | Description                       |
| ------ | --------------------------------- |
| 200    | The Branch! in data.createBranch. |

## 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 CreateBranch($input: CreateBranchInput!) {\n  createBranch(input: $input) {\n    id\n    projectId\n    name\n    baseBranchId\n    createdAt\n    createdBy\n    mergedAt\n    mergedBy\n    updatedAt\n    version\n    description\n    status\n    autoDeleteOnMerge\n  }\n}",
  "variables": {
    "input": {
      "name": "feature-new-header"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createBranch": {
      "id": "string",
      "projectId": "string",
      "name": "string",
      "baseBranchId": "string",
      "createdAt": "string",
      "createdBy": "string",
      "mergedAt": "string",
      "mergedBy": "string",
      "updatedAt": "string",
      "version": 0,
      "description": "string",
      "status": "active",
      "autoDeleteOnMerge": false
    }
  }
}
```
