BulkOperation

View as Markdown

BulkOperation

Bulk operations such as Publish, Un-publish, and Delete on multiple entries or assets.

publish

The Publish entries and assets in bulk request allows you to publish multiple entries and assets at the same time.

NameTypeDescription
params.detailsobject

Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to publish the entries or assets. If you do not specify a source locale, the entries or assets will be published in the master locale automatically.

params.skip_workflow_stage_checkboolean

Set this to 'true' to publish the entries that are at a workflow stage where they satisfy the applied publish rules.

params.approvalsboolean

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

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


const publishDetails = {

  entries: [

    {

      uid: '{{entry_uid}}',

      content_type: '{{content_type_uid}}',

      version: '{{version}}',

      locale: '{{entry_locale}}'

    }

  ],

  assets: [{

    uid: '{{uid}}'

  }],

  locales: [

    'en'

  ],

  environments: [

    '{{env_uid}}'

  ]

}

client.stack({ api_key: 'api_key'}).bulkOperation().publish({ details:  publishDetails })

.then((response) => {  console.log(response.notice) })

// For Nested bulk publish pass api_version param with value 3.2

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


const publishDetails = {

  environments:["{{env_uid}}","{{env_uid}}"],

  locales:["en-us"],

  entries:[

    {

      _content_type_uid: '{{content_type_uid}}',

      uid: '{{entry_uid}}'

    },

    {

      _content_type_uid: '{{content_type_uid}}',

      uid: '{{entry_uid}}'

    },

    {

      _content_type_uid: '{{content_type_uid}}',

      uid: '{{entry_uid}}'

    }

  ]

}

client

  .stack({ api_key: 'api_key'})

  .bulkOperation().publish({ 

     details:  publishDetails, 

     api_version: 3.2 

  })

  .then((response) => {  console.log(response.notice) })

unpublish

The Unpublish entries and assets in bulk request allows you to unpublish multiple entries and assets at the same time.

NameTypeDescription
params.detailsobject

Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to unpublish the entries or assets. If you do not specify a source locale, the entries or assets will be unpublished in the master locale automatically.

params.skip_workflow_stage_checkboolean

Set this to 'true' to un-publish the entries that are at a workflow stage where they satisfy the applied un-publish rules.

params.approvalsboolean

Set this to 'true' to un-publish the entries that do not require an approval to be published.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


const publishDetails = {

  entries: [

    {

      uid: '{{entry_uid}}',

      content_type: '{{content_type_uid}}',

      version: '{{version}}',

      locale: '{{entry_locale}}'

    }

  ],

  assets: [{

    uid: '{{uid}}'

  }],

  locales: [

    'en'

  ],

  environments: [

    '{{env_uid}}'

  ]

}

client.stack({ api_key: 'api_key'}).bulkOperation().unpublish({ details:  publishDetails })

.then((response) => {  console.log(response.notice) })

// Bulk nested publish

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


const publishDetails = {

environments:["{{env_uid}}","{{env_uid}}"],

locales:["en-us"],

items:[

{

  _content_type_uid: '{{content_type_uid}}',

  uid: '{{entry_uid}}'

},

{

  _content_type_uid: '{{content_type_uid}}',

  uid: '{{entry_uid}}'

},

{

  _content_type_uid: '{{content_type_uid}}',

  uid: '{{entry_uid}}'

}

]

}

client.stack({ api_key: 'api_key'}).bulkOperation().unpublish({ details:  publishDetails, is_nested: true })

.then((response) => {  console.log(response.notice) })

delete

The Delete entries and assets in bulk request allows you to delete multiple entries and assets at the same time.

NameTypeDescription
params.detailsobject

Set this with details specifing the content type UIDs, entry UIDs or asset UIDs, and locales of which the entries or assets you want to delete.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


const publishDetails = {

  entries: [

    {

      uid: '{{entry_uid}}',

      content_type: '{{content_type_uid}}',

      locale: '{{entry_locale}}'

    }

  ],

  assets: [{

    uid: '{{uid}}'

  }]

}


client.stack({ api_key: 'api_key'}).bulkOperation().delete({ details:  publishDetails })

.then((response) => {  console.log(response.notice) })

addItems

The addItems method allows you to add multiple items to a release in bulk.

NameTypeDescription
params.dataobject

The data containing the items to be added.

params.bulk_versionstring

The bulk operation version . (2.0)

import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })

const itemsData = {
  items: [
    {
      uid: 'entry_uid',
      content_type: 'content_type_uid'
    }
  ]
}
client.stack({ api_key: 'api_key'}).bulkOperation().addItems({ data: itemsData })
  .then((response) => { console.log(response) })

updateItems

The updateItems method allows you to update multiple items in a release in bulk.

NameTypeDescription
params.dataobject

The data containing the items to be added.

params.bulk_versionstring

The bulk operation version . (2.0)

import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })

const itemsData = {
  items: [
    {
      uid: 'entry_uid',
      content_type: 'content_type_uid'
    }
  ]
  or 
  [ '$all' ]
}
client.stack({ api_key: 'api_key'}).bulkOperation().updateItems({ data: itemsData })
  .then((response) => { console.log(response) })

jobStatus

The jobStatus method allows you to check the status of a bulk job.

NameTypeDescription
params.job_idstring

The bulk job's UID

params.bulk_versionstring

The bulk operation version . (2.0)

import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })

client.stack({ api_key: 'api_key'}).bulkOperation().jobStatus({ job_id: 'job_id' })
  .then((response) => { console.log(response) })