Bulk Operations

View as Markdown

Bulk Operations

The Contentstack Management .NET SDK provides bulk operation capabilities to perform actions on multiple entries and assets simultaneously, enabling efficient large-scale content management.

BulkPublish

The BulkPublish method publishes multiple entries and assets simultaneously across specified locales and environments.

NameTypeDescription
publishDetailsBulkPublishDetails

Specify entry or asset UIDs along with the target locales and publishing environments. If omitted, the system defaults to the primary locale.

skipWorkflowStageBoolean

Set to true to publish entries that are in workflow stages eligible under the applied publish rules.

approvalsBoolean

Set to true to publish entries that do not require an approval to be published.

apiVersionString

Specify the API Version in Headers

Example:

var bulkOperation = stack.BulkOperation();
var publishDetails = new BulkPublishDetails
{
   Entries = new List<BulkPublishEntry>
   {
       new BulkPublishEntry
       {
           Uid = "entry_uid_1",
           ContentType = "content_type_uid",
           Version = 1,
           Locale = "en-us"
       },
       new BulkPublishEntry
       {
           Uid = "entry_uid_2",
           ContentType = "content_type_uid",
           Version = 2,
           Locale = "en-us"
       }
   },
   Assets = new List<BulkPublishAsset>
   {
       new BulkPublishAsset { Uid = "asset_uid_1" },
       new BulkPublishAsset { Uid = "asset_uid_2" }
   },
   Locales = new List<string> { "en-us", "en-gb" },
   Environments = new List<string> { "environment_uid" }
};
ContentstackResponse response = bulkOperation.Publish(publishDetails);

BulkPublishAsync

The BulkPublish method publishes multiple entries and assets simultaneously across specified locales and environments.

NameTypeDescription
publishDetailsBulkPublishDetails

Specify entry or asset UIDs along with the target locales and publishing environments. If omitted, the system defaults to the primary locale.

skipWorkflowStageBoolean

Set to true to publish entries that are in workflow stages eligible under the applied publish rules.

approvalsBoolean

Set to true to publish entries that do not require an approval to be published.

apiVersionString

Specify the API Version in Headers

Example:

var bulkOperation = stack.BulkOperation();
var publishDetails = new BulkPublishDetails
{
   Entries = new List<BulkPublishEntry>
   {
       new BulkPublishEntry
       {
           Uid = "entry_uid_1",
           ContentType = "content_type_uid",
           Version = 1,
           Locale = "en-us"
       },
       new BulkPublishEntry
       {
           Uid = "entry_uid_2",
           ContentType = "content_type_uid",
           Version = 2,
           Locale = "en-us"
       }
   },
   Assets = new List<BulkPublishAsset>
   {
       new BulkPublishAsset { Uid = "asset_uid_1" },
       new BulkPublishAsset { Uid = "asset_uid_2" }
   },
   Locales = new List<string> { "en-us", "en-gb" },
   Environments = new List<string> { "environment_uid" }
};
ContentstackResponse response = await bulkOperation.PublishAsync(publishDetails);

BulkUnpublish

The BulkUnpublish method allows you to unpublish multiple entries and assets simultaneously across selected locales and environments.

NameTypeDescription
publishDetailsBulkPublishDetails

Specify entry or asset UIDs along with the target locales and unpublishing environments. If omitted, the system defaults to the primary locale.

skipWorkflowStageBoolean

Set to true to unpublish entries that are in workflow stages eligible under the applied publish rules.

approvalsBoolean

Set to true to publish entries that do not require an approval to be published.

apiVersionString

Specify the API Version in Headers

Example:

var bulkOperation = stack.BulkOperation();

var unpublishDetails = new BulkPublishDetails
{
    Entries = new List<BulkPublishEntry>
    {
        new BulkPublishEntry
        {
            Uid = "entry_uid_1",
            ContentType = "content_type_uid",
            Locale = "en-us"
        },
        new BulkPublishEntry
        {
            Uid = "entry_uid_2",
            ContentType = "content_type_uid",
            Locale = "en-us"
        }
    },
    Assets = new List<BulkPublishAsset>
    {
        new BulkPublishAsset { Uid = "asset_uid_1" }
    },
    Locales = new List<string> { "en-us" },
    Environments = new List<string> { "environment_uid" }
};

ContentstackResponse response = bulkOperation.Unpublish(unpublishDetails);

BulkUnpublishAsync

The BulkUnpublishAsync method allows you to unpublish multiple entries and assets simultaneously across selected locales and environments.

NameTypeDescription
publishDetailsBulkPublishDetails

Specify entry or asset UIDs along with the target locales and unpublishing environments. If omitted, the system defaults to the primary locale.

skipWorkflowStageBoolean

Set to true to unpublish entries that are in workflow stages eligible under the applied publish rules.

