---
title: "Stack"
description: "Stack"
url: "https://www.contentstack.com/docs/developers/sdks/content-management-sdk/javascript/reference/stack"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-21"
---

# Stack

## Stack

A [stack](/docs/headless-cms/about-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.

## update

The Update stack call lets you update the name and description of an existing stack.

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

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))
```

## fetch

The fetch stack call fetches stack details.

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

client.stack({ api_key: 'api_key'}).fetch()
.then((stack) => console.log(stack))
```

## contentType

Content type defines the structure or schema of a page or a section of your web or mobile property.

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

client.stack({ api_key: 'api_key'}).contentType()
// OR
client.stack({ api_key: 'api_key'}).contentType('uid')
```

UID for content type to perform operation on.

## locale

Locale allows you to create and publish entries in any language.

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

client.stack({ api_key: 'api_key'}).locale()
// OR
client.stack({ api_key: 'api_key'}).locale('uid')
```

UID for locale to perform operation on.

## asset

Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use.

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

client.stack({ api_key: 'api_key'}).asset()
// OR
client.stack({ api_key: 'api_key'}).asset('uid')
```

UID for asset to perform operation on.

## globalField

A Global field is a reusable field (or group of fields) that you can define once and reuse in any content type within your stack.

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

client.stack({ api_key: 'api_key'}).globalField()
// OR
client.stack({ api_key: 'api_key'}).globalField('uid')
```

UID for GlobalField to perform operation on.

## environment

Environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published.

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

client.stack({ api_key: 'api_key'}).environment()
// OR
client.stack({ api_key: 'api_key'}).environment('uid')
```

UID for environment to perform operation on.

## branch

Branch corresponds to Stack branch.

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

client.stack({ api_key: 'api_key'}).branch()
// OR
client.stack({ api_key: 'api_key'}).branch('uid')
```

UID for branch alias to perform operation on.

## branchAlias

Branch Alias is a custom name given to a specific branch in a stack to make referencing easier, especially when working with multiple branches.

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

client.stack({ api_key: 'api_key'}).branchAlias()
// OR
client.stack({ api_key: 'api_key'}).branchAlias('uid')
```

UID for branch alias to perform operation on.

## deliveryToken

Delivery Tokens provide read-only access to the associated environments.

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

client.stack({ api_key: 'api_key'}).deliveryToken()
// OR
client.stack({ api_key: 'api_key'}).deliveryToken('uid')
```

UID for delivery token to perform operation on.

## extension

Extensions let you create custom fields and custom widgets that lets you customize Contentstack's default UI and behaviour.

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

client.stack({ api_key: 'api_key'}).extension()
// OR
client.stack({ api_key: 'api_key'}).extension('uid')
```

UID for extension to perform operation on.

## 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.

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

client.stack({ api_key: 'api_key'}).workflow()
// OR
client.stack({ api_key: 'api_key'}).workflow('uid')
```

UID for workflow to perform operation on.

## webhook

Webhooks allow you to specify a URL to which you would like Contentstack to post data when an event happens.

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

client.stack({ api_key: 'api_key'}).webhook()
// OR
client.stack({ api_key: 'api_key'}).webhook('uid')
```

UID for webhook to perform operation on.

## label

Labels allow you to group a collection of content within a stack. Using labels you can group content types that need to work together

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

client.stack({ api_key: 'api_key'}).label()
// OR
client.stack({ api_key: 'api_key'}).label('label_uid')
```

UID for label to perform operation on.

## release

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.

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

client.stack({ api_key: 'api_key'}).release()
// OR
client.stack({ api_key: 'api_key'}).release('release_uid')
```

Uid for release to perform operation on.

## bulkOperation

Bulk operations such as Publish, Unpublish, and Delete on multiple entries or assets.

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

client.stack({ api_key: 'api_key'}).bulkOperation()
```

## users

The Get all users of a stack call fetches the list of all users of a particular stack

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

const users = {
 user_uid: ['role_uid_1', 'role_uid_2' ]
}

client.stack({ api_key: 'api_key'}).users()
.then((users) => console.log(users))
```

## updateUsersRoles

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.

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

const users = {
 user_uid: ['role_uid_1', 'role_uid_2' ]
}

client.stack({ api_key: 'api_key'}).updateUsersRoles(users)
.then((response) => console.log(response.notice))
```

User object with userid and roles to assign to them.

## transferOwnership

The Transfer stack ownership to other users call sends the specified user an email invitation for accepting the ownership of a particular stack.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).transferOwnership('emailId')
.then((response) => console.log(response.notice))
```

The email address of the user to whom you wish to transfer the ownership of the stack.

## settings

The Get stack settings call retrieves the configuration settings of an existing stack.

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

client.stack({ api_key: 'api_key'}).settings()
.then((settings) => console.log(settings))
```

