---
title: "[JavaScript Management] - Get Started with JavaScript Management SDK"
description: Get started guide for Contentstack JavaScript Management SDK (Content Management APIs) including installation, authentication, initialization, and basic operations.
url: https://www.contentstack.com/docs/developers/sdks/content-management-sdk/javascript/get-started-with-javascript-management-sdk
product: Contentstack
doc_type: sdk-guide
audience:
  - developers
  - javascript-developers
  - nodejs-developers
version: latest
last_updated: 2026-03-25
---

# [JavaScript Management] - Get Started with JavaScript Management SDK

This page explains how to install, authenticate, and initialize the Contentstack JavaScript Management SDK, and shows basic examples (fetch stack details, create entries, upload assets). It is intended for developers building Node.js/JavaScript or TypeScript tools and apps that manage Contentstack content via the Content Management APIs.

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

## Prerequisite
You need [Node.js](https://nodejs.org/en) version 22 or above installed to use the Contentstack JavaScript Management SDK.

## Installation
To install it via npm:

```
npm i @contentstack/management
```

To import the SDK, use one of the following ways:
- **JavaScript ES Modules**

This method provides access to the `client` function via the default export. It requires `"type": "module"` in `package.json` to support ES module usage.

```
import contentstack from '@contentstack/management';
```

- **TypeScript with esModuleInterop**

This method provides access to the `client` function via the default export. Requires `"type": "module"` in `package.json` and `"esModuleInterop": true` in `tsconfig.json`.

```
import contentstack from '@contentstack/management';
```

- **TypeScript Namespace Import**

This method functions correctly, regardless of the `"esModuleInterop"` setting in `tsconfig.json`, ensuring broad compatibility across module configurations.

```
import * as contentstack from '@contentstack/management';
```

- **TypeScript Destructuring**

Accesses the `client` function through the default export, enabling streamlined integration in ES module environments.

```
import contentstack from '@contentstack/management';
const { client } = contentstack;
```

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

### Authtoken
An [authtoken](/docs/developers/create-tokens/types-of-tokens#authentication-tokens-authtokens-) is a read-write token used to make authorized CMA requests, and it is a user-specific token.

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

### Login
The login call allows you to sign in to your Contentstack account and obtain an authentication token (authtoken). Multi-Factor Authentication (MFA) is supported for SDK based logins.

| Name | Type | Description |
|---|---|---|
| email *(required)* | string | Registered email address used for login |
| password *(required)* | string | Password associated with the registered email |
| tfa_token | string | **Required for MFA-enabled accounts**. One-time passcode generated by an authenticator app for completing MFA during login. |
| mfaSecret | string | **Required to generate the **`**tfa_token**`** dynamically**. Secret key generated when MFA is enabled for the user. |

**Example:**

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

// When user does not have MFA enabled
client.login({ email: , password:  })
.then(() => {

}))

// When user have MFA enabled
client.login({ email: , password: , tfa_token:  })
.then(() => {
}))

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

