- Source:
A stack is a space that stores the content of a project (a web or mobile property). Within a stack, you can create content structures, content entries, users, etc. related to the project. Read more about Stacks.
Methods
(static) update() → {Promise.<Stack.Stack>}
- Source:
The Update stack call lets you update the name and description of an existing stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).fetch()
.then((stack) => {
stack.name = 'My New Stack'
stack.description = 'My new test stack'
return stack.update()
})
.then((stack) => console.log(stack))
Returns:
Promise for Stack instance
- Type
- Promise.<Stack.Stack>
(static) fetch() → {Promise.<Stack.Stack>}
- Source:
The fetch stack call fetches stack details.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).fetch()
.then((stack) => console.log(stack))
Returns:
Promise for Stack instance
- Type
- Promise.<Stack.Stack>
contentType(uid) → {ContentType}
- Source:
Content type defines the structure or schema of a page or a section of your web or mobile property.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).contentType().create()
.then((contentType) => console.log(contentType))
client.stack({ api_key: 'api_key'}).contentType('content_type_uid').fetch()
.then((contentType) => console.log(contentType))
Parameters:
Name | Type | Description |
---|---|---|
uid |
String | The UID of the ContentType you want to get details. |
Returns:
Instance of ContentType.
- Type
- ContentType
locale(uid) → {Locale}
- Source:
Locale allows you to create and publish entries in any language.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).locale().create()
.then((locale) => console.log(locale))
client.stack({ api_key: 'api_key'}).locale('locale_code').fetch()
.then((locale) => console.log(locale))
Parameters:
Name | Type | Description |
---|---|---|
uid |
String | The UID of the Locale you want to get details. |
Returns:
Instance of Locale.
- Type
- Locale
asset(uid) → {Asset}
- Source:
Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).asset().create()
.then((asset) => console.log(asset))
client.stack({ api_key: 'api_key'}).asset('asset_uid').fetch()
.then((asset) => console.log(asset))
Parameters:
Name | Type | Description |
---|---|---|
uid |
String | The UID of the Asset you want to get details. |
Returns:
Instance of Asset.
- Type
- Asset
globalField(uid) → {GlobalField}
- Source:
Global field defines the structure or schema of a page or a section of your web or mobile property.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).globalField().create()
.then((globalField) => console.log(globalField))
client.stack({ api_key: 'api_key'}).globalField('globalField_uid').fetch()
.then((globalField) => console.log(globalField))
Parameters:
Name | Type | Description |
---|---|---|
uid |
String | The UID of the Global field you want to get details. |
Returns:
Instance of Global field.
- Type
- GlobalField
environment(uid) → {Environment}
- Source:
Environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).environment().create()
.then((environment) => console.log(environment))
client.stack({ api_key: 'api_key'}).environment('environment_uid').fetch()
.then((environment) => console.log(environment))
Parameters:
Name | Type | Description |
---|---|---|
uid |
String | The UID of the Environment you want to get details. |
Returns:
Instance of Environment.
- Type
- Environment
branch(branchUid) → {Branch}
- Source:
Branch corresponds to Stack branch.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).branch().create()
.then((branch) => console.log(branch))
client.stack({ api_key: 'api_key' }).branch('branch_uid').fetch()
.then((branch) => console.log(branch))
Parameters:
Name | Type | Description |
---|---|---|
branchUid |
String |
Returns:
- Type
- Branch
branchAlias(branchUid) → {BranchAlias}
- Source:
Branch corresponds to Stack branch.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).branchAlias().create()
.then((branch) => console.log(branch))
client.stack({ api_key: 'api_key' }).branchAlias('branch_alias_uid').fetch()
.then((branch) => console.log(branch))
Parameters:
Name | Type | Description |
---|---|---|
branchUid |
String |
Returns:
- Type
- BranchAlias
deliveryToken(deliveryTokenUid) → {DeliveryToken}
- Source:
Delivery Tokens provide read-only access to the associated environments.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).deliveryToken().create()
.then((deliveryToken) => console.log(deliveryToken))
client.stack({ api_key: 'api_key'}).deliveryToken('deliveryToken_uid').fetch()
.then((deliveryToken) => console.log(deliveryToken))
Parameters:
Name | Type | Description |
---|---|---|
deliveryTokenUid |
String | The UID of the Delivery Token field you want to get details. |
Returns:
Instance of DeliveryToken.
- Type
- DeliveryToken
extension(extensionUid) → {Extension}
- Source:
Extensions let you create custom fields and custom widgets that lets you customize Contentstack's default UI and behavior.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).extension().create()
.then((extension) => console.log(extension))
client.stack({ api_key: 'api_key'}).extension('extension_uid').fetch()
.then((extension) => console.log(extension))
Parameters:
Name | Type | Description |
---|---|---|
extensionUid |
String | The UID of the Extension you want to get details. |
Returns:
Instance of Extension.
- Type
- Extension
workflow(workflowUid) → {Workflow}
- Source:
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.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).workflow().create()
.then((workflow) => console.log(workflow))
client.stack({ api_key: 'api_key'}).workflow('workflow_uid').fetch()
.then((workflow) => console.log(workflow))
Parameters:
Name | Type | Description |
---|---|---|
workflowUid |
String | The UID of the Workflow you want to get details. |
Returns:
Instance of Workflow.
- Type
- Workflow
webhook(webhookUid) → {Webhook}
- Source:
Webhooks allow you to specify a URL to which you would like Contentstack to post data when an event happens.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).webhook().create()
.then((webhook) => console.log(webhook))
client.stack({ api_key: 'api_key'}).webhook('webhook_uid').fetch()
.then((webhook) => console.log(webhook))
Parameters:
Name | Type | Description |
---|---|---|
webhookUid |
String | The UID of the Webhook you want to get details. |
Returns:
Instance of Webhook.
- Type
- Webhook
label(uid) → {Label}
- Source:
Labels allow you to group a collection of content within a stack. Using labels you can group content types that need to work together
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).label().create()
.then((label) => console.log(label))
client.stack({ api_key: 'api_key'}).label('label_uid').fetch()
.then((label) => console.log(label))
Parameters:
Name | Type | Description |
---|---|---|
uid |
String | The UID of the Label you want to get details. |
Returns:
Instance of Label.
- Type
- Label
release(releaseUid) → {Release}
- Source:
You can pin a set of entries and assets (along with the deploy action, i.e., publish/unpublish) to a ‘release’, and then deploy this release to an environment.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).release().create()
.then((release) => console.log(release))
client.stack({ api_key: 'api_key'}).release('release_uid').fetch()
.then((release) => console.log(release))
Parameters:
Name | Type | Description |
---|---|---|
releaseUid |
String | The UID of the Releases you want to get details. |
Returns:
Instance of Release.
- Type
- Release
bulkOperation() → {BulkOperation}
- Source:
Bulk operations such as Publish, Unpublish, and Delete on multiple entries or assets.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const publishDetails = {
entries: [
{
uid: '{{entry_uid}}',
content_type: '{{content_type_uid}}',
version: '{{version}}',
locale: '{{entry_locale}}'
}
],
assets: [{
uid: '{{uid}}'
}],
locales: [
'en'
],
environments: [
'{{env_name}}/env_uid}}'
]
}
client.stack({ api_key: 'api_key'}).bulkOperation().publish({ details: publishDetails })
.then((response) => { console.log(response.notice) })
Returns:
Instance of BulkOperation.
- Type
- BulkOperation
(static) users() → {Array.<User>}
- Source:
The Get all users of a stack call fetches the list of all users of a particular stack
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).users()
.then((users) => console.log(users))
Returns:
Array of User's including owner of Stack
- Type
- Array.<User>
(static) updateUsersRoles(users) → {Object}
- Source:
The Update User Role API Request updates the roles of an existing user account.
This API Request will override the existing roles assigned to a user
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const users = {
user_uid: ['role_uid_1', 'role_uid_2' ]
}
client.stack({ api_key: 'api_key'}).updateUsersRoles(users)
.then((response) => console.log(response.notice))
Parameters:
Name | Type | Description |
---|---|---|
users |
* | object containing userId and array of roles to assign user. |
Returns:
Response Object.
- Type
- Object
(static) transferOwnership(email) → {Object}
- Source:
The Transfer stack ownership to other users call sends the specified user an email invitation for accepting the ownership of a particular stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).transferOwnership('emailId')
.then((response) => console.log(response.notice))
Parameters:
Name | Type | Description |
---|---|---|
email |
String | The email address of the user to whom you wish to transfer the ownership of the stack. |
Returns:
Response Object.
- Type
- Object
(static) settings() → {Object}
- Source:
The Get stack settings call retrieves the configuration settings of an existing stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).settings()
.then((settings) => console.log(settings))
Returns:
Configuration settings of stack.
- Type
- Object
(static) resetSettings() → {Object}
- Source:
The Reset stack settings call resets your stack to default settings, and additionally, lets you add parameters to or modify the settings of an existing stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).resetSettings()
.then((settings) => console.log(settings))
Returns:
Configuration settings of stack.
- Type
- Object
(static) addSettings() → {Object}
- Source:
The Add stack settings call lets you add settings for an existing stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).addSettings({ key: 'value' })
.then((settings) => console.log(settings))
Returns:
Configuration settings of stack.
- Type
- Object
(static) share(emails, roles) → {Object}
- Source:
The Share a stack call shares a stack with the specified user to collaborate on the stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).share([ "manager@example.com" ], { "manager@example.com": [ "abcdefhgi1234567890" ] })
.then((response) => console.log(response.notice))
Parameters:
Name | Type | Description |
---|---|---|
emails |
Array.<String> | Email ID of the user with whom you wish to share the stack |
roles |
Array.<String> | The role uid that you wish to assign the user. |
Returns:
Response Object.
- Type
- Object
(static) unShare(email) → {Object}
- Source:
The Unshare a stack call unshares a stack with a user and removes the user account from the list of collaborators.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).unShare('email@id.com')
.then((response) => console.log(response.notice))
Parameters:
Name | Type | Description |
---|---|---|
email |
String | The email ID of the user from whom you wish to unshare the stack. |
Returns:
Response Object.
- Type
- Object
(static) role(uidopt) → {Role}
- Source:
A role is a collection of permissions that will be applicable to all the users who are assigned this role.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).role().create({
"role":
{
"name":"testRole",
"description":"",
"rules":[...],
}
})
.then((role) => console.log(role))
client.stack({ api_key: 'api_key'}).role('role_uid').fetch())
.then((role) => console.log(role))
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
uid |
String |
<optional> |
The UID of the role you want to get details. |
Returns:
Instance of Role.
- Type
- Role
(static) create() → {Promise.<Stack.Stack>}
- Source:
The Create stack call creates a new stack in your Contentstack account.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack().create({name: 'My New Stack'}, { organization_uid: 'org_uid' })
.then((stack) => console.log(stack))
Returns:
Promise for Stack instance
- Type
- Promise.<Stack.Stack>
(static) query(include_collaborators, include_stack_variablesSet, include_discrete_variables, include_count, query) → {ContentstackCollection}
- Source:
The Query on Stack will allow to fetch details of all or specific Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack().query({ query: { name: 'Stack Name' } }).find()
.then((stack) => console.log(stack))
Parameters:
Name | Type | Description |
---|---|---|
include_collaborators |
Boolean | Set this parameter to 'true' to include the details of the stack collaborators. |
include_stack_variablesSet |
Boolean | this to 'true' to display the stack variables. Stack variables are extra information about the stack, such as the description, format of date, format of time, and so on. Users can include or exclude stack variables in the response. |
include_discrete_variables |
Boolean | Set this to 'true' to view the access token of your stack. |
include_count |
Boolean | Set this to 'true' to include in the response the total count of the stacks owned by or shared with a user account. |
query |
Object | Queries that you can use to fetch filtered results. |
Returns:
Instance of ContentstackCollection.
- Type
- ContentstackCollection