## resetSettings

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.

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

client.stack({ api_key: 'api_key'}).resetSettings()
.then((settings) => console.log(settings))
```

## addSettings

The Add stack settings call lets you add settings for an existing stack.

```
Example 1:

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

client.stack({ api_key: 'api_key'}).addSettings({ key: 'value' })
.then((settings) => console.log(settings))
Example 2:

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

const variables = {
  stack_variables: {
    enforce_unique_urls: true,
    sys_rte_allowed_tags: "style,figure,script",
    sys_rte_skip_format_on_paste: "GD:font-size"
  },
  rte: {
    cs_breakline_on_enter: true,
    cs_only_breakline: true
  },
  live_preview: {
    enabled: true,
    "default-env": "blt123123123123",
    "default-url": "https://preview.example.com"
  }
};
client.stack({ api_key: 'api_key'}).addSettings(variables)
.then((settings) => console.log(settings)
```

Object for adding to the stack settings

## share

The Share a stack call shares a stack with the specified user to collaborate on the stack.

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

client.stack({ api_key: 'api_key'}).share([ "manager@example.com" ], { "manager@example.com": [ "abcdefhgi1234567890" ] })
.then((response) => console.log(response.notice))
```

Email id to unshare stack.

Email and role to assign to the user.

## unShare

The Unshare a stack call unshares a stack with a user and removes the user account from the list of collaborators.

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

client.stack({ api_key: 'api_key'}).unShare('email@id.com')
.then((response) => console.log(response.notice))
```

Email id to unshare stack.

## role

A role is a collection of permissions that will be applicable to all the users who are assigned this role.

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

client.stack({ api_key: 'api_key'}).role()
//or
<span>client.stack({ api_key: 'api_key'}).role('role_uid')</span>
```

Role uid for initiating role class

## create

The Create stack call creates a new stack in your Contentstack account.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const newStack = {
    stack:
        {
          name: 'My New Stack',
          description: 'My new test stack',
          master_locale: 'en-us'
        }
}
client.stack().create(newStack, { organization_uid: 'org_uid' })
.then((stack) => console.log(stack))
```

Name for the stack

Master locale for the Stack.

Description for the Stack.

Organization uid to create stack within the organization.

## query

The query() method returns a query builder. Pass optional query parameters, which are stored until any one of the following terminal methods is called:

*   find(): Retrieves multiple stacks as a ContentstackCollection.
*   findOne(): Retrieves at most one stack as a ContentstackCollection (items\[0\]).
*   count(): Returns the total count by merging count: true into the request and returning response.data.

**Note:** The find() method performs a single API request and returns a ContentstackCollection. Page size and offset are controlled via limit and skip in query(). Omitting them uses API defaults.

```
Example: Fetch a filtered list of stacks in a single request.
Note: Each include_* flag can increase response size and transfer time. Request only the expansions your app needs.
import * as contentstack from '@contentstack/management'
const client = contentstack.client({
  authtoken: '<AUTHTOKEN>',
})
client
  .stack()
  .query({
    query: { name: '<STACK_NAME>' },
    limit: 20,
    skip: 0,
    include_count: true,
    include_collaborators: true,
    include_stack_variables: true,
    include_discrete_variables: true,
  })
  .find()
  .then((stacks) => console.log(stacks))
  .catch((err) => console.error(err))Example: Get the total count of stacks matching the query
import * as contentstack from '@contentstack/management'
const client = contentstack.client({
  authtoken: '<AUTHTOKEN>',
})
client
  .stack()
  .query({
    query: { name: '<STACK_NAME>' },
    limit: 20,
    skip: 0,
    include_count: true,
    include_collaborators: true,
    include_stack_variables: true,
    include_discrete_variables: true,
  })
  .count()
  .then((data) => console.log(data))
  .catch((err) => console.error(err))
```

Top-level query object for filtering stacks. Sibling keys can include pagination and include flags.

When true, it includes the details of the stack collaborators in the response.

When true, includes stack variables in the response (e.g., description, date format, time format). Response includes stack variable details.

When true, it includes your stack's access token in the response. Response includes discrete variables.

When true, includes the total count of stacks owned by or shared with your account. Response includes a count.

## auditlog

Audit log displays a record of all the activities performed in a stack and helps you keep a track of all published items, updates, deletes, and current status of the existing content.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).auditLog().fetchAll()
.then((logs) => console.log(logs))

client.stack({ api_key: 'api_key' }).auditLog('log_item_uid').fetch()
.then((log) => console.log(log))
```

UID of the log item

## Stack | JavaScript Management SDK | Contentstack

Stack is a space that stores a project's content, letting you create content structures, entries, and users in the JavaScript Management SDK.