BulkPublishRules

View as Markdown

BulkPublishRules

BulkPublishRules holds the rules object of a bulk publish or unpublish request. Assign it to BulkPublishDetails.Rules before you call the Publish and Unpublish methods.

When to Use This Class: Use this class when a bulk publish request needs the rules.approvals setting in its body.

Conceptual Role: Acts as the rules object in the request body.

Returns: BulkPublishRules. The rules of a bulk publish.

Properties

NameTypeRequiredDefaultDescription
Approvalsstring?NonullApprovals setting, for example "true". Serialized as approvals.

Class-Level Notes

Serialization.

  • The SDK serializes the model with System.Text.Json and leaves out every property that is null. The SDK does not check the values.

A string, not a flag.

  • Approvals is a string, and the SDK sends the text you set without changes.
  • The approvals argument of Publish is a separate setting. It adds approvals=true to the query string, which the Content Management API (CMA) reference uses to publish the entries that need no approval. See the Publish entries and assets in bulk request.

Method Index

BulkPublishRules has no methods. Set its properties and pass it as shown in the Class-Level Snippet below.

Class-Level Snippet

The snippet below sets the rules object on a bulk publish request.

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>");

BulkPublishDetails details = new BulkPublishDetails()
{
    Entries = new List<BulkPublishEntry>
    {
        new BulkPublishEntry() { Uid = "<ENTRY_UID>", ContentType = "<CONTENT_TYPE_UID>", Version = 2, Locale = "<LOCALE_CODE>" }
    },
    Assets = new List<BulkPublishAsset>
    {
        new BulkPublishAsset() { Uid = "<ASSET_UID>" }
    },
    Locales = new List<string> { "<LOCALE_CODE>" },
    Environments = new List<string> { "<ENVIRONMENT_NAME>" },
    Rules = new BulkPublishRules() { Approvals = "true" },
    ScheduledAt = "2026-12-01T09:00:00.000Z",
    PublishWithReference = true
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").BulkOperation().Publish(details);
    Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}