PublishUnpublishDetails

View as Markdown

PublishUnpublishDetails

PublishUnpublishDetails holds the environments, locales, variants, version, and schedule of a publish or unpublish request for an entry, an entry variant, or an asset.

When to Use This Class: Use this class whenever you publish or unpublish one entry or asset, for example to publish an entry to production in two locales.

Conceptual Role: Acts as the data model for the request body of the publish and unpublish methods.

Returns: PublishUnpublishDetails. The publish or unpublish details of one item.

Properties

NameTypeRequiredDefaultDescription
EnvironmentsList<string>?NonullEnvironment names to publish to.
LocalesList<string>?NonullLocale codes to publish in.
VariantsList<PublishVariant>?NonullEntry variants to include.
VariantRulesPublishVariantRules?NonullRules for the base entry version.
Versionint?NonullVersion of the item to publish.
ScheduledAtstring?NonullDate and time for a scheduled publish.

Class-Level Notes

How the SDK builds the body.

  • The SDK writes the body field by field instead of serializing the class, and maps each property to the key below:
    • Under the entry key, or asset for an asset: Locales as locales, Environments as environments, Variants as variants, and VariantRules as variant_rules.
    • At the top level of the body: Version as version and ScheduledAt as scheduled_at.
  • The SDK leaves out a list that is null or empty, a null Version, and a null or empty ScheduledAt.
  • The SDK does not check environment names, locale codes, or the date format. The API rejects values it cannot use.

Where the class is used.

Variants.

Method Index

PublishUnpublishDetails has no methods. Set its properties and pass it to a publish or unpublish method.

Class-Level Snippet

The snippet below schedules version 3 of an entry for publishing in two locales.

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", "fr-fr" },
    Version = 3,
    ScheduledAt = "2026-12-01T09:00:00.000Z"
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Publish(details, "en-us");
    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}");
}