approvalsBoolean

Set to true to publish entries that do not require an approval to be published.

apiVersionString

Specify the API Version in Headers

Example:

var bulkOperation = stack.BulkOperation();

var unpublishDetails = new BulkPublishDetails
{
    Entries = new List<BulkPublishEntry>
    {
        new BulkPublishEntry
        {
            Uid = "entry_uid_1",
            ContentType = "content_type_uid",
            Locale = "en-us"
        },
        new BulkPublishEntry
        {
            Uid = "entry_uid_2",
            ContentType = "content_type_uid",
            Locale = "en-us"
        }
    },
    Assets = new List<BulkPublishAsset>
    {
        new BulkPublishAsset { Uid = "asset_uid_1" }
    },
    Locales = new List<string> { "en-us" },
    Environments = new List<string> { "environment_uid" }
};

ContentstackResponse response = await bulkOperation.UnpublishAsync(unpublishDetails);

BulkDelete

The BulkDelete method allows you to delete multiple entries and assets simultaneously across specified locales and environments.

NameTypeDescription
dataBulkDeleteDetails

Data containing the entries and assets to be deleted.

Example:

var deleteDetails = new BulkDeleteDetails
{
    Entries = new List<BulkDeleteEntry>
    {
        new BulkDeleteEntry
        {
            Uid = "entry_uid_1",
            ContentType = "content_type_uid",
            Locale = "en-us"
        },
        new BulkDeleteEntry
        {
            Uid = "entry_uid_2",
            ContentType = "content_type_uid",
            Locale = "en-us"
        }
    },
    Assets = new List<BulkDeleteAsset>
    {
        new BulkDeleteAsset { Uid = "asset_uid_1" },
        new BulkDeleteAsset { Uid = "asset_uid_2" }
    }
};

ContentstackResponse response = bulkOperation.Delete(deleteDetails);

Bulk Workflow Update

The update method updates an existing workflow with the specified configuration details

NameTypeDescription
dataBulkWorkflowUpdateBody

Data containing the entries and assets to be added.

Example:

var updateBody = new BulkWorkflowUpdateBody
{
    Entries = new List<BulkWorkflowEntry>
    {
        new BulkWorkflowEntry
        {
            Uid = "entry_uid",
            ContentType = "content_type_uid",
            Locale = "en-us"
        }
    },
    Workflow = new BulkWorkflowStage
    {
        Uid = "workflow_stage_uid",
        Comment = "Please review this content",
        DueDate = "2023-12-15",
        Notify = true,
        AssignedTo = new List<BulkWorkflowUser>
        {
            new BulkWorkflowUser
            {
                Uid = "user_uid",
                Name = "John Doe",
                Email = "[email protected]"
            }
        },
        AssignedByRoles = new List<BulkWorkflowRole>
        {
            new BulkWorkflowRole
            {
                Uid = "role_uid",
                Name = "Content Editor"
            }
        }
    }
};

ContentstackResponse response = bulkOperation.Update(updateBody);

Bulk Workflow UpdateAsync

The updateAsync method updates an existing workflow with the specified configuration details

NameTypeDescription
dataBulkWorkflowUpdateBody

Data containing the entries and assets to be added.

Example:

var updateBody = new BulkWorkflowUpdateBody
{
    Entries = new List<BulkWorkflowEntry>
    {
        new BulkWorkflowEntry
        {
            Uid = "entry_uid",
            ContentType = "content_type_uid",
            Locale = "en-us"
        }
    },
    Workflow = new BulkWorkflowStage
    {
        Uid = "workflow_stage_uid",
        Comment = "Please review this content",
        DueDate = "2023-12-15",
        Notify = true,
        AssignedTo = new List<BulkWorkflowUser>
        {
            new BulkWorkflowUser
            {
                Uid = "user_uid",
                Name = "John Doe",
                Email = "[email protected]"
            }
        },
        AssignedByRoles = new List<BulkWorkflowRole>
        {
            new BulkWorkflowRole
            {
                Uid = "role_uid",
                Name = "Content Editor"
            }
        }
    }
};

ContentstackResponse response = bulkOperation.Update(updateBody);

BulkDeleteAsync

The BulkDeleteAsync method allows you to delete multiple entries and assets simultaneously across specified locales and environments.

NameTypeDescription
dataBulkDeleteDetails

Data containing the entries and assets to be deleted.

Example:

var deleteDetails = new BulkDeleteDetails
{
    Entries = new List<BulkDeleteEntry>
    {
        new BulkDeleteEntry
        {
            Uid = "entry_uid_1",
            ContentType = "content_type_uid",
            Locale = "en-us"
        },
        new BulkDeleteEntry
        {
            Uid = "entry_uid_2",
            ContentType = "content_type_uid",
            Locale = "en-us"
        }
    },
    Assets = new List<BulkDeleteAsset>
    {
        new BulkDeleteAsset { Uid = "asset_uid_1" },
        new BulkDeleteAsset { Uid = "asset_uid_2" }
    }
};

