---
title: "BranchModel"
description: "BranchModel"
url: "https://www.contentstack.com/docs/developers/sdks/content-management-sdk/dot-net/reference/branchmodel"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-16"
---

# BranchModel

## BranchModel

BranchModel holds the details of a branch. You set Uid and Source to create a branch with the [Create](/docs/developers/sdks/content-management-sdk/dot-net/reference/branch#branch-create) method, and the API fills the other fields when it returns a branch.

**When to Use This Class:** Use this class to build the request for a new branch, or to read a fetched branch as a typed object.

**Conceptual Role:** Acts as the data model that the Branch class serializes under the branch key of a request.

**Returns:** BranchModel. The details of a branch.

## Class-Level Notes

**Fields you send and fields the API sets.**

*   Create and CreateAsync serialize every field that is not null and leave out the null ones. Leave CreatedBy, UpdatedBy, CreatedAt, UpdatedAt, and Alias unset when you create a branch, so the request body contains only uid and source.
*   The model has no field for publish\_config, so a branch you create through this SDK clones all environments of its source branch.

**Dates are strings.**

*   CreatedAt and UpdatedAt contain the timestamp string the API returns. Parse them with DateTimeOffset.Parse when you need a date value.

## Method Index

BranchModel has no methods. Set and read its properties directly, and pass the model to the [Create](/docs/developers/sdks/content-management-sdk/dot-net/reference/branch#branch-create) method.

## Class-Level Snippet

This snippet builds a model to create a branch, then reads a fetched branch back into a second model.

```
using System;
using System.Text.Json;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
Stack stack = client.Stack("<API_KEY>");

try
{
    BranchModel model = new BranchModel() { Uid = "<BRANCH_UID>", Source = "main" };
    stack.Branch().Create(model);

    ContentstackResponse response = stack.Branch("<EXISTING_BRANCH_UID>").Fetch();
    BranchModel? branch = response.OpenJsonObjectResponse()["branch"]?.Deserialize<BranchModel>();

    foreach (BranchAliasModel alias in branch?.Alias ?? new())
    {
        Console.WriteLine($"Alias {alias.Uid} points to {branch?.Uid}");
    }
}
catch (ContentstackErrorException ex)
{
    Console.WriteLine($"API error {(int)ex.StatusCode}: {ex.ErrorMessage}");
}
```

Branch UID. Required to create a branch. Lowercase, \_ between words, at most 15 characters. Serialized as uid.

UID of the branch to copy, for example main. Required to create a branch. Serialized as source.

UID of the user who created the branch. The API sets it. Serialized as created\_by.

UID of the user who last updated the branch. The API sets it. Serialized as updated\_by.

Creation time as an ISO 8601 string. The API sets it. Serialized as created\_at.

Last update time as an ISO 8601 string. The API sets it. Serialized as updated\_at.

Aliases that point to the branch. The API sets it. Serialized as alias.

## BranchModel | .NET Management SDK | Contentstack

BranchModel in the .NET Management SDK holds the details of a branch: the UID and source you send to create it, and the fields the API returns.