Workflow

View as Markdown

Workflow

Workflow is a tool that allows you to streamline the process of content creation and publishing, and lets you manage the content lifecycle of your project smoothly.

update

The Update Workflow request allows you to add a workflow stage or update the details of the existing stages of a workflow.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow('workflow_uid').fetch()

.then((workflow) => {

 workflow.name = 'My New Workflow'

 workflow.description = 'Workflow description'

 return workflow.update()

})

.then((workflow) => console.log(workflow))

disable

The Disable Workflow request allows you to disable a workflow.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow('workflow_uid')

.disable()

.then((workflow) => console.log(workflow))

enable

The Enable Workflow request allows you to enable a workflow.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow('workflow_uid')

.enable()

.then((workflow) => console.log(workflow))

delete

The Delete Workflow call is used to delete an existing Workflow permanently from your Stack.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow('workflow_uid')

.delete()

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

fetch

The fetch workflow retrieves the comprehensive details of a specific Workflow of a stack.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow('workflow_uid')

.fetch()

.then((workflow) => console.log(workflow))

getPublishRules

The get Workflow call is used to get details of an existing Workflow from your Stack.

NameTypeDescription
params.actionstring

Enter the action that has been set in the Publishing Rule. Example:publish/unpublish

params.localestring

Enter the code of the locale where your Publishing Rule will be applicable.

environmentstring

Enter the UID of the environment where your Publishing Rule will be applicable.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow()

.contentType('contentType_uid')

.getPublishRules()

.then((collection) => console.log(collection))

create

The Create a Workflow request allows you to create a Workflow.

NameTypeDescription
params.workflowobject

The workflow details with workflow stages.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


const workflow = {

"workflow_stages": [

     {

       "color": "#2196f3",

       "SYS_ACL": {

         "roles": {

           "uids": []

         },

         "users": {

         "uids": [

           "$all"

         ]

       },

       "others": {}

     },

     "next_available_stages": [

       "$all"

     ],

     "allStages": true,

     "allUsers": true,

     "specificStages": false,

     "specificUsers": false,

     "entry_lock": "$none", 

     "name": "Review"

   },

   {

     "color": "#74ba76",

     "SYS_ACL": {

       "roles": {

         "uids": []

       },

       "users": {

         "uids": [

           "$all"

         ]

       },

       "others": {}

     },

     "allStages": true,

     "allUsers": true,

     "specificStages": false,

     "specificUsers": false,

     "next_available_stages": [

         "$all"

       ],

       "entry_lock": "$none",

       "name": "Complete"

     }

   ],

   "admin_users": {

     "users": []

   },

     "name": "Workflow Name",

     "enabled": true,

     "content_types": [

       "$all"

     ]

 }


client.stack({ api_key: 'api_key'}).workflow()

.create({ workflow })

.then((workflow) => console.log(workflow))

fetchAll

The Get all Workflows request retrieves the details of all the Workflows of a stack.

NameTypeDescription
params.limiitnumber

The limit parameter will return a specific number of workflow in the output.

params.skipnumber

The skip parameter will skip a specific number of workflow in the output.

params.include_countboolean

To retrieve the count of workflow.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow()

.fetchAll()

.then((collection) => console.log(collection))

publishRule

The Publish rule allow you to create, fetch, delete, update the publish rules.

NameTypeDescription
uidstring

Uid for publish rule.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).workflow().publishRule().fetchAll()

.then((collection) => console.log(collection))


client.stack({ api_key: 'api_key'}).workflow().publishRule('rule_uid').fetch()

.then((publishrule) => console.log(publishrule))