// Execute bulk delete
ContentstackResponse response = await bulkOperation.DeleteAsync(deleteDetails);

Bulk AddItemsAsync

The AddItemsAsync method adds multiple entries and assets to a release in a single operation.

NameTypeDescription
dataBulkAddItemsData

Data containing the entries and assets to be deleted.

bulkVersionString

The bulk operation version.

Example:

var releaseData = new BulkAddItemsData
{
    Release = "release_uid",
    Action = "publish",
    Locale = new List<string> { "en-us", "en-gb" },
    Reference = true,
    Items = new List<BulkReleaseItem>
    {
        new BulkReleaseItem
        {
            ContentTypeUid = "content_type_uid",
            Uid = "entry_uid",
            Version = 1,
            Locale = "en-us",
            Title = "Sample Entry"
        },
        new BulkReleaseItem
        {
            ContentTypeUid = "content_type_uid",
            Uid = "entry_uid_2",
            Version = 2,
            Locale = "en-gb",
            Title = "Sample Entry 2"
        }
    }
};

ContentstackResponse response = await bulkOperation.AddItemsAsync(releaseData, "2.0");

Bulk UpdateItems

The UpdateItems method updates multiple entries and assets to a release in a single operation.

NameTypeDescription
dataBulkAddItemsData

Data containing the entries and assets to be deleted.

bulkVersionString

The bulk operation version.

Example:

var itemsData = new BulkAddItemsData
{
    Items = new List<BulkAddItem>
    {
        new BulkAddItem
        {
            Uid = "entry_uid_1",
            ContentType = "blog_post"
        },
        new BulkAddItem
        {
            Uid = "entry_uid_2",
            ContentType = "product"
        },
        new BulkAddItem
        {
            Uid = "entry_uid_3",
            ContentType = "article"
        }
    }
};

// Update items in release with specific bulk version
ContentstackResponse response = bulkOperation.UpdateItems(itemsData, "2.0");

Bulk AddItems

The AddItems method adds multiple entries and assets to a release in a single operation.

NameTypeDescription
dataBulkAddItemsData

Data containing the entries and assets to be deleted.

bulkVersionString

The bulk operation version.

Example:

var releaseData = new BulkAddItemsData
{
    Release = "release_uid",
    Action = "publish",
    Locale = new List<string> { "en-us", "en-gb" },
    Reference = true,
    Items = new List<BulkReleaseItem>
    {
        new BulkReleaseItem
        {
            ContentTypeUid = "content_type_uid",
            Uid = "entry_uid",
            Version = 1,
            Locale = "en-us",
            Title = "Sample Entry"
        },
        new BulkReleaseItem
        {
            ContentTypeUid = "content_type_uid",
            Uid = "entry_uid_2",
            Version = 2,
            Locale = "en-gb",
            Title = "Sample Entry 2"
        }
    }
};

ContentstackResponse response = bulkOperation.AddItems(releaseData, "2.0");

Bulk UpdateItemsAsync

The UpdateItemsAsync method updates multiple entries and assets to a release in a single operation.

NameTypeDescription
dataBulkAddItemsData

Data containing the entries and assets to be deleted.

bulkVersionString

The bulk operation version.

Example:

var itemsData = new BulkAddItemsData
{
    Items = new List<BulkAddItem>
    {
        new BulkAddItem
        {
            Uid = "entry_uid_1",
            ContentType = "blog_post"
        },
        new BulkAddItem
        {
            Uid = "entry_uid_2",
            ContentType = "product"
        },
        new BulkAddItem
        {
            Uid = "entry_uid_3",
            ContentType = "article"
        }
    }
};

ContentstackResponse response = await bulkOperation.UpdateItemsAsync(itemsData, "2.0");

JobStatusAsync

The JobStatusAsync method retrieves the status of a bulk operation using its job UID.

NameTypeDescription
job_idString

The UID of the bulk job

bulkVersionString

The bulk operation version.

Example:

string jobId = "job_id_from_bulk_operation";
ContentstackResponse response = bulkOperation.JobStatus(jobId);
ContentstackResponse responseWithVersion = await bulkOperation.JobStatusAsync(jobId, "2.0");

JobStatus

The JobStatus method retrieves the status of a bulk operation using its job UID.

NameTypeDescription
job_idString

The UID of the bulk job

bulkVersionString

The bulk operation version.

Example:

string jobId = "job_id_from_bulk_operation";
ContentstackResponse response = bulkOperation.JobStatus(jobId);
ContentstackResponse responseWithVersion = bulkOperation.JobStatus(jobId, "2.0");