---
title: "Branch"
description: "Branch"
url: "https://www.contentstack.com/docs/developers/sdks/content-management-sdk/javascript/reference/branch"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-04"
---

# Branch

## Branch

[Branches](/docs/headless-cms/about-branches/) efficiently present independent workspaces where developers and content managers can work parallely on content models and content. It helps sync the development activities of websites.

## delete

The Delete Branch call is used to delete an existing Branch permanently from your Stack.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })

client.stack({ api_key: 'api_key'}).branch('uid')
.delete()
.then((response) => console.log(response.notice))
```

## fetch

The fetch Branch call fetches Branch details.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })

client.stack({ api_key: 'api_key'}).branch('uid')
.fetch()
.then((branch) => console.log(branch))
```

## create

The Create a Branch call creates a new branch in a particular stack of your Contentstack account.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })

const branch = {
     name: 'branch_name',
     source: 'master'
}

client.stack({ api_key: 'api_key'}).branch().create({ branch })
.then((branch) => console.log(branch))
```

Branch details to create.

## query

The query on Branch will allow to fetch details of all or specific Branch.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })

client.stack({ api_key: 'api_key'}).branch()
.query()
.find()
.then((branch) => console.log(branch))
```

Enter 'true' to include the publish details of the entry.

Queries that you can use to fetch filtered results.

## compare all

The compare all call is used to compare the differences between all the content types and global fields of two branches.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'})
    .branch('branch_uid')
    .compare('compare_branch_uid')
    .all({skip: 0, limit: 100})
    .then(response => console.log(response))
```

## compare contentType

The contentType call is used to compare the differences only between the content types of two branches.

You can specify the content type UID to fetch the difference of a specific content type. If no UID is specified, differences for all content types are fetched in a paged way.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const compare = client.stack({ api_key: 'API_KEY' }).branch(_base_branch_uid).compare(_compare_branch_uid)
compare.contentType({
  uid: UID, skip: 4, limit: 20, include_schemas: true
})
.then(response)
.catch(error)
```

## compare globalField

The globalField call is used to compare the differences only between the global fields of two branches.

You can specify the global field UID to fetch the difference of a specific global field. If no UID is specified, differences for all global fields are fetched in a paged way.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const compare = client.stack({ api_key: 'API_KEY' }).branch(_base_branch_uid).compare(_compare_branch_uid)
compare.globalField({
  uid: UID, skip: 4, limit: 20, include_schemas: true
})
.then(response)
.catch(error)
```

## merge

The merge call is used to merge two branches. You can choose to use a default merge strategy for all content types and global fields, or you can opt for specific merge strategies for particular content types or global fields.

```
import * as contentstack from '@contentstack/management'
const branch = contentstack.client({ authtoken }).stack({ api_key: 'api_key'}).branch()
branch.merge({
  base_branch: "main",
  compare_branch: "dev",
  default_merge_strategy: "merge_prefer_base",
  item_merge_strategies: [ 
    {
      uid: "global_field_uid", 
      type: "global_field", 
      merge_strategy: "merge_prefer_base"
    }
  ],
  merge_comment: "Merging dev into main", 
  no_revert: true
})
```

## fetch mergeQueue

The fetch mergeQueue call is used to fetch a specific merge job in a specific branch.

```
import * as contentstack from '@contentstack/management'
const branch = contentstack.client.stack({ api_key: 'API_KEY' }).branch('branch_uid')
branch.mergeQueue( 'UID')
.fetch()
.then(response)
.catch(error)
```

## find mergeQueue

The find mergeQueue call is used to fetch all merge jobs in a specific branch.

```
import * as contentstack from '@contentstack/management'
const branch = contentstack.client.stack({ api_key: 'API_KEY' }).branch(branch_uid)
branch.mergeQueue()
.find()
.then(response)
.catch(error)
```

## Branch | JavaScript Management SDK | Contentstack

Branch provides independent workspaces where developers and content managers work in parallel on models and content in the JavaScript Management SDK.