Workflow
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.
| Name | Type | Description |
|---|---|---|
| params.action | string | Enter the action that has been set in the Publishing Rule. Example:publish/unpublish |
| params.locale | string | Enter the code of the locale where your Publishing Rule will be applicable. |
| environment | string | 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.
| Name | Type | Description |
|---|---|---|
| params.workflow | object | 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
| Name | Type | Description |
|---|---|---|
| params.limiit | number | The limit parameter will return a specific number of workflow in the output. |
| params.skip | number | The skip parameter will skip a specific number of workflow in the output. |
| params.include_count | boolean | 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.
| Name | Type | Description |
|---|---|---|
| uid | string | 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))