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

# PublishVariant

## PublishVariant

PublishVariant names one entry variant, and the version of it, in a publish or unpublish request. You add it to the Variants list of [PublishUnpublishDetails](/docs/developers/sdks/content-management-sdk/dot-net/reference/publishunpublishdetails).

**When to Use This Class:** Use this class when you publish or unpublish a specific version of an entry variant, alone or together with the base entry.

**Conceptual Role:** Acts as the data model that the SDK sends as one item of the entry.variants array of a publish or unpublish request.

**Returns:** PublishVariant. One entry variant and its version.

## Properties

Name

Type

Required

Default

Description

Uid

string?

No

null

UID of the variant. Sent as uid.

Version

int?

No

null

Version of the variant. Sent as version.

The VariantRules property of PublishUnpublishDetails takes a PublishVariantRules object, with the properties in the table below:

Name

Type

Required

Default

Description

PublishLatestBase

bool?

No

null

Publishes the latest base entry. Sent as publish\_latest\_base.

PublishLatestBaseConditionally

bool?

No

null

Publishes the latest base entry conditionally. Sent as publish\_latest\_base\_conditionally.

## Class-Level Notes

**What the SDK sends.**

*   The SDK writes uid and version for each item only when they are not null. It writes each rule of PublishVariantRules only when it is not null.
*   The SDK does not check that the UID names a variant or that the version exists.

**What the API expects.**

*   The Content Management API (CMA) reference asks for the variant UID and version within variants. To publish a variant, it also asks for publish\_latest\_base\_conditionally set to true within variant\_rules. See [Publish entry variant](/docs/developers/apis/content-management-api/entry-variants#publish-entry-variant).
*   The API ignores a base entry version in a variant publish request, and publishes the variant based on the latest base version or as variant\_rules specifies.

**Entry and EntryVariant.**

*   With the [Publish](/docs/developers/sdks/content-management-sdk/dot-net/reference/entry#entry-publish) method of Entry, list every variant you want in Variants yourself.
*   The [Publish](/docs/developers/sdks/content-management-sdk/dot-net/reference/entryvariant#entryvariant-publish) method of EntryVariant adds its own variant to Variants without a version, unless the list already holds an item with that UID. Add your own item to send a version.

## Method Index

PublishVariant and PublishVariantRules have no methods. Set their properties and assign them to PublishUnpublishDetails.

## Class-Level Snippet

The snippet below publishes version 2 of one entry variant together with the latest base entry.

```
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");

PublishUnpublishDetails details = new PublishUnpublishDetails
{
    Environments = new List<string> { "<ENVIRONMENT_NAME>" },
    Locales = new List<string> { "en-us" },
    Variants = new List<PublishVariant>
    {
        new PublishVariant { Uid = "<VARIANT_UID>", Version = 2 }
    },
    VariantRules = new PublishVariantRules
    {
        PublishLatestBase = false,
        PublishLatestBaseConditionally = true
    }
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Publish(details);
    Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}
```

## PublishVariant | .NET Management SDK | Contentstack

PublishVariant in the .NET Management SDK names one entry variant and its version in a publish or unpublish request, with PublishVariantRules for the base entry.