Get Started with JavaScript Management SDK

This guide will help you get started with Contentstack JavaScript Management SDK (that uses Content Management APIs) to manage apps powered by Contentstack. This includes operations such as creating, updating, deleting, and fetching content of your Contentstack account.


You need Node.js version 10 or above installed to use the Contentstack JavaScript Management SDK. 



Install it via npm:

npm i @contentstack/management

To import the SDK, use the following command:

import contentstack from '@contentstack/management'
contentstackClient = contentstack.client() 


To use this SDK, you need to authenticate users. You can do this by using an authtoken, credentials, or a management token (stack-level token). Let's discuss them in detail.


An authtoken is a read-write token used to make authorized CMA requests, and it is a user-specific token. 

contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' }) 


To log in to Contentstack, provide your credentials in the following code:

contentstackClient.login({ email: 'EMAIL', password: 'PASSWORD'})
.then((response) => {

Management Token

Management tokens are stack-level tokens, with no users attached to them. 

contentstackClient.stack({ api_key: 'API_KEY', management_token: 'MANAGEMENT_TOKEN' })
.then((stack) => {

Contentstack Management JavaScript SDK: 5-minute Quickstart

Initializing your SDK

To use the JavaScript CMA SDK, you need to first initialize it. To do this, use the following code: 

import contentstack from '@contentstack/management'

var contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' }) 

Fetch Stack Details

To fetch your stack details through the SDK, use the following lines of code: 

contentstackClient.stack({ api_key: 'API_KEY' })
.then((stack) => {

Create an Entry

You can use the following lines of code to create an entry in a specific content type of a stack through the SDK:

var entry  = {
    title: 'Sample Entry',
    url: '/sampleEntry'

contentstackClient.stack({ api_key: 'API_KEY' }).contentType('CONTENT_TYPE_UID').entry().create({ entry })
.then((entry) => {

Upload Assets

Use the following code snippet to upload assets to your stack through the SDK:

var asset  = {
    upload: 'path/to/file',
    title: 'Asset Title'

contentstackClient.stack({ api_key: 'API_KEY' }).asset().create({ asset })
.then((asset) => {

Further Reading

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page