client.login({ email: , password: , mfaSecret:  })
.then(() => {
}))
```

**Note: **The `mfaSecret` is not passed in the request body—it’s used to generate the OTP dynamically, which is then sent as the tfa_token.

### OAuth
**Note: **This feature requires `@contentstack/management` **version 1.20.0** or later and registered OAuth client credentials.

The JavaScript Management SDK supports **OAuth 2.0**, enabling secure, token-based access to Contentstack’s Content Management APIs. This integration simplifies authentication by automating token acquisition, refresh, and secure lifecycle management.

With OAuth 2.0, developers can easily implement secure access for both **web-based interfaces** and **command-line tools**.

**Additional Resource**: For more information on the OAuth support in JavaScript Management SDK, refer to [Implement OAuth 2.0 with JavaScript Management SDK](/docs/developers/sdks/content-management-sdk/javascript/implement-oauth-2-0-with-javascript-management-sdk) documentation.

**Key Features**
- **Easy SDK initialization**: Set up OAuth effortlessly by configuring the SDK with minimal credentials.
- **Automatic token management**: The SDK seamlessly handles token acquisition, automatic refresh on expiry, and secure in-memory storage—ensuring uninterrupted authentication.
- **Compatible with both web and CLI applications**: The SDK works seamlessly across browser-based apps and command-line tools, supporting multiple secure token storage strategies.
- **Built-in logout functionality**: Easily terminate the user sessions with a single method that clears tokens and resets the authentication state.
- **Token revocation support included**: Integrated token revocation allows your app to invalidate access upon logout or session expiration.

### Management Token
[Management tokens](/docs/developers/create-tokens/about-management-tokens) are stack-level tokens with no users attached to them.

```
import * as contentstack from '@contentstack/management'
contentstackClient = contentstack.client()
contentstackClient.stack({ api_key: 'API_KEY', management_token: 'MANAGEMENT_TOKEN' })
.fetch()
.then((stack) => {
    console.log(stack)
})
```

## Initialize your SDK
To use the JavaScript CMA SDK, you need to first initialize it.

```
import * as contentstack from '@contentstack/management'

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

**Initialization with Management Token and Branch**

If you want to initialize SDK in a particular branch use the code given below:

```
import * as contentstack from '@contentstack/management'
contentstackClient = contentstack.client()
contentstackClient.stack({ api_key: 'API_KEY', management_token: 'MANAGEMENT_TOKEN', branch_uid: 'BRANCH'})
```

**Initialization with Host Configuration**

When using Contentstack, set the `host` to `api.contentstack.io` to connect to the North America (NA) region. This ensures the client communicates with the correct API endpoint:

```
https://api.contentstack.io
```

Contentstack supports multiple regions, each with a distinct base URL. Using the correct region-specific endpoint ensures optimal performance and compliance with regional data regulations.

For a full list of supported region values and their corresponding base URLs, refer to the [Content Management API](/docs/developers/apis/content-management-api#base-url) documentation.

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ host: 'api.contentstack.io' });
```

### Proxy Configuration
Contentstack allows you to define HTTP proxy for your requests with the JavaScript Management SDK. A proxied request allows you to anonymously access public URLs even from within a corporate firewall through a proxy server.

Here is the basic syntax of the proxy settings that you can pass within `fetchOptions` of the JavaScript Management SDK:

```
import * as contentstack from '@contentstack/management'
const client = contentstack.client({
 proxy: {
   protocol: 'https',
   host: '127.0.0.1',
   port: 9000,
   auth: {
     username: 'username',
     password: 'password'
   }
 },
})
```

## Fetch Stack Details
To fetch your stack details through the SDK, use the following:

```
import * as contentstack from '@contentstack/management'
contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' })
contentstackClient.stack({ api_key: 'API_KEY' })
.fetch()
.then((stack) => {
    console.log(stack)
})
```

## Create an Entry
You can use the following to create an entry in a specific content type of a stack through the SDK:

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

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

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

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

```
import contentstack from '@contentstack/management'
contentstackClient = contentstack.client({ authtoken: 'AUTHTOKEN' })

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

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

## Further Reading
- [Contentstack Website](https://www.contentstack.com)
- [Content Management API Docs](/docs/developers/apis/content-management-api)

## Common questions

### Which Node.js version is required?
You need [Node.js](https://nodejs.org/en) version 22 or above installed to use the Contentstack JavaScript Management SDK.

### What authentication options does the SDK support?
You can authenticate using an authtoken, credentials (login), OAuth 2.0, or a management token (stack-level token).

### How do I connect to a specific region endpoint?
Set the `host` in the client configuration (for example, `api.contentstack.io` for the North America (NA) region) and refer to the [Content Management API](/docs/developers/apis/content-management-api#base-url) documentation for other base URLs.

### Can I use a proxy with the JavaScript Management SDK?
Yes. You can define an HTTP proxy for your requests by passing proxy settings within the client